[svn] r6868: vs-plugin/trunk:
Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n
Nemerle.Co...
IT
svnadmin at nemerle.org
Sat Nov 11 21:32:58 CET 2006
Log:
Fixed some bugs of error processing.
Author: IT
Date: Sat Nov 11 21:32:52 2006
New Revision: 6868
Modified:
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.CompilerMessages.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Utils.n
vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringSink.cs
vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleLanguageService.cs
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n Sat Nov 11 21:32:52 2006
@@ -237,6 +237,8 @@
public Find(pRoot : PExpr, tRoot : TExpr, line : int, col : int) : Location * object * object
{
+ if (pRoot != null && tRoot != null)
+ {
Init(line, col);
ExprWalker().Walk(pRoot, PFinder);
@@ -265,9 +267,10 @@
)
}
else
- {
(Location.Default, null, null)
}
+ else
+ (Location.Default, null, null)
}
Init(line : int, col : int) : void
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n Sat Nov 11 21:32:52 2006
@@ -131,9 +131,7 @@
if (method.BodyLocation.Contains(line, col))
{
- def (pBody, tBody, _) = method.GetMethodBody();
-
- ExprFinder().Find(pBody, tBody, line, col);
+ ExprFinder().Find(method.GetParsedBody(), method.GetTypedBody(), line, col);
}
else if (method.fun_header.Location.Contains(line, col))
{
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 Sat Nov 11 21:32:52 2006
@@ -16,7 +16,7 @@
namespace Nemerle.Completion2
{
public delegate AddHiddenRegion(location : Location, text : string, isExpanded : bool) : void;
- public delegate AddError (compilerMessage : CompilerMessage) : void;
+ public delegate AddError (compilerMessage : CompilerMessage) : bool;
[Record]
public partial class Project
@@ -149,9 +149,14 @@
foreach (cm when cm.Location.FileIndex == fileIndex in Errors)
yield cm;
- foreach (method in GetAllMetodsDefinedInFile(fileIndex))
+ foreach (method when method.Env != null in GetAllMetodsDefinedInFile(fileIndex))
+ {
+ try
{
method.EnsureCompiled();
+ }
+ catch { _ => () }
+
foreach (cm in method.BodyMessages)
yield cm;
}
@@ -189,6 +194,11 @@
seq
}
+ _debug(obj : object) : void
+ {
+ _ = obj.ToString();
+ }
+
public Check(
/*[NotNull]*/ fileName : string,
/*[NotNull]*/ source : ISource,
@@ -200,7 +210,8 @@
def fileIndex = _compileUnits.GetFileIndex(fileName);
foreach (cm in GetAllCompilerMessageForFile(fileIndex))
- addError(cm);
+ when (!addError(cm))
+ break;
def isNext(line, col, ch)
{
@@ -254,29 +265,32 @@
//
def _start = Environment.TickCount;
- def isProessed(m)
+ def isProcessed(m)
{
!(m.Attributes %&& NemerleAttributes.SpecialName)
&& m.Location.FileIndex == fileIndex
}
- def members = builder.GetDirectMembers().Filter(isProessed);
+ def members = builder.GetDirectMembers().Filter(isProcessed);
foreach (member in members)
{
- // TypeBuilder can contains methods from many parts of partial
+ // TypeBuilder can contain methods from many parts of partial
// class and super classes. We must process only memebers defined
// in processed file only!
//
| method is MethodBuilder =>
#if !DEBUG
- when (_start > Environment.TickCount - 2000)
- {
+ when (_start < Environment.TickCount - 2000)
+ break;
#endif
+
+ try
+ {
// Get errors.
//
- def (pExpr, _, _) = method.GetMethodBody();
+ def pExpr = method.GetParsedBody();
when (pExpr != null)
{
@@ -294,9 +308,11 @@
}
});
}
-#if !DEBUG
}
-#endif
+ catch
+ {
+ | _ => ()
+ }
// Get the method region location.
//
@@ -437,5 +453,5 @@
| _ => null
}
}
- } // end class Project
-} // end namespace
+ }
+}
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n Sat Nov 11 21:32:52 2006
@@ -190,6 +190,14 @@
protected override PreParseMethodBody (method : MethodBuilder) : Token.BracesGroup
{
+ // Generated methods may not have Env.
+ //
+ if (method.Env == null)
+ {
+ Token.BracesGroup(null);
+ }
+ else
+ {
def reportError(e, msg)
{
Trace.WriteLine($"$msg method body of:");
@@ -199,25 +207,37 @@
}
def loc = method.BodyLocation;
- def bodyCode = try
+ def bodyCode =
+ if (loc == Location.Default)
+ {
+ "{}"
+ }
+ else
+ {
+ try
{
def filePath = loc.File;
def source = ProjectSources.GetSource(filePath);
+
source.GetRegion(loc);
}
catch { e => reportError(e, "Try get"); "{}" } // return empty body!
+ }
+
try
{
def lexer = LexerString(this, bodyCode, loc);
def preparser = PreParser(lexer, method.Env);
+
preparser.PreParse()
}
catch
{ e =>
- reportError(e, "Try compile");
+ reportError(e, "Try to compile");
Token.BracesGroup(null)
} // return empty body!
}
+ }
} // end class Engine
} // end namespace
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 Sat Nov 11 21:32:52 2006
@@ -8,13 +8,11 @@
{
public partial class Engine
{
- //[Accessor(flags=WantSetter)] mutable _processMessages : bool;
-
mutable _currentMessages : SCG.List[CompilerMessage];
public AddCompilerMessage(message : string, location : Location, kind : MessageKind, ) : void
{
- if (null != _currentMessages)
+ if (_currentMessages != null)
_currentMessages.Add(CompilerMessage(message, location, kind));
else
System.Diagnostics.Trace.WriteLine("_currentMessages is null???");
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 Sat Nov 11 21:32:52 2006
@@ -15,10 +15,14 @@
{
public module Utils
{
- public GetMethodBody(this /*[NotNull]*/ method : MethodBuilder)
- : PExpr * TExpr * Exception
+ public GetParsedBody(this /*[NotNull]*/ method : MethodBuilder) : PExpr
{
- (method.BodyParsed, method.BodyTyped, null)
+ try { method.BodyParsed } catch { _ => null }
+ }
+
+ public GetTypedBody(this /*[NotNull]*/ method : MethodBuilder) : TExpr
+ {
+ try { method.BodyTyped } catch { _ => null }
}
public IsNullOrEmpty(this value : string) : bool
Modified: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringSink.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringSink.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringSink.cs Sat Nov 11 21:32:52 2006
@@ -15,6 +15,14 @@
: base(reason, line, col, maxErrors)
{
_source = source;
+ _maxErrors = maxErrors;
+ }
+
+ private int _maxErrors;
+ public int MaxErrors
+ {
+ get { return _maxErrors; }
+ set { _maxErrors = value; }
}
private NemerleSource _source;
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 Sat Nov 11 21:32:52 2006
@@ -219,6 +219,8 @@
if (projectInfo == null)
return null;
+ int nErrors = 0;
+
request.Sink.ProcessHiddenRegions = true;
projectInfo.UpdateFile(request);
@@ -243,15 +245,22 @@
},
delegate(CompilerMessage cm)
{
+ NemerleAuthoringSink sink = (NemerleAuthoringSink)request.Sink;
+
+ if (++nErrors >= sink.MaxErrors)
+ return false;
+
TextSpan ts = Convert(cm.Location);
- request.Sink.AddError(
+ sink.AddError(
request.FileName,
cm.Message,
ts,
cm.MessageKind == MessageKind.Error ? Severity.Error :
cm.MessageKind == MessageKind.Warning ? Severity.Warning :
Severity.Hint);
+
+ return true;
});
return GetDefaultScope(request);
More information about the svn
mailing list