[svn] r6708: vs-plugin/trunk: Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n Nemerle.Compi...

IT svnadmin at nemerle.org
Mon Sep 25 06:48:26 CEST 2006


Log:
Working on regions.

Author: IT
Date: Mon Sep 25 06:48:21 2006
New Revision: 6708

Modified:
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.crud.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Utils.n
   vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleLanguageService.cs

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	Mon Sep 25 06:48:21 2006
@@ -14,7 +14,7 @@
 namespace Nemerle.Completion2
 {
   public delegate GetText        (line : int, col : int, lineEnd : int, colEnd : int) : string;
-  public delegate AddHiddenRegion(location : Location) : void;
+  public delegate AddHiddenRegion(location : Location, isExpanded : bool) : void;
   public delegate AddError       (compilerMessage : CompilerMessage) : void;
 
   [Record]
@@ -29,7 +29,8 @@
       line : int,
       col : int,
       [NotNull] getText : GetText
-      ) : array[CompletionElem]
+    )
+      : array[CompletionElem]
     {
       def fileIndex = _compileUnits.GetFileIndex(filePath);
       // Find the declaration under text cursor.
@@ -144,10 +145,10 @@
     }
 
     public Check(
-      [NotNull] fileName        : string,
-      [NotNull] addHiddenRegion : AddHiddenRegion,
-      [NotNull] addError        : AddError,
-      [NotNull] getText         : GetText
+      /*[NotNull]*/ fileName        : string,
+      /*[NotNull]*/ addHiddenRegion : AddHiddenRegion,
+      /*[NotNull]*/ addError        : AddError,
+      /*[NotNull]*/ getText         : GetText
     )
       : void
     {
@@ -164,6 +165,8 @@
         {
         | method is MethodBuilder =>
 
+          // Get errors.
+          //
           def location = method.BodyLocation;
           def bodyCode = getText(location.Line, location.Column, location.EndLine, location.EndColumn);
 
@@ -172,12 +175,22 @@
           foreach (cm in _engine.CompilerMessages)
             addError(cm);
 
-          addHiddenRegion(location);
+          // Get region location.
+          //
+          def loc      = method.Location.TrimStart(method.fun_header.Location, false);
+          def bodyCode = getText(loc.Line, loc.Column, loc.EndLine, loc.EndColumn);
+
+          addHiddenRegion(
+            if (bodyCode.Length > 0 && bodyCode[0] == ' ')
+              Location(loc.FileIndex, loc.Line, loc.Column + 1, loc.EndLine, loc.EndColumn)
+            else
+              loc,
+            false);
 
         | _ => ()
         }
 
-        addHiddenRegion(tp.Location);
+        addHiddenRegion(tp.Location, true);
 
       | _ => ()
       }

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.crud.n
==============================================================================

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Utils.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Utils.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Utils.n	Mon Sep 25 06:48:21 2006
@@ -340,15 +340,22 @@
 
     public TrimStart(this l1 : Location, l2 : Location) : Location
     {
+      TrimStart(l1, l2, true)
+    }
+
+    public TrimStart(this l1 : Location, l2 : Location, adjustBegin : bool) : Location
+    {
       mutable lbeg;
       mutable cbeg;
 
-      if      (l1.Line < l2.EndLine) { lbeg = l2.EndLine; cbeg = l2.EndColumn + 1; }
+      def adj = if (adjustBegin) 1 else 0;
+
+      if      (l1.Line < l2.EndLine) { lbeg = l2.EndLine; cbeg = l2.EndColumn + adj; }
       else if (l1.Line > l2.EndLine) { lbeg = l1.Line;    cbeg = l1.Column; }
       else
       {
         lbeg = l1.Line;
-        cbeg = if (l1.Column < l2.EndColumn) l2.EndColumn + 1 else l1.Column;
+        cbeg = if (l1.Column < l2.EndColumn) l2.EndColumn + adj else l1.Column;
       }
 
       Location(l1.FileIndex, lbeg, cbeg, l1.EndLine, l1.EndColumn)
@@ -375,7 +382,7 @@
       if (line < l2.Line || line == l2.Line && col < l2.Column)
         l1.TrimEnd(l2)
       else if (line > l2.EndLine || line == l2.EndLine && col > l2.EndColumn)
-        l1.TrimStart(l2)
+        l1.TrimStart(l2, true)
       else
         l1
     }

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	Mon Sep 25 06:48:21 2006
@@ -205,19 +205,18 @@
 
 				projectInfo.Project.Check(
 					request.FileName,
-					delegate(Location location)
+					delegate(Location location, bool isExpanded)
 					{
 						NewHiddenRegion r = new NewHiddenRegion();
 
 						r.tsHiddenText = Convert(location);
 						r.iType        = (int)HIDDEN_REGION_TYPE.hrtCollapsible;
 						r.dwBehavior   = (int)HIDDEN_REGION_BEHAVIOR.hrbEditorControlled; //hrbClientControlled;
-						r.dwState      = (int)HIDDEN_REGION_STATE.hrsDefault;
+						r.dwState      = (uint)(isExpanded? HIDDEN_REGION_STATE.hrsExpanded: HIDDEN_REGION_STATE.hrsDefault);
 						r.pszBanner    = null;
 						r.dwClient     = 25;
 
 						request.Sink.AddHiddenRegion(r);
-
 						request.Sink.ProcessHiddenRegions = true;
 					},
 					delegate(CompilerMessage cm)



More information about the svn mailing list