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

VladD2 svnadmin at nemerle.org
Fri Jan 5 04:58:51 CET 2007


Log:


Author: VladD2
Date: Fri Jan  5 04:58:47 2007
New Revision: 7208

Modified:
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Checker.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Debug/   (props changed)
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.CompilerMessages.n
   vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/   (props changed)
   vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleLanguageService.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Nemerle.VisualStudio.csproj

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	Fri Jan  5 04:58:47 2007
@@ -1,6 +1,6 @@
 using System;
-using System.Collections.Generic;
 
+using Nemerle.Collections;
 using Nemerle.Compiler;
 using Nemerle.Compiler.Parsetree;
 using Nemerle.Compiler.Typedtree;
@@ -10,6 +10,8 @@
 using Nemerle.Imperative;
 using Nemerle.Utility;
 
+using SCG = System.Collections.Generic;
+
 namespace Nemerle.Completion2
 {
   class Checker
@@ -29,7 +31,7 @@
       _addError        = addError;
     }
 
-    _project         : Project;
+    mutable _project : Project;
     _fileName        : string;
     _source          : ISource;
     _addHiddenRegion : AddHiddenRegion;
@@ -383,7 +385,7 @@
           false);
       }
 
-      def usings = List();
+      def usings = SCG.List();
 
       foreach (decl in decls)
       {
@@ -471,7 +473,60 @@
       _afterUsingLine = int.MaxValue;
       _fileIndex      = _project.CompileUnits.GetFileIndex(_fileName);
 
-      foreach (cm in _project.GetAllCompilerMessageForFile(_fileIndex))
+      mutable errors = _project.GetAllCompilerMessageForFile(_fileIndex).ToArray();
+
+      def isBraceErrorMsg = errors.Exists(cm =>
+        cm.Message.Contains("when parsing this `{' brace group")
+        || cm.Message.Contains("unexpected end of file"));
+
+      def engine = _project.Engine;
+      def isBraceMatch()
+      {
+        def code = _source.GetText();
+        def lex = LexerString(engine, code, Location(_fileIndex, 1, 1));
+        //lex.BeginParseFile();
+        lex.Keywords = lex.Manager.CoreEnv.Keywords;
+        def stack = Stack();
+        stack.Push(Token.EndOfFile());
+        def scan(toc : Token)
+        {
+          | EndOfFile              => stack.Count == 1
+
+          | BeginBrace(_generated) // {
+          | BeginRound             // (
+          | BeginSquare            // [
+          | BeginQuote          => // <[
+            stack.Push(toc);
+            scan(lex.GetToken())
+
+          | EndBrace(_generated)   => check(_ is Token.BeginBrace)  // }
+          | EndRound               => check(_ is Token.BeginRound)  // )
+          | EndSquare              => check(_ is Token.BeginSquare) // ]
+          | EndQuote               => check(_ is Token.BeginQuote)  // ]>
+          | _                      => scan(lex.GetToken());
+        }
+        and check(predicate)
+        {
+            if (stack.Count > 0 && predicate(stack.Peek()))
+            {
+              stack.RemoveLast();
+              scan(lex.GetToken())
+            }
+            else
+              false
+        }
+
+        scan(lex.GetToken());
+      }
+
+      when (isBraceErrorMsg && isBraceMatch()) // Rebuild "type tree".
+      {
+        engine.ResetTypeTree();
+        _project = engine.Project;
+        errors = _project.GetAllCompilerMessageForFile(_fileIndex).ToArray();
+      }
+
+      foreach (cm in errors)
         when (!_addError(cm))
           break;
 

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.CompilerMessages.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.CompilerMessages.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.CompilerMessages.n	Fri Jan  5 04:58:47 2007
@@ -12,7 +12,7 @@
 
     public AddCompilerMessage(message : string, location : Location, kind : MessageKind, ) : void
     {
-      when (null == _currentMessages)
+      when (_currentMessages == null)
       {
         System.Diagnostics.Trace.WriteLine("_currentMessages is null???");
         _currentMessages = SCG.List();

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	Fri Jan  5 04:58:47 2007
@@ -157,7 +157,6 @@
 
 				AuthoringScope scope = GetDefaultScope(request);
 
-
 				AstToolWindow tool = AstToolWindow.AstTool;
 				if (tool != null && tool.IsAutoUpdate)
 					tool.ShowInfo(source);

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Nemerle.VisualStudio.csproj
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Nemerle.VisualStudio.csproj	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Nemerle.VisualStudio.csproj	Fri Jan  5 04:58:47 2007
@@ -192,6 +192,7 @@
     <CtcFile Include="CtcComponents\PkgCmd.ctc">
       <ResourceName>1000</ResourceName>
     </CtcFile>
+    <None Include="!ToDo\ToDo.txt" />
     <Content Include="CodeSnippets\Snippets\foreach.snippet">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>



More information about the svn mailing list