[svn] r7429: vs-plugin/trunk:
Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
Nemerle.Compiler.Utils/...
VladD2
svnadmin at nemerle.org
Thu Feb 15 03:13:21 CET 2007
Log:
1. Fix 788 (The integration does not use newly added /removed references until VS reloaded).
2. Some refactoring.
Author: VladD2
Date: Thu Feb 15 03:13:15 2007
New Revision: 7429
Removed:
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/EngineState.n
Modified:
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Completion.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Init.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Properties.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.crud.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/ReferenceCollection.n
vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleScanner.cs
vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleTypeAndMemberDropdownBars .cs
vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNode.cs
vs-plugin/trunk/Nemerle.VsIntegration/Project/ProjectInfo.cs
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj Thu Feb 15 03:13:15 2007
@@ -92,7 +92,6 @@
<Compile Include="Nemerle.Completion2\CodeCompletionEngineException.n" />
<Compile Include="Nemerle.Completion2\Decl.n" />
<Compile Include="Nemerle.Completion2\DefineCollection.n" />
- <Compile Include="Nemerle.Completion2\EngineState.n" />
<Compile Include="Nemerle.Completion2\InternalReference.n" />
<Compile Include="Nemerle.Completion2\ReferenceCollection.n" />
<Compile Include="Nemerle.Completion2\Relocation.n" />
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n Thu Feb 15 03:13:15 2007
@@ -22,7 +22,7 @@
{
public event TypedtreeCreated : EventHandler;
- public ParceTopDeclarations(source : ISource) : list[TopDeclaration]
+ public ParseTopDeclarations(source : ISource) : list[TopDeclaration]
{
if (IsProjectAvailable) // Get cached TopDeclaration-s.
this.Project.CompileUnits[source.FileIndex].TopDeclarations;
@@ -33,28 +33,47 @@
}
}
- /// Makes the typed tree and constructs compile unit collection.
+ /// Makes the typed tree (namespace tree) and constructs compile
+ /// unit collection.
private BuildNamespaceTreeAndInitProject() : void
{
try
{
- _currentMessages = SCG.List(32);
-
Trace.WriteLine(">>>> ##### Build types tree!");
- Instance = this;
- Init();
+
+ def init() : void
+ {
+ RestoreManagerClassInstance();
+
+ // we must clean the nodes from current program - note that this
+ // behaviour is automatically provided by Run, but completion
+ // engine does not use it at the moment.. :(
+ if (Options.PersistentLibraries)
+ when (Hierarchy != null)
+ Hierarchy.RemoveProgramTypes();
+ else
+ {
+ References.UpdateLibrariesManager();
+ LoadExternalLibraries ();
+ }
+
+ // next time Init is called, we won't reload libs
+ Options.PersistentLibraries = true;
+ #pragma warning disable 618 // Obsolete
+ _project = null; // in other locations you must use ResetTypeTree()!
+ #pragma warning restore 618 // Obsolete
_namespaces.Clear();
_decls = [];
_fileInfos.Clear();
-
- // lexing of the NotParsed files
- // we save the parsed files to improve performance
-
+ _currentMessages = SCG.List(32);
this.Hierarchy = TypesManager (this);
+ _isCanBeReset = true;
+ }
+
+ init();
mutable trees = [];
def regionsMap = Hashtable();
-
def projSources = ProjectSources;
foreach (fileIndex in Sources.GetFileIndices())
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Completion.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Completion.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Completion.n Thu Feb 15 03:13:15 2007
@@ -37,7 +37,7 @@
//// Find the declaration under text cursor.
//// Так как дерева типов нет, нужно построить Decl и TopDeclarations
//// для текущего файла.
- def topDecls = ParceTopDeclarations(source);
+ def topDecls = ParseTopDeclarations(source);
Trace.Assert(!IsProjectAvailable);
def decls = _decls.Rev();
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Init.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Init.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Init.n Thu Feb 15 03:13:15 2007
@@ -34,7 +34,6 @@
options.GreedyReferences = false;
base (options);
Output = output;
- _state = EngineState.Pure;
_isIntelliSenseMode = true;
syncObject = object();
_defines = DefineCollection (this);
@@ -55,37 +54,36 @@
_afterNamespaceParse = AfterNamespaceParse;
Instance = this;
- InitCompiler ();
+ _isCanBeReset = true;
+ Reset();
}
- public Init () : void
- {
- // if we are not in loaded libs _state, it will reload them
- Options.PersistentLibraries = _state == EngineState.LoadedLibs;
+ mutable _isCanBeReset : bool;
+ /// Reset Engine state (include: TypeTree, LibRefs and so on).
+ /// Call this method if you need reload libs and completely rebuild TypeTree.
+ Reset() : void
+ {
+ when (_isCanBeReset)
+ {
+ Options.PersistentLibraries = false; // reload libraries on next parse
+ ResetTypeTree();
// we must clean the nodes from current program - note that this
// behaviour is automatically provided by Run, but completion
// engine does not use it at the moment.. :(
when (Hierarchy != null)
{
- Hierarchy.RemoveProgramTypes();
- when (_state == EngineState.Pure)
+ Hierarchy.Dispose();
Hierarchy = null;
}
- //InitCompiler ();
- LoadExternalLibraries ();
-
- // next time Init is called, we won't rebuild external types
- _state = EngineState.LoadedLibs;
-#pragma warning disable 618 // Obsolete
- _project = null; // in other locations you must use ResetTypeTree()!
-#pragma warning restore 618 // Obsolete
+ InitCompiler();
+ _isCanBeReset = false; // it set tu true in BuildNamespaceTreeAndInitProject()
+ }
}
// Nemerle.Compiler.ManagerClass.Instance is a singletone. Actually, it's a bug.
// Quick'n'durty solution is 'save and revert when done'
- //
public RestoreManagerClassInstance() : void
{
Instance = this;
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Properties.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Properties.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Properties.n Thu Feb 15 03:13:15 2007
@@ -24,7 +24,6 @@
[Accessor] mutable _defines : DefineCollection;
[Accessor] mutable _references : ReferenceCollection;
[Accessor] _sources : SourceCollection;
- [Accessor] mutable _state : EngineState;
/// [Obsolete] for dont us it accidentally.
/// Don't use this field directly! Use Project propert.
[Obsolete] mutable _project : Project;
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.crud.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.crud.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.crud.n Thu Feb 15 03:13:15 2007
@@ -18,15 +18,13 @@
{
public partial class Engine
{
- public AddLibrary(path : string) : void
+ AddLibrary(path : string) : void
{
- _state = EngineState.Pure;
LibrariesManager.AddLibrary(path);
}
- public AddAssembly(assembly : SR.Assembly) : void
+ AddAssembly(assembly : SR.Assembly) : void
{
- _state = EngineState.Pure;
LibrariesManager.AddAssembly(assembly);
}
} // end class Engine
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/ReferenceCollection.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/ReferenceCollection.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/ReferenceCollection.n Thu Feb 15 03:13:15 2007
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
using Nemerle.Assertions;
using Nemerle.Collections;
using Nemerle.Compiler;
@@ -14,73 +15,84 @@
{
public class ReferenceCollection
{
- internal this (eng : Engine)
+ internal this(eng : Engine)
{
- references = Hashtable ();
+ references = Hashtable();
Engine = eng;
}
- internal mutable references : Hashtable[string, InternalReference];
+ mutable references : Hashtable[string, InternalReference];
public Engine : Engine
{
mutable _engine : Engine;
- get { ManagerClass.Instance = _engine; _engine; }
+ [DebuggerNonUserCode]
+ get
+ {
+ ManagerClass.Instance = _engine;
+ _engine;
+ }
private set { _engine = value }
}
- public Add (key : string, path : string) : void
+ Reset() : void
{
- unless (references.Contains (key))
- {
- references.Add (key, InternalReference.Library (path));
- Engine.AddLibrary(path);
- Engine.ResetTypeTree();
- }
+ Engine.Reset();
}
- public Add (key : string, loadedAssembly : System.Reflection.Assembly) : void
+ public Add(key : string, path : string) : void
{
- unless (references.Contains (key))
+ unless (references.Contains(key))
{
- references.Add (key, InternalReference.Assembly (loadedAssembly));
- Engine.AddAssembly (loadedAssembly);
- Engine.ResetTypeTree();
+ references.Add(key, InternalReference.Library(path));
+ Reset();
}
}
- public Remove (key : string) : void
+ public Add(key : string, loadedAssembly : System.Reflection.Assembly) : void
{
- when (references.Contains (key))
+ unless (references.Contains(key))
{
- references.Remove (key);
- Engine._state = EngineState.Pure;
- Engine.ResetTypeTree();
+ references.Add(key, InternalReference.Assembly(loadedAssembly));
+ Reset();
+ }
+ }
- foreach (reference in references.Values)
+ public Remove(key : string) : void
{
- | Library as l => Engine.AddLibrary(l.path);
- | Assembly as a => Engine.AddAssembly (a.assembly);
- }
+ when (references.Contains(key))
+ {
+ references.Remove(key);
+ Reset();
}
}
- public Clear () : void
+ public Clear() : void
{
- references = Hashtable ();
- Engine._state = EngineState.Pure;
- Engine.ResetTypeTree();
+ references = Hashtable();
+ Reset();
}
- public ContainsKey (key : string) : bool
+ public ContainsKey(key : string) : bool
{
- references.ContainsKey (key)
+ references.ContainsKey(key)
}
- public GetKeys () : System.Collections.Generic.IEnumerable[string]
+ public GetKeys() : System.Collections.Generic.IEnumerable[string]
{
references.Keys
}
+
+ internal UpdateLibrariesManager() : void
+ {
+ def engine = this.Engine;
+
+ foreach (reference in references.Values)
+ {
+ | Library as lib => engine.AddLibrary(lib.path);
+ | Assembly as asm => engine.AddAssembly(asm.assembly);
+ }
+ }
}
}
} // end namespace
Modified: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleScanner.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleScanner.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleScanner.cs Thu Feb 15 03:13:15 2007
@@ -41,16 +41,11 @@
Engine engine;
if (projectInfo == null)
- {
// TODO: We need to create hidden project for files which are not included
// in any project.
engine = new Engine(new ProjectManager(_languageService), new TraceWriter());
- engine.Init();
- }
else
- {
engine = projectInfo.Engine;
- }
_lexer = new ScanLexer(engine);
}
Modified: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleTypeAndMemberDropdownBars .cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleTypeAndMemberDropdownBars .cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleTypeAndMemberDropdownBars .cs Thu Feb 15 03:13:15 2007
@@ -54,7 +54,7 @@
List<NemerleDropDownMember> list = new List<NemerleDropDownMember>();
IEnumerable decls = AstUtils.GetAllDeclarations(
- _source.ProjectInfo.Engine.ParceTopDeclarations(
+ _source.ProjectInfo.Engine.ParseTopDeclarations(
new SourceTextManager(_source)));
foreach (Tuple<string,TopDeclaration> decl in decls)
Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNode.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNode.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNode.cs Thu Feb 15 03:13:15 2007
@@ -291,8 +291,6 @@
if (libraryManager != null)
libraryManager.RegisterHierarchy(InteropSafeHierarchy);
-
- _projectInfo.Init();
}
/// <summary>
Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/ProjectInfo.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/ProjectInfo.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/ProjectInfo.cs Thu Feb 15 03:13:15 2007
@@ -75,11 +75,6 @@
int _buildTypedtreeCount;
- public void Init()
- {
- Engine.Init();
- }
-
private Engine _engine;
public Engine Engine
{
More information about the svn
mailing list