[svn] r6367: nemerle/trunk/ncc: completion/CodeCompletionEngine.n typing/OverloadPossibility.n

trupill svnadmin at nemerle.org
Sun Jun 4 14:09:16 CEST 2006


Log:
Change of the Completion Engine to use Nemerle compiler structures 
instead of wrapping


Author: trupill
Date: Sun Jun  4 14:09:14 2006
New Revision: 6367

Modified:
   nemerle/trunk/ncc/completion/CodeCompletionEngine.n
   nemerle/trunk/ncc/typing/OverloadPossibility.n

Modified: nemerle/trunk/ncc/completion/CodeCompletionEngine.n
==============================================================================
--- nemerle/trunk/ncc/completion/CodeCompletionEngine.n	(original)
+++ nemerle/trunk/ncc/completion/CodeCompletionEngine.n	Sun Jun  4 14:09:14 2006
@@ -46,6 +46,8 @@
 
 namespace Nemerle.Completion
 {
+    public delegate CompletionStageHandler (node : TypeInfo) : void;
+    
     public enum EngineState {
       | Pure
       | LoadedLibs
@@ -273,8 +275,6 @@
             Defines = DefineCollection (this);
             References = ReferenceCollection (this);
             Sources = SourceCollection ();
-            // this.ParsingPipeline = MainParser.Parse;
-            // this.ScanningPipeline = ScanTypeHierarchy (this).ProcessDeclaration;
             MessageOccured += process_error_message;
             Options.GreedyReferences = true;
             Options.ColorMessages = false;
@@ -283,18 +283,18 @@
         
         public Init () : void
         {
-          Options.PersistentLibraries = state == EngineState.LoadedLibs; // if we are not in loaded libs state, it will reload them
+          Options.PersistentLibraries = (state == EngineState.LoadedLibs); // if we are not in loaded libs state, it will reload them
           
           // 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 (Options.PersistentLibraries && Hierarchy != null)
+          when (Hierarchy != null)
             Hierarchy.RemoveProgramTypes();
          
           InitCompiler ();
           LoadExternalLibraries ();
           
           state = EngineState.LoadedLibs; // next time Init is called, we won't rebuild external types
-          Sources.set_unparsed_state ();
+          // Sources.set_unparsed_state ();
           listMessages = [];
         }
         
@@ -387,12 +387,40 @@
             }
         }
        
+        // This method should be used when iterating all along the type tree
+        // because looping inside the tree from other thread throws an 'out of sync' exception
+        public GetTypeTree (handler : CompletionStageHandler) : void
+        {
+            def tree = GetTypeTree ();
+            
+            def loop (x : NamespaceTree.Node)
+            {
+                foreach ( pair in x.children )
+                {
+                    def node = pair.Value;
+                    match (node.Value) {
+                    | NamespaceReference => loop (node);
+                    | Cached as c =>
+                         match (c.tycon) {
+                         | tb is TypeBuilder =>
+                            handler (tb);
+                         | _ => ();
+                         }
+                     | _ => ()
+                     }
+                 }
+            }
+            
+            loop (tree);
+        }
+       
         public GetTypeTree () : NamespaceTree.Node
         {
             Instance = this;
             Init ();
         
-            System.Console.WriteLine ("just before lexing");
+            // lexing of the NotParsed files
+            // we save the parsed files to improve performance
             mutable trees = [];
             try
             {
@@ -421,11 +449,9 @@
                   {}
             }
              
-            System.Console.WriteLine ("just before TypesManager");
             this.Hierarchy = TypesManager (this);
     
             // create N.C.TypeBuilders for all parsed types and add them to namespace hierarchy
-            System.Console.WriteLine ("just before parsing");
             try
             {
                 foreach (group in trees) {
@@ -441,7 +467,6 @@
                   {}
             }
             
-            System.Console.WriteLine ("just before building the hierarchy");
             try
             {
                 this.Hierarchy.Run();
@@ -474,7 +499,7 @@
                 name
                 
             | TyVarRef as r => r.tyvar.Name
-            | Fun as f => def name = GetNameFromType (f.from :> MType) + " -> " + GetNameFromType (f.to :> MType); name
+            | Fun as f => GetNameFromType (f.from :> MType) + " -> " + GetNameFromType (f.to :> MType)
             | Tuple as tuple => mutable name = "(";
                 foreach (tx in tuple.args)
                 {
@@ -483,8 +508,10 @@
                 }
                 name = name.Trim(',', ' ') + ")";
                 name
-            | Array as a => def name = "array[" + GetNameFromType (a.t :> MType) + "]"; name
+            | Array as a => "array[" + GetNameFromType (a.t :> MType) + "]"
             | Void => "void"
+            | Ref as rf => "ref " + GetNameFromType (rf.t :> MType)
+            | Out as ut => "out " + GetNameFromType (ut.t :> MType)
             | _ => ""
          }
                 

Modified: nemerle/trunk/ncc/typing/OverloadPossibility.n
==============================================================================
--- nemerle/trunk/ncc/typing/OverloadPossibility.n	(original)
+++ nemerle/trunk/ncc/typing/OverloadPossibility.n	Sun Jun  4 14:09:14 2006
@@ -164,6 +164,11 @@
       get { member }
     }
 
+    public From : MType.Class
+    {
+      get { from }
+    }
+
     public override ToString () : string
     {
       member.ToString () +
@@ -218,7 +223,7 @@
     member : IMember;
     solver : Solver;
     is_static : bool;
-    internal from : MType.Class;
+    from : MType.Class;
     method_typarms : list [TyVar];
     local_context : LocalContext;
     mutable generic_specifier : list [TyVar];



More information about the svn mailing list