[svn] r6745: vs-plugin/trunk: Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n Nemerle.Co...

IT svnadmin at nemerle.org
Tue Oct 3 04:47:25 CEST 2006


Log:
Working on #region/#endregion regions.

Author: IT
Date: Tue Oct  3 04:47:19 2006
New Revision: 6745

Modified:
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprWalker.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/ParsedFile.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/SourceCollection.n
   vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleLanguageService.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleAssemblyReference.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleAssemblyReferenceNode.cs

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n	Tue Oct  3 04:47:19 2006
@@ -717,6 +717,6 @@
       ignore(loc);
     }
 
-    //#endregion
+    #endregion
   }
 }

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprWalker.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprWalker.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprWalker.n	Tue Oct  3 04:47:19 2006
@@ -14,24 +14,33 @@
     mutable _walkHandler : PExprWalkHandler;
     mutable _stop        : bool;
 
-    private Go(lst : list[PExpr])         : void { foreach (item in lst) Go(item); }
-    private Go(lst : list[ClassMember])   : void { foreach (item in lst) Go(item); }
-    private Go(lst : list[Splicable])     : void { foreach (item in lst) Go(item); }
-    private Go(lst : list[SyntaxElement]) : void { foreach (item in lst) Go(item); }
-    private Go(lst : list[Function_decl]) : void { foreach (item in lst) Go(item); }
-    private Go(lst : list[MatchCase])     : void { foreach (item in lst) Go(item); }
-    private Go(lst : list[TryCase])       : void { foreach (item in lst) Go(item); }
-    private Go(lst : list[Fun_parm])      : void { foreach (item in lst) Go(item); }
+    private Go(lst : list[PExpr])         : void { when (lst != null) foreach (item in lst) Go(item); }
+    private Go(lst : list[ClassMember])   : void { when (lst != null) foreach (item in lst) Go(item); }
+    private Go(lst : list[Splicable])     : void { when (lst != null) foreach (item in lst) Go(item); }
+    private Go(lst : list[SyntaxElement]) : void { when (lst != null) foreach (item in lst) Go(item); }
+    private Go(lst : list[Function_decl]) : void { when (lst != null) foreach (item in lst) Go(item); }
+    private Go(lst : list[MatchCase])     : void { when (lst != null) foreach (item in lst) Go(item); }
+    private Go(lst : list[TryCase])       : void { when (lst != null) foreach (item in lst) Go(item); }
+    private Go(lst : list[Fun_parm])      : void { when (lst != null) foreach (item in lst) Go(item); }
 
     private Go(splicable : Splicable) : void
     {
+      when (_stop || splicable == null)
+        return;
+
+      match (splicable)
+      {
     | Expression(e) => Go(e); // { expr : PExpr; }
     | Name                    // { body : Parsetree.Name; }
     | HalfId        => ();    // { prefix : Parsetree.Name; }
     }
+    }
 
     private Go(parms : Typarms) : void
     {
+      when (_stop || parms == null)
+        return;
+
       Go(parms.tyvars);
 
       foreach (c in parms.constraints)
@@ -43,47 +52,74 @@
 
     private Go(header : Fun_header) : void
     {
+      when (_stop || header == null)
+        return;
+
       Go(header.typarms);
       Go(header.name);
       Go(header.ret_type);
       Go(header.parms);
     }
 
-    private Go(fun_decl : Function_decl) : void
+    private Go(decl : Function_decl) : void
     {
-      Go(fun_decl.header);
-      Go(fun_decl.body);
+      when (_stop || decl == null)
+        return;
+
+      Go(decl.header);
+      Go(decl.body);
     }
 
     private Go(parm : Fun_parm) : void
     {
+      when (_stop || parm == null)
+        return;
+
       Go(parm.ty);
       Go(parm.name);
     }
 
     private Go(body : FunBody) : void
     {
+      when (_stop || body == null)
+        return;
+
+      match (body)
+      {
     | Parsed(e) => Go(e); // { expr : Parsetree.PExpr; }
     | Typed               // { expr : Typedtree.TExpr; }
     | ILed
     | Abstract  => ();
     }
+    }
 
     private Go(tryCase : TryCase) : void
     {
+      when (_stop || tryCase == null)
+        return;
+
+      match (tryCase)
+      {
     | Catch(sp, e1, e2)      => Go(sp); Go(e1); Go(e2);         // { exn : Splicable; exn_ty : PExpr; handler : PExpr; }
     | Filter(sp, e1, e2, e3) => Go(sp); Go(e1); Go(e2); Go(e3); // { exn : Splicable; exn_ty : PExpr; filter : PExpr; handler : PExpr; }
     | Ellipsis(e)            => Go(e);                          // { body : PExpr; }
     }
+    }
 
     private Go(matchCase : MatchCase) : void
     {
+      when (_stop || matchCase == null)
+        return;
+
       Go(matchCase.patterns);
       Go(matchCase.body);
     }
 
     private Go(decl : TopDeclaration) : void
     {
+      when (_stop || decl == null)
+        return;
+
       match (decl)
       {
       | Class    (lst, m)                              // { mutable t_extends : list [PExpr]; decls : list [ClassMember]; }
@@ -101,6 +137,9 @@
 
     private Go(member : ClassMember) : void
     {
+      when (_stop || member == null)
+        return;
+
       match (member)
       {
       | TypeDeclaration(td)    => Go(td);          // { td : TopDeclaration; }
@@ -129,6 +168,11 @@
 
     private Go(element : SyntaxElement) : void
     {
+      when (_stop || element == null)
+        return;
+
+      match (element)
+      {
     | Expression      (e)                 // { body : PExpr; }
     | TType           (e)    => Go(e);    // { body : PExpr; }
     | MatchCase       (mc)   => Go(mc);   // { body : Parsetree.MatchCase; }
@@ -143,6 +187,7 @@
     | PropertyBuilder                     // { body : Compiler.PropertyBuilder; }
     | EventBuilder           => ();       // { body : Compiler.EventBuilder; }
     }
+    }
 
     private Go(expression : PExpr) : void
     {

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n	Tue Oct  3 04:47:19 2006
@@ -15,7 +15,7 @@
 
 namespace Nemerle.Completion2
 {
-  public delegate AddHiddenRegion(location : Location, isExpanded : bool) : void;
+  public delegate AddHiddenRegion(location : Location, text : string, isExpanded : bool) : void;
   public delegate AddError       (compilerMessage : CompilerMessage) : void;
 
   [Record]
@@ -198,6 +198,7 @@
                 Location(fileIndex, loc.Line, loc.Column + 1, loc.EndLine, loc.EndColumn)
               else
                 loc,
+              null,
               true);
 
             checkLine(loc.Line);
@@ -217,7 +218,7 @@
           //
           colStart = source.GetLine(lineStart).Length + 1;
 
-          addHiddenRegion(Location(fileIndex, lineStart, colStart, lineEnd, colEnd), true);
+          addHiddenRegion(Location(fileIndex, lineStart, colStart, lineEnd, colEnd), null, true);
           checkLine(lineStart);
 
           // Get regions and errors for methods.
@@ -305,7 +306,7 @@
             when (isNext(lineStart, colStart, ' ')) colStart++;
             when (isNext(lineEnd,   colEnd,   '}')) colEnd++;
 
-            addHiddenRegion(Location(fileIndex, lineStart, colStart, lineEnd, colEnd), true);
+            addHiddenRegion(Location(fileIndex, lineStart, colStart, lineEnd, colEnd), null, true);
             checkLine(lineStart);
 
           | None => ()
@@ -359,9 +360,19 @@
               }
             }
 
-            addHiddenRegion(Location(fileIndex, lineStart, colStart, lineEnd, colEnd), true);
+            addHiddenRegion(Location(fileIndex, lineStart, colStart, lineEnd, colEnd), null, true);
           }
         }
+
+        match (_engine.Sources._sources[fileName])
+        {
+        | ParsedFile.Parsed(_, _, regions) =>
+
+          foreach (r in regions)
+            addHiddenRegion(r.Location, r.Text, true);
+
+        | _ => ()
+        }
       }
 
       processDecls(_compileUnits[fileIndex].Decls);

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	Tue Oct  3 04:47:19 2006
@@ -40,7 +40,7 @@
       {
           match (fileInfo)
           {
-          | Parsed(_, code)
+          | Parsed(_, code, _)
           | NotParsed(code) =>
               _fileIndex = Location.GetFileIndex(filePath);
               BeginParseFile(_fileIndex);
@@ -48,7 +48,7 @@
               {
                 def lexer = LexerString (this, code, Location(_fileIndex, 1, 1));
                 def decls = ParsingPipeline (lexer);
-                Sources._sources[filePath] = ParsedFile.Parsed (decls, code);
+                Sources._sources[filePath] = ParsedFile.Parsed(decls, code, lexer.Regions);
                 trees ::= decls;
               }
               finally { EndParseFile(_fileIndex); }

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/ParsedFile.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/ParsedFile.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/ParsedFile.n	Tue Oct  3 04:47:19 2006
@@ -13,7 +13,7 @@
   internal variant ParsedFile
   {
   | NotParsed { code : string }
-  | Parsed { decls : list [TopDeclaration]; code : string; }
+  | Parsed { decls : list [TopDeclaration]; code : string; regions : list[Region]; }
   }
 } // end namespace
 

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/SourceCollection.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/SourceCollection.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/SourceCollection.n	Tue Oct  3 04:47:19 2006
@@ -44,7 +44,7 @@
 
       internal set_unparsed_state () : void
       {
-        foreach ((fileName, Parsed(_, code)) in _sources.KeyValuePairs)
+        foreach ((fileName, Parsed(_, code, _)) in _sources.KeyValuePairs)
           _sources[fileName] = ParsedFile.NotParsed(code);
       }
 

Modified: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleLanguageService.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleLanguageService.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleLanguageService.cs	Tue Oct  3 04:47:19 2006
@@ -208,7 +208,7 @@
 				projectInfo.Project.Check(
 					request.FileName,
 					new SourceTextManager(this, request.View),
-					delegate(Location location, bool isExpanded)
+					delegate(Location location, string text, bool isExpanded)
 					{
 						NewHiddenRegion r = new NewHiddenRegion();
 
@@ -216,7 +216,7 @@
 						r.iType        = (int)HIDDEN_REGION_TYPE.hrtCollapsible;
 						r.dwBehavior   = (int)HIDDEN_REGION_BEHAVIOR.hrbEditorControlled; //.hrbClientControlled;
 						r.dwState      = (uint)(isExpanded? HIDDEN_REGION_STATE.hrsExpanded: HIDDEN_REGION_STATE.hrsDefault);
-						r.pszBanner    = null;
+						r.pszBanner    = string.IsNullOrEmpty(text)? null: text;
 						r.dwClient     = 25;
 
 						request.Sink.AddHiddenRegion(r);

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleAssemblyReference.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleAssemblyReference.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleAssemblyReference.cs	Tue Oct  3 04:47:19 2006
@@ -1,10 +1,10 @@
 using System;
 using System.Collections.Generic;
+using System.Runtime.InteropServices;
 using System.Text;
 
 using Microsoft.VisualStudio.Package.Automation;
 using Microsoft.VisualStudio.Package;
-using System.Runtime.InteropServices;
 
 namespace Nemerle.VisualStudio.Project
 {
@@ -16,13 +16,17 @@
 			: base(assemblyReference) 
 		{
 			byte[] token = assemblyReference.AssemblyName.GetPublicKeyToken();
+
 			if (token == null)
 				token = assemblyReference.ResolvedAssembly.GetPublicKeyToken();
+
 			if (token != null)
 			{
 				StringBuilder builder = new StringBuilder();
+
 				foreach (byte number in token)
 					builder.AppendFormat("{0:x2}", number);
+
 				_publicKeyToken = builder.ToString();
 			}
 		}

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleAssemblyReferenceNode.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleAssemblyReferenceNode.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleAssemblyReferenceNode.cs	Tue Oct  3 04:47:19 2006
@@ -1,8 +1,9 @@
 using System;
 using System.Collections.Generic;
+using System.Runtime.InteropServices;
 using System.Text;
+
 using Microsoft.VisualStudio.Package;
-using System.Runtime.InteropServices;
 
 namespace Nemerle.VisualStudio.Project
 {
@@ -25,7 +26,6 @@
 			{
 				if (_assemblyRef == null)
 					_assemblyRef = new NemerleAssemblyReference(this);
-
 				return _assemblyRef;
 			}
 		}



More information about the svn mailing list