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

kliss svnadmin at nemerle.org
Mon Apr 30 17:58:06 CEST 2007


Log:
Fix bug in special comments (IndexOutOfRangeException)

Author: kliss
Date: Mon Apr 30 17:58:00 2007
New Revision: 7639

Modified:
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanLexer.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	Mon Apr 30 17:58:00 2007
@@ -889,7 +889,10 @@
       | Comment(value) =>
 
         //TODO: Implement special comment in the middle of regular one, ie // regular >special one< regular again
-        def commentWOBeginning = value.Substring(2);
+        def commentOffset =  if(value.StartsWith("/*") || value.StartsWith("//")) 2;
+                             else 0;
+        def commentWOBeginning =  if(commentOffset > 0) value.Substring(commentOffset) else value;
+        
         def (idx, len, color)  = chooseColor(commentWOBeginning, specialCommentRegexes);
 
         when(idx != -1)
@@ -899,9 +902,9 @@
 
           def l = tokenInfo.Token.Location;
           // shrinking regular comment location
-          tokenInfo.Token.Location = Location(l, l.Line, l.Column, l.EndLine, l.Column + 1 + idx);
+          tokenInfo.Token.Location = Location(l, l.Line, l.Column, l.EndLine, l.Column + idx);
           _pendingToken.Color = color;
-          _pendingToken.Token.Location = Location(l, l.Line, l.Column + 2 + idx, l.EndLine, l.EndColumn);
+          _pendingToken.Token.Location = Location(l, l.Line, l.Column + commentOffset + idx, l.EndLine, l.EndColumn);
         }
 
       | _ => () 



More information about the svn mailing list