[nemerle] r8413 committed - Improve performance of editing global level code (i.e. types members, ...

2 views
Skip to first unread message

codesite...@google.com

unread,
Oct 29, 2009, 12:03:36 AM10/29/09
to nemer...@googlegroups.com
Revision: 8413
Author: v...@rsdn.ru
Date: Wed Oct 28 21:02:28 2009
Log: Improve performance of editing global level code (i.e. types members,
types and namespaces).
http://code.google.com/p/nemerle/source/detail?r=8413

Modified:

/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Async/AsyncRequest/AsyncRequest.n

/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Async/AsyncRequest/CompletionAsyncRequest.n

/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Async/AsyncRequestType.n

/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Completion2/CompilerConcreteDefinitions/IntelliSenseModeMethodBuilder.n

/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/BackgroundWorks/Engine-BuildTypeTree.n

/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/BackgroundWorks/Engine-UpdateCompileUnit.n

/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n

/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/IEngine.n

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/LanguageService/NemerleLanguageService.cs

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/LanguageService/NemerleScanner.cs

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/LanguageService/NemerleViewFilter.cs
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/NemerlePackage.cs

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/Project/NemerleProjectNode.cs
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/Project/ProjectInfo.cs

=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Async/AsyncRequest/AsyncRequest.n
Wed Sep 2 07:38:29 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Async/AsyncRequest/AsyncRequest.n
Wed Oct 28 21:02:28 2009
@@ -70,6 +70,8 @@
{
if (other.Engine : object != this.Engine)
false
+ else if (other.Type == AsyncRequestType.CloseProject)
+ true
else match (Type)
{
| AsyncRequestType.UpdateCompileUnit =>
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Async/AsyncRequest/CompletionAsyncRequest.n
Wed Sep 2 01:20:55 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Async/AsyncRequest/CompletionAsyncRequest.n
Wed Oct 28 21:02:28 2009
@@ -35,6 +35,7 @@
false
else match (other.Type)
{
+ | AsyncRequestType.CloseProject
| AsyncRequestType.UpdateCompileUnit
| AsyncRequestType.BuildTypesTree => true
| _ => false
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Async/AsyncRequestType.n
Mon Oct 26 02:38:15 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Async/AsyncRequestType.n
Wed Oct 28 21:02:28 2009
@@ -23,5 +23,6 @@
| HighlightUsages
| FindUnimplementedMembers
| FindMethodsToOverride
+ | CloseProject
}
}
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Completion2/CompilerConcreteDefinitions/IntelliSenseModeMethodBuilder.n
Tue Oct 13 14:21:15 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Completion2/CompilerConcreteDefinitions/IntelliSenseModeMethodBuilder.n
Wed Oct 28 21:02:28 2009
@@ -144,7 +144,7 @@
assert(!(Attributes %&& NemerleAttributes.Abstract ||
BodyLocation.FileIndex <= 0));
when (_bodyParsed == null)
{
- Trace.WriteLine($">>>> ##### BodyParsed ($Name)! - _bodyParsed
== null");
+ //Trace.WriteLine($">>>> ##### BodyParsed ($Name)! - _bodyParsed
== null");

when (_bodyMessages != null)
_bodyMessages.Clear();
@@ -154,7 +154,7 @@
// if (Location.IsGenerated
&& !fun_header.Name.OrdinalStartsWith("_N_field_initialiser"))
match (fun_header.body)
{
- | FunBody.Parsed(code) => Body = code; Trace.WriteLine($">>>>
##### BodyParsed ($Name)! - fun_header.body is FunBody.Parsed(code)");
+ | FunBody.Parsed(code) => Body = code;
//Trace.WriteLine($">>>> ##### BodyParsed ($Name)! - fun_header.body is
FunBody.Parsed(code)");
| _ =>
def source = Manager.GetSource(BodyLocation.FileIndex);
def member = if (source.CompileUnit == null) null
@@ -164,9 +164,10 @@
{
| Some(ClassMember.Function(body = FunBody.Parsed(expr)))
=>
SetBodyParsed(expr);
- Trace.WriteLine($">>>> ##### BodyParsed ($Name)! - взяли
тело из CompileUnit-а!");
+ //Trace.WriteLine($">>>> ##### BodyParsed ($Name)! -
взяли тело из CompileUnit-а!");

| _ =>
+ Trace.WriteLine($">>>> ##### BodyParsed ($Name)! -
читаем тело из исходника! Это не здорово!");
//assert2(false); // VladD2: This sould not be happen!

//def indent = _indent; _indent += " ";
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/BackgroundWorks/Engine-BuildTypeTree.n
Wed Oct 28 16:13:10 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/BackgroundWorks/Engine-BuildTypeTree.n
Wed Oct 28 21:02:28 2009
@@ -27,8 +27,23 @@

public RequestOnBuildTypesTree() : void
{
+ LastEditTime = DateTime.Now;
IsNeedBuildTypesTree = true;
}
+
+ public OnIdle() : void
+ {
+ when (IsNeedBuildTypesTree)
+ {
+ def delta = DateTime.Now - LastEditTime;
+
+ when (delta.TotalMilliseconds > 2000)
+ {
+ IsNeedBuildTypesTree = false;
+ _ = BeginBuildTypesTree();
+ }
+ }
+ }

public BeginBuildTypesTree() : AsyncRequest
{
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/BackgroundWorks/Engine-UpdateCompileUnit.n
Wed Oct 14 19:42:38 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/BackgroundWorks/Engine-UpdateCompileUnit.n
Wed Oct 28 21:02:28 2009
@@ -26,8 +26,11 @@

public partial class Engine
{
+ public LastEditTime : DateTime { get; private set; }
+
public BeginUpdateCompileUnit(source : ISource) : AsyncRequest
{
+ LastEditTime = DateTime.Now;
def request = AsyncRequest(AsyncRequestType.UpdateCompileUnit, this,
source, UpdateCompileUnit);
AsyncWorker.AddWork(request);
request
@@ -79,7 +82,7 @@
def isUpdate = rel.Begin != rel.Old && rel.Begin != rel.New;
if (resetedMember == null && isUpdate)
{
- ignore(BeginBuildTypesTree());
+ RequestOnBuildTypesTree();
break;
}
else when (needRelocation)
@@ -193,7 +196,7 @@
}

if (isNeedRebuildTypesTree(this, source))
- ignore(BeginBuildTypesTree());
+ RequestOnBuildTypesTree();
else lock (source.RelocationRequestsQueue)
{
try
@@ -208,10 +211,8 @@
}
catch
{
- | _ is Completion.RelocationFailedException =>
- _ = BeginBuildTypesTree();
- | _ =>
- throw;
+ | _ is Completion.RelocationFailedException =>
RequestOnBuildTypesTree();
+ | _ => throw;
}
}
}
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n
Mon Aug 31 14:24:47 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n
Wed Oct 28 21:02:28 2009
@@ -13,6 +13,7 @@
using Nemerle.Imperative;
using Nemerle.Utility;
using Nemerle.Compiler.Utils;
+using Nemerle.Compiler.Utils.Async;

using Typed = Nemerle.Compiler.Typedtree;
using TExpr = Nemerle.Compiler.Typedtree.TExpr;
@@ -35,6 +36,11 @@

public GetSource(fileIndex : int) : ISource {
_callback.GetSource(fileIndex) }
public GetSources() : SCG.IEnumerable[ISource] {
_callback.GetSources() }
+
+ public Close() : void
+ {
+ AsyncWorker.AddWork(AsyncRequest(AsyncRequestType.CloseProject,
this, null, _ => ()));
+ }

// HACK: see usings
public static VeryBigNumber = 1000000;
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/IEngine.n
Mon Aug 31 14:24:47 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/IEngine.n
Wed Oct 28 21:02:28 2009
@@ -14,6 +14,9 @@
BeginReloadProject() : AsyncRequest;
/// Build the Types Tree witout reload information obout project.
BeginBuildTypesTree() : AsyncRequest;
+ /// Send request on Build the Types Tree. It not lead to immediately
rebuild project.
+ /// The project will be rebuilded when IDE turn into idle state (user
will not be type in editor).
+ RequestOnBuildTypesTree() : void;
/// Cal this method when file changed in editor.
BeginUpdateCompileUnit(source : ISource) : AsyncRequest;
/// Get information for display hint (in IDE).
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/LanguageService/NemerleLanguageService.cs
Tue Oct 20 11:03:27 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/LanguageService/NemerleLanguageService.cs
Wed Oct 28 21:02:28 2009
@@ -27,6 +27,7 @@
using Nemerle.VisualStudio.Properties;
using Microsoft.VisualStudio.Package;

+// ReSharper disable LocalizableElement
namespace Nemerle.VisualStudio.LanguageService
{
///<summary>
@@ -632,6 +633,9 @@
if (IsDisposed)
return;

+ foreach (var prj in ProjectInfo.Projects)
+ prj.Engine.OnIdle();
+
if (periodic)
{
var maxTime = TimeSpan.FromSeconds(0.05);
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/LanguageService/NemerleScanner.cs
Sat Oct 10 12:57:07 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/LanguageService/NemerleScanner.cs
Wed Oct 28 21:02:28 2009
@@ -37,10 +37,10 @@

if (engine.CoreEnv == null) // Engine not init yet. We mast
BuildTypesTree for init it
{
- engine.BeginBuildTypesTree(); // Building types tree
- System.Threading.Thread.Sleep(1000);
- if (engine.CoreEnv == null)
- return null;
+ if (!engine.IsBuildTypesTreeInProgress &&
engine.IsNeedBuildTypesTree)
+ engine.RequestOnBuildTypesTree();
+
+ return null;
}

return new ScanLexer(engine);
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/LanguageService/NemerleViewFilter.cs
Wed Oct 28 16:13:10 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/LanguageService/NemerleViewFilter.cs
Wed Oct 28 21:02:28 2009
@@ -154,7 +154,7 @@
pkg.SelectionExtend.Enabled = false;
pkg.SelectionShrink.Enabled = false;

- Debug.WriteLine("OnKillFocus(IVsTextView view)");
+ //Debug.WriteLine("OnKillFocus(IVsTextView view)");
base.OnKillFocus(view);
}

@@ -167,7 +167,7 @@
pkg.SelectionExtend.Enabled = true;
pkg.SelectionShrink.Enabled = true;

- Debug.WriteLine("OnSetFocus(IVsTextView view)");
+ //Debug.WriteLine("OnSetFocus(IVsTextView view)");
//ShowAst(view, true);
base.OnSetFocus(view);

=======================================
--- /nemerle/trunk/VsIntegration/Nemerle.VisualStudio/NemerlePackage.cs Mon
Oct 19 04:51:16 2009
+++ /nemerle/trunk/VsIntegration/Nemerle.VisualStudio/NemerlePackage.cs Wed
Oct 28 21:02:28 2009
@@ -8,6 +8,7 @@
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Project;
+using System.Linq;

using Nemerle.VisualStudio.LanguageService;
using Nemerle.VisualStudio.Project;
@@ -160,6 +161,16 @@
{
base.Initialize();

+ foreach (var listener in
Trace.Listeners.OfType<DefaultTraceListener>())
+ listener.AssertUiEnabled = false;
+
+ foreach (var listener in
Debug.Listeners.OfType<DefaultTraceListener>())
+ listener.AssertUiEnabled = false;
+
+ //Debug.Assert(false);
+ //Trace.Listeners.Clear();
+ //Trace.Listeners.Clear();
+
RegisterProjectFactory(new NemerleProjectFactory(this));
RegisterEditorFactory (new NemerleEditorFactory (this));
RegisterProjectFactory(new NemerleWPFProjectFactory(this));
@@ -207,7 +218,7 @@

private static void RegisterCommand(OleMenuCommandService service,
CommandID commandId, EventHandler handler)
{
- MenuCommand command = new MenuCommand(handler, commandId);
+ var command = new MenuCommand(handler, commandId);
service.AddCommand(command);
//Debug.WriteLine(string.Format("Menu command {0} added", command));
}
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/Project/NemerleProjectNode.cs
Mon Aug 31 14:24:47 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/Project/NemerleProjectNode.cs
Wed Oct 28 21:02:28 2009
@@ -628,7 +628,7 @@
// event handler generation (EventBindingProvider) for the XAML
designer.
OleServiceProvider.AddService(typeof(DesignerContext),
DesignerContext, false);

- _projectInfo.BeginReloadProject();
+ //_projectInfo.BeginReloadProject();
}

public override void PrepareBuild(string config, bool cleanBuild)
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/Project/ProjectInfo.cs
Mon Oct 26 02:38:15 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/Project/ProjectInfo.cs
Wed Oct 28 21:02:28 2009
@@ -111,7 +111,7 @@
{
if (IsCosed)
return;
-
+ Engine.Close();
IsCosed = true;
_projects.Remove(this);
_errorList.Tasks.Clear();
Reply all
Reply to author
Forward
0 new messages