[svn] r7563: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel: Checker.n Formatter.n

kliss svnadmin at nemerle.org
Sat Mar 31 23:03:05 CEST 2007


Log:
Change outlining for a type so that type name stays visible after collapsing regions.

Author: kliss
Date: Sat Mar 31 23:03:02 2007
New Revision: 7563

Modified:
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Checker.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Formatter.n

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Checker.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Checker.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Checker.n	Sat Mar 31 23:03:02 2007
@@ -1,4 +1,5 @@
 using System;
+using System.Diagnostics;
 
 using Nemerle.Collections;
 using Nemerle.Compiler;
@@ -333,20 +334,30 @@
       when (builder.IsDelegate || builder.IsVariantOption)
         return;
 
-      foreach (loc when loc.FileIndex == _fileIndex in builder.PartsLocation)
+      foreach (part when part.Location.FileIndex == _fileIndex in builder.AstParts)
       {
         _addHiddenRegion(
           Location(
             _fileIndex,
-            loc.Line,
-            //VladD2: Имя типа можно вынуть из TypeBuilder.AstParts.name.
-            GetLine(loc.Line).Length + 1, // should be temporary solution until we get location for the type name.
-            loc.EndLine,
-            loc.EndColumn),
+            // kliss: Make sure that type name is visible after collapsing its region (also
+            // leaving all attributes visible).
+            // TODO: Collapse all attributes to their own region.
+            // But there's occasional strange thing:
+            // Sometimes an additional hidden region is created that contains everything
+            // below last attribute (type's access modifiers, name and body).
+            // Or, maybe, it's my region that is created, and that one still persists
+            // from the previous times.
+            // Can anyone tell me what is going on?
+            // This doesn't reproduce on tiny projects (no persisted regions?), 
+            // but does on real ones, like this.
+            part.name.Location.EndLine,
+            part.name.Location.EndColumn,
+            part.Location.EndLine,
+            part.Location.EndColumn),
           null,
           true);
 
-        CheckLine(loc.Line);
+        CheckLine(part.Location.Line);
       }
 
       // Get regions and errors for methods.

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Formatter.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Formatter.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Formatter.n	Sat Mar 31 23:03:02 2007
@@ -12,23 +12,39 @@
 
 namespace Nemerle.Completion2
 {
+  [Obsolete]
   [Record]
   public class FormatterResult
   {
-    [Accessor] _startCol : int = -1;
     [Accessor] _startLine : int = -1;
-    [Accessor] _endCol : int  = -1;
+    [Accessor] _startCol : int = -1;
     [Accessor] _endLine : int = -1;
+    [Accessor] _endCol : int  = -1;
     [Accessor] _replacementString : string = "";
     
     public this(loc : Location, replacement : string)
     {
-      _startCol = loc.Column;
-      _startLine = loc.Line;
-      _endCol = loc.EndColumn;
-      _endLine = loc.EndLine;
-      _replacementString = replacement;
+      this(loc.Line, loc.Column, loc.EndLine, loc.EndColumn, replacement);
     }
+    
+    public this(line : int, column : int, replacement : string)
+    {
+      this(line, column, line, column, replacement);
+    }     
+    
+    //public this(startLine : int,
+    //            startColumn : int, 
+    //            endLine : int,
+    //            endColumn : int,
+    //            replacement : string)
+    //{
+    //  _startLine = startLine;
+    //  _startCol = startColumn;
+    //  _endLine = endLine;
+    //  _endCol = endColumn;
+    //  _replacementString = replacement;
+    //}
+
   }
   
   public class Formatter
@@ -163,35 +179,17 @@
       def results = SCG.List.[FormatterResult]();
       def declNS = this.Engine.Project.CompileUnits[filePath];
       
-      //def frm = AstBrowserForm(this.Engine.NameTree.NamespaceTree);
-      //_ = frm.ShowDialog();
-     
-      //mutable usings : list[Decl.Using] = [];
+      ////def lexer = LexerFile(Engine, "c:\\temp\\Main.n");
+      //def lexer = LexerFile(Engine, filePath);
+      ////def pexpr = MainParser.Parse(lexer);
+      //def preparser = PreParser(lexer);
+      //def tokens = preparser.PreParse();
+      //def finder = TokenFinder();
+      //def found = finder.Find(tokens, 27, 16);
+      //def t = found.GetType();
+      ////def t2 = pexpr.GetType();
      
-      //mutable usingsLocation = Location.Default;
       
-      //def processUsing(ns : Decl.Using)
-      //{
-      //  usings ::= ns;
-      //  usingsLocation += ns.Location;
-      //}
-      
-      //def processDecls(decls : list[Decl])
-      //{
-      //  match(decls)
-      //  {
-      //  | x :: xs => 
-      //      match(x)
-      //      {
-      //      | Decl.Using as u => processUsing(u);
-      //      | Decl.Type as t => Debug.WriteLine($"Found type: $t");
-      //      | _ => ();
-      //      }
-      //      processDecls(xs);
-      //  | _ => ();
-      //  }
-      //}
-      //
       //def writeFormattedUsings()
       //{
       //  def replacement = System.Text.StringBuilder();
@@ -240,14 +238,6 @@
       //  results.Add(fr);
       //}
       
-      //processDecls(declNS.Decls);
-      //writeFormattedUsings();
-      //
-      
-      //def (loc1, d1) = ExprFinder().Find(declNS, 4, 8);
-      //def (loc2, d2) = ExprFinder().Find(declNS, 17, 16);
-      //def (loc3, d3) = ExprFinder().Find(declNS, 11, 7);
-      
       ExprWalker().Walk(declNS, WalkHandler);
       //results.AddRange(FormatNamespace(declNS));
       results;



More information about the svn mailing list