[svn] r6921: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel: ScanLexer.n ScanState.n...

IT svnadmin at nemerle.org
Fri Nov 17 04:15:38 CET 2006


Log:
Keyword coloring for quotation type prefix.

Author: IT
Date: Fri Nov 17 04:15:35 2006
New Revision: 6921

Modified:
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanLexer.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanState.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanTokenInfo.n

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanLexer.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanLexer.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanLexer.n	Fri Nov 17 04:15:35 2006
@@ -50,6 +50,7 @@
     _tokenInfo : ScanTokenInfo = ScanTokenInfo();
 
     static _types : Dictionary[string,string] = Dictionary();
+    static _quotationTypes : Dictionary[string,string] = Dictionary();
 
     static this()
     {
@@ -59,6 +60,11 @@
       {
         _types.Add(name, name);
       }
+
+      foreach (name in ["ttype",  "fundecl", "case",  "parameter", "decl"])
+      {
+        _quotationTypes.Add(name, name);
+      }
     }
 
     skip() : void
@@ -395,7 +401,19 @@
         {
         | Identifier(nm) when _types.ContainsKey(nm)
         | Keyword                   => (TP.Keyword,    C.Keyword,    TR.None)
-        | Identifier
+        | Identifier(name)          =>
+
+          if (_tokenInfo.IsQuotationStart && _quotationTypes.ContainsKey(name.ToLower()) && 
+            {
+              def s = reader.Substring(pos).TrimStart(' ', '\t');
+              s.Length > 0 && s[0] == ':'
+            })
+          {
+            (TP.Keyword,    C.Keyword,    TR.None)
+          }
+          else
+            (TP.Identifier, C.Identifier, TR.None)
+
         | IdentifierToComplete      => (TP.Identifier, C.Identifier, TR.None)
         | Comma                     => (TP.Operator,   C.Operator,   TR.ParameterNext)
         | Semicolon                 => (TP.Operator,   C.Operator,   TR.None)
@@ -444,10 +462,14 @@
             _quotationCount           = 1;
           }
 
+          _tokenInfo.State |= ScanState.QuotationStart;
+
           (TP.Operator, C.Quotation, TR.None)
 
         | EndQuote       /* ]> */   =>
 
+          _tokenInfo.State &= ~ScanState.QuotationStart;
+
           when (_tokenInfo.IsQuotation)
           {
             when (_quotationCount < 0)
@@ -486,6 +508,8 @@
       _last_col   = col;
       _keepDollar = true;
 
+      def resetQuotationStart = _tokenInfo.IsQuotationStart;
+
       (_tokenInfo.Token, _tokenInfo.Type, _tokenInfo.Color, _tokenInfo.Triggers)
         =
       if (eol())
@@ -624,6 +648,9 @@
         _bracketCount           = 0;
       }
 
+      when (resetQuotationStart && !_tokenInfo.IsWhiteSpaceOrCommentType)
+        _tokenInfo.State &= ~ScanState.QuotationStart;
+
       when (_tokenInfo.IsQuotation && !(_tokenInfo.Token is Token.BeginQuote))
       {
         _tokenInfo.Color = match (_tokenInfo.Color)

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanState.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanState.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanState.n	Fri Nov 17 04:15:35 2006
@@ -8,9 +8,10 @@
     | None             = 0x00000000
     | Comment          = 0x00000001
     | Quotation        = 0x00000002
-    | Dollar           = 0x00000004
-    | String           = 0x00000010
-    | MultiLineString  = 0x00000020
+    | QuotationStart   = 0x00000004
+    | Dollar           = 0x00000010
+    | String           = 0x00000020
+    | MultiLineString  = 0x00000040
     | BracketCounter   = 0x0F000000
     | QuotationCounter = 0xF0000000
   }

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanTokenInfo.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanTokenInfo.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanTokenInfo.n	Fri Nov 17 04:15:35 2006
@@ -40,9 +40,16 @@
     }
 
     public IsQuotation       : bool { get { State %&& ScanState.Quotation       } }
+    public IsQuotationStart  : bool { get { State %&& ScanState.QuotationStart  } }
     public IsComment         : bool { get { State %&& ScanState.Comment         } }
     public IsString          : bool { get { State %&& ScanState.String          } }
     public IsMultiLineString : bool { get { State %&& ScanState.MultiLineString } }
     public IsDollar          : bool { get { State %&& ScanState.Dollar          } }
+
+    public IsWhiteSpaceType : bool { get { Type == ScanTokenType.WhiteSpace } }
+    public IsCommentType    : bool { get { Type == ScanTokenType.Comment || Type == ScanTokenType.LineComment } }
+
+    public IsWhiteSpaceOrCommentType : bool { get { IsWhiteSpaceType || IsCommentType } }
+
   }
 }



More information about the svn mailing list