[svn]
r7358: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2:
Debug/AstUtils.n Engine/Engine-ma...
VladD2
svnadmin at nemerle.org
Tue Jan 30 03:01:33 CET 2007
Log:
Prevent exception when code not welldefined.
Author: VladD2
Date: Tue Jan 30 03:01:31 2007
New Revision: 7358
Modified:
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Debug/AstUtils.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Completion.n
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Debug/AstUtils.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Debug/AstUtils.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Debug/AstUtils.n Tue Jan 30 03:01:31 2007
@@ -119,7 +119,13 @@
def checkDecl(parentName, decl : TopDeclaration)
{
- def name = parentName + decl.Name + ".";
+ def shortName = match (decl.name)
+ {
+ | Splicable.Name (x) => x.Id
+ | _ => ""
+ };
+
+ def name = parentName + shortName + ".";
def checkMember(member : ClassMember)
{
@@ -136,7 +142,10 @@
| Macro => result ::= (parentName, decl);
| Class (_, decls)
| Variant (_, decls)
- | VariantOption(decls) => result ::= (parentName, decl); decls.Iter(checkMember);
+ | VariantOption(decls) =>
+ result ::= (parentName, decl);
+ when (decls != null)
+ decls.Iter(checkMember);
}
}
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 Tue Jan 30 03:01:31 2007
@@ -86,7 +86,7 @@
{
//Output.WriteLine($"------- $topDecl: $(topDecl.Name)");
//Output.WriteLine(topDecl.Location);
- when (topDecl.ParsedName.context != null)
+ when (topDecl.name is Splicable.Name && topDecl.ParsedName.context != null)
ScanningPipeline(topDecl);
}
//Trace.WriteLine("!!! End <<<<");
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Completion.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Completion.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Completion.n Tue Jan 30 03:01:31 2007
@@ -221,12 +221,13 @@
def completeTypeEnforcement(method, typeExpr : list[Token])
{
// Make fake expression and type it...
- def prefix = "_ : ";
+ //def prefix = "_ : ";
def loc = if (typeExpr is []) Location(fileIndex, line, col, line, col)
else typeExpr.Head.Location + typeExpr.Last.Location;
def typeName = if (typeExpr is []) "" else source.GetRegion(loc);
- def code = prefix + typeName;
- def result = RunCompletionEngine(method, code, loc, line, col + prefix.Length);
+ def code = /*prefix +*/ typeName;
+ def result = CompleteType(method.Env, code, loc, line, col/* + prefix.Length*/);
+ //def result = RunCompletionEngine(method, code, loc, line, col + prefix.Length);
if (result == null)
{
Trace.WriteLine("### RunCompletionEngine() (type enforcement completion) return null!");
@@ -473,6 +474,47 @@
}
}
+ public CompleteType (
+ [NotNull] env : GlobalEnv,
+ [NotNull] content : string,
+ methodBodyLocation : Location,
+ completionMarkLine : int,
+ completionMarkChar : int
+ )
+ : CompletionResult
+ {
+ _isCompletioInProgress = true;
+
+ try
+ {
+ _currentMessages = SCG.List(32);
+
+ mutable completionList = null;
+ def content = content + " ";
+ def lexer = LexerCompletion (this, content, methodBodyLocation,
+ completionMarkLine, completionMarkChar);
+
+ try
+ {
+ def pExpr = MainParser.ParseExpr(env, lexer, false);
+ def _x = env.MonoBindType(pExpr)
+ }
+ catch
+ {
+ | e is CompletionResult => completionList = e;
+ | e => Trace.WriteLine (e.Message);
+ }
+
+ _currentMessages = null;
+
+ completionList
+ }
+ finally
+ {
+ _isCompletioInProgress = false;
+ }
+ }
+
private ParseMethodBody(method : MethodBuilder, lexer : LexerBase) : FunBody.Parsed
{
def header = method.GetHeader();
@@ -505,5 +547,23 @@
lex.Keywords = lex.Manager.CoreEnv.Keywords;
lex
}
+
+ /// Get completion lexer for some range in source file.
+ /// The range specified by loc parametr.
+ // Note: All locations strat at start point of loc.
+ public GetCompletionLexer(
+ source : ISource,
+ loc : Location,
+ completionMarkLine : int,
+ completionMarkChar : int
+ )
+ : LexerBase
+ {
+ def code = source.GetRegion(loc);
+ def lex = LexerCompletion(this, code, loc, completionMarkLine, completionMarkChar);
+ lex.BeginParseFile();
+ lex.Keywords = lex.Manager.CoreEnv.Keywords;
+ lex
+ }
} // end class Engine
} // end namespace
More information about the svn
mailing list