[svn] r6664: nemerle/trunk/ncc/parsing/PreParser.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completi...
IT
svnadmin at nemerle.org
Mon Sep 18 06:53:59 CEST 2006
Log:
Working on the method parameter tips.
Author: IT
Date: Mon Sep 18 06:53:52 2006
New Revision: 6664
Modified:
nemerle/trunk/ncc/parsing/PreParser.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/MethodTipInfo.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n
vs-plugin/trunk/Nemerle.VsIntegration/NemerleLanguage.cs
vs-plugin/trunk/Nemerle.VsIntegration/NemerleMethods.cs
vs-plugin/trunk/Nemerle.VsIntegration/NemerleScanner.cs
Modified: nemerle/trunk/ncc/parsing/PreParser.n
==============================================================================
--- nemerle/trunk/ncc/parsing/PreParser.n (original)
+++ nemerle/trunk/ncc/parsing/PreParser.n Mon Sep 18 06:53:52 2006
@@ -166,7 +166,11 @@
}
else {
def loose_group = make_list (current_stream, current_begin);
- def loose = Token.LooseGroup (loose_group.Location, loose_group);
+ def location = if (separator_token != null)
+ shift_end(loose_group.Location + separator_token.Location);
+ else
+ loose_group.Location;
+ def loose = Token.LooseGroup (location, loose_group);
parent_stream.Add (loose);
current_stream.RemoveRange (current_begin, current_stream.Count - current_begin);
}
@@ -248,7 +252,7 @@
Message.Error (loc, "when parsing this `{' brace group");
Message.Error (e.Location, e.Message);
def group = finish_parent (parent_begin, current_begin);
- Token.BracesGroup (loc + e.Location, group);
+ Token.BracesGroup (shift_end(loc + e.Location), group);
}
}
@@ -278,7 +282,7 @@
Message.Error (loc, "when parsing this `(' brace group");
Message.Error (e.Location, e.Message);
def group = finish_parent (parent_begin, current_begin);
- Token.RoundGroup (loc + e.Location, group);
+ Token.RoundGroup (shift_end(loc + e.Location), group);
}
}
@@ -306,7 +310,7 @@
Message.Error (loc, "when parsing this `[' brace group");
Message.Error (e.Location, e.Message);
def group = finish_parent (parent_begin, current_begin);
- Token.SquareGroup (loc + e.Location, group);
+ Token.SquareGroup (shift_end(loc + e.Location), group);
}
}
@@ -334,7 +338,7 @@
Message.Error (loc, "when parsing this `<[' brace group");
Message.Error (e.Location, e.Message);
def group = finish_parent (parent_begin, current_begin);
- Token.QuoteGroup (loc + e.Location, group);
+ Token.QuoteGroup (shift_end(loc + e.Location), group);
}
}
@@ -535,6 +539,7 @@
indention_based_copy ().ParseTopLevel ()
}
}
+
[Nemerle.Assertions.Ensures (value != null)]
public PreParse () : Token.BracesGroup {
try {
@@ -548,6 +553,14 @@
indention_based_copy ().PreParse ()
}
}
+
+ static shift_end(loc : Location) : Location
+ {
+ if (loc.EndColumn > 1)
+ Location(loc.FileIndex, loc.Line, loc.Column, loc.EndLine, loc.EndColumn - 1);
+ else
+ loc
+ }
}
}
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 Mon Sep 18 06:53:52 2006
@@ -344,8 +344,8 @@
| PropertyMember(obj, mem : IMember) => // { obj : TExpr; prop : IProperty; }
Check(
- expression.Location, fun() { CheckObject(expression.Location, mem) },
- obj.Location, fun() { Go(obj) });
+ expression.Location, () => CheckObject(expression.Location, mem),
+ obj.Location, () => Go(obj));
| TypeConversion(e, t, _) => // { mutable expr : TExpr; target_type : TyVar; kind : ConversionKind; }
@@ -390,8 +390,8 @@
| DefValIn(nm, val, body) => // { name : LocalValue; val : TExpr; mutable body : TExpr; }
Check(
- nm. Location, fun() { CheckLocated(nm) },
- val.Location, fun() { Go(val) });
+ nm. Location, () => CheckLocated(nm),
+ val.Location, () => Go(val));
unless (body == null)
Go(body);
@@ -571,7 +571,10 @@
| LooseGroup (child) // { mutable Child : Token; } // ; ... ;
| Namespace(_,child) => // { Env : GlobalEnv; Body : Token; }
- Go(child, token :: stack);
+ //if (IsIn(token.Location))
+ Go(child, token :: stack)
+ //else
+ // stack
| _ =>
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/MethodTipInfo.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/MethodTipInfo.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/MethodTipInfo.n Mon Sep 18 06:53:52 2006
@@ -13,11 +13,90 @@
{
_methods = methods;
_tokens = tokens;
+
+ _methods.Sort((x, y) =>
+ {
+ def xparms = x.GetParameters();
+ def yparms = y.GetParameters();
+
+ xparms.Length - yparms.Length;
+ });
+
+ Init();
}
_methods : List[IMethod];
_tokens : list[Token];
+ [Accessor] mutable _startName : Location;
+ [Accessor] mutable _startParameters : Location;
+ [Accessor] mutable _nextParameters : List[Location] = List();
+ [Accessor] mutable _endParameters : Location;
+ [Accessor] mutable _defaultMethod : int;
+
+ Init() : void
+ {
+ def memberName = GetName(0);
+
+ def findRoundGroup(tokens)
+ {
+ | h :: t => if (h is Token.RoundGroup) tokens else findRoundGroup(t)
+ | _ => []
+ }
+
+ def findIdentifier(token : Token)
+ {
+ | Identifier(name) when name == memberName && token.Next == null => token
+ | Identifier(name) when name == memberName =>
+
+ def t = findIdentifier(token.Next);
+ if (t == null) token else t
+
+ | LooseGroup(child) => findIdentifier(child)
+ | _ when token.Next != null => findIdentifier(token.Next);
+ | _ => null
+ }
+
+ def findComma(token : Token)
+ {
+ | LooseGroup as lg when lg.Next != null =>
+
+ _nextParameters.Add(Location(
+ lg.Location.FileIndex,
+ lg.Location.EndLine, lg.Location.EndColumn,
+ lg.Location.EndLine, lg.Location.EndColumn + 1));
+
+ ()
+ | _ => ()
+ }
+
+ match (findRoundGroup(_tokens))
+ {
+ | group :: prev :: _ =>
+
+ def token = findIdentifier(prev);
+
+ _startName = token.Location;
+ _startParameters = group.Location;
+
+ findComma((group :> Token.RoundGroup).Child);
+
+ _endParameters = Location(
+ group.Location.FileIndex,
+ group.Location.EndLine,
+ if (group.Location.EndColumn > 1) group.Location.EndColumn - 1 else group.Location.EndColumn);
+
+ | _ => ()
+ }
+
+ // TODO: This works incorrectly and should be redone.
+ //
+ _defaultMethod = _methods.FindIndex(m => m.GetParameters().Length == _nextParameters.Count + 1);
+
+ when (_defaultMethod < 0)
+ _defaultMethod = 0;
+ }
+
public GetCount() : int
{
_methods.Count
@@ -33,7 +112,7 @@
public GetType(index : int) : string
{
- ": " + _methods[index].ReturnType.ToString()
+ _methods[index].ReturnType.ToString()
}
public GetParameterCount(index : int) : int
@@ -64,52 +143,5 @@
{
_methods[index].Name;
}
-
- public delegate StartName (location : Location, name : string) : void;
- public delegate StartParameters(location : Location) : void;
-
- public SetCurrentCall(
- line : int,
- col : int,
- startName : StartName,
- startParameters : StartParameters
- )
- : void
- {
- def memberName = GetName(0);
-
- def findRoundGroup(tokens)
- {
- | h :: t => if (h is Token.RoundGroup) tokens else findRoundGroup(t)
- | _ => []
- }
-
- def findIdentifier(token : Token)
- {
- | Identifier(name) when name == memberName && token.Next == null => token
- | Identifier(name) when name == memberName =>
-
- def t = findIdentifier(token.Next);
- if (t == null) token else t
-
- | LooseGroup(child) => findIdentifier(child)
- | _ when token.Next != null => findIdentifier(token.Next);
- | _ => null
- }
-
- match (findRoundGroup(_tokens))
- {
- | rg :: prev :: _ =>
-
- def token = findIdentifier(prev);
-
- startName (token.Location, memberName);
- startParameters(rg.Location);
-
- | _ =>
- def loc = Location(_tokens.Head.Location.FileIndex, line, col - 1, line, col + 1);
- startName(loc, memberName);
- }
- }
}
}
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 Mon Sep 18 06:53:52 2006
@@ -206,9 +206,6 @@
)
: MethodTipInfo
{
- when (col == 21)
- _=col.ToString();
-
def typeBuilder = typeDecl.Builder;
def member = typeBuilder.GetActiveMember(fileIndex, line, col);
@@ -241,13 +238,7 @@
| Overloads(values) =>
foreach (overload in values)
- {
- match (overload.Member)
- {
- | m is IMethod => members.Add(m);
- | _ => ()
- }
- }
+ match (overload.Member) { | m is IMethod => members.Add(m); | _ => () }
| _ => ()
}
Modified: vs-plugin/trunk/Nemerle.VsIntegration/NemerleLanguage.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/NemerleLanguage.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/NemerleLanguage.cs Mon Sep 18 06:53:52 2006
@@ -262,15 +262,25 @@
if (methods != null)
{
- methods.SetCurrentCall(_request.Line + 1, _request.Col + 1,
- delegate(Location loc, string name)
+ if (methods.StartName.EndLine > 0)
{
- _request.Sink.StartName(Convert(loc), name);
- },
- delegate(Location loc)
+ _request.Sink.StartName (Convert(methods.StartName), methods.GetName(0));
+ _request.Sink.StartParameters(Convert(methods.StartParameters));
+ foreach (Location loc in methods.NextParameters)
+ _request.Sink.NextParameter(Convert(loc));
+ _request.Sink.EndParameters (Convert(methods.EndParameters));
+ }
+ else
{
- _request.Sink.StartParameters(Convert(loc));
- });
+ TextSpan ts = new TextSpan();
+
+ ts.iStartIndex = _request.Line;
+ ts.iEndIndex = _request.Line;
+ ts.iStartIndex = _request.Col - 1;
+ ts.iEndIndex = _request.Col + 1;
+
+ _request.Sink.StartName(ts, methods.GetName(0));
+ }
return new NemerleAuthoringScope(
ProjectInfo.FindProject(_request.FileName),
Modified: vs-plugin/trunk/Nemerle.VsIntegration/NemerleMethods.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/NemerleMethods.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/NemerleMethods.cs Mon Sep 18 06:53:52 2006
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using Microsoft.VisualStudio.Package;
@@ -22,6 +23,15 @@
return _info.GetCount();
}
+ public override string Delimiter { get { return ", "; } }
+ public override bool TypePrefixed { get { return false; } }
+ public override string TypePrefix { get { return ": "; } }
+
+ public override int DefaultMethod
+ {
+ get { return _info.DefaultMethod; }
+ }
+
public override string GetDescription(int index)
{
return _info.GetDescription(index);
@@ -52,13 +62,9 @@
return _info.GetName(index);
}
- public void SetCurrentCall(
- int line,
- int col,
- MethodTipInfo.StartName startName,
- MethodTipInfo.StartParameters startParameters)
- {
- _info.SetCurrentCall(line, col, startName, startParameters);
- }
+ public Location StartName { get { return _info.StartName; } }
+ public Location StartParameters { get { return _info.StartParameters; } }
+ public List<Location> NextParameters { get { return _info.NextParameters; } }
+ public Location EndParameters { get { return _info.EndParameters; } }
}
}
Modified: vs-plugin/trunk/Nemerle.VsIntegration/NemerleScanner.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/NemerleScanner.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/NemerleScanner.cs Mon Sep 18 06:53:52 2006
@@ -72,20 +72,26 @@
switch (_source[token.StartPos])
{
case '(': tokenInfo.Trigger |= TokenTriggers.ParameterStart; break;
- case ')': tokenInfo.Trigger |= TokenTriggers.ParameterEnd; break;
+ //case ')': tokenInfo.Trigger |= TokenTriggers.ParameterEnd; break;
}
break;
- case SyntaxType.OperatorDot:
+ case SyntaxType.Operator:
tokenInfo.Color = (TokenColor)TC.Operator;
tokenInfo.Type = TokenType.Operator;
- tokenInfo.Trigger = TokenTriggers.MemberSelect;
+
+ //switch (_source[token.StartPos])
+ //{
+ // case ',': tokenInfo.Trigger |= TokenTriggers.ParameterNext; break;
+ //}
+
break;
- case SyntaxType.Operator:
+ case SyntaxType.OperatorDot:
tokenInfo.Color = (TokenColor)TC.Operator;
tokenInfo.Type = TokenType.Operator;
+ tokenInfo.Trigger = TokenTriggers.MemberSelect;
break;
case SyntaxType.Keyword:
More information about the svn
mailing list