[svn] r6861: vs-plugin/trunk:
Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n
Nemerle....
pbludov
svnadmin at nemerle.org
Fri Nov 10 05:39:01 CET 2006
Log:
Navigation for tuples & generics.
Author: pbludov
Date: Fri Nov 10 05:38:56 2006
New Revision: 6861
Modified:
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.CompilerMessages.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/Class1-2.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Utils.n
vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs
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 Fri Nov 10 05:38:56 2006
@@ -95,6 +95,36 @@
if (loc1.Intersect(loc2) == loc1) m1 else m2
});
+ def checkType(ast, ty)
+ {
+ def ast_args =
+ match (ast)
+ {
+ | PExpr.Array (_, p) => [p]
+ | PExpr.Call (_, p)
+ | PExpr.Indexer(_, p) => p
+ | _ => []
+ }
+
+ match (ast_args.Find((p) => p.Location.Contains(line, col)))
+ {
+ | Some(p) =>
+ def ty_args =
+ match (ty)
+ {
+ | MType.Array (p, _) => [p]
+ | MType.Class (_, p)
+ | MType.Tuple (p) => p
+ | _ => []
+ }
+
+ def idx = ast_args.IndexOf(p);
+ checkType(p, ty_args.Nth(idx))
+
+ | _ => (ast.Location, null, ty)
+ }
+ }
+
match (member)
{
| method is MethodBuilder =>
@@ -108,9 +138,7 @@
else if (method.fun_header.Location.Contains(line, col))
{
if (method.fun_header.ret_type_loc.Contains(line, col))
- {
- (method.fun_header.ret_type_loc, null, method.fun_header.ret_type)
- }
+ checkType(method.Ast.header.ret_type, method.ReturnType);
else
{
def parm = method.fun_header.parms.Find((p) => p.ty_loc.Contains(line, col));
@@ -136,14 +164,23 @@
(fb.Location, null, fb)
else
if (fb.Ast.ty.Location.Contains(line, col))
- (fb.Ast.ty.Location, null, fb.GetMemType())
+ checkType(fb.Ast.ty, fb.GetMemType())
else
(fb.Location, null, fb)
| pb is PropertyBuilder =>
if (pb.Ast.ty.Location.Contains(line, col))
- (pb.Ast.ty.Location, null, (pb.GetMemType() :> MType.Fun).to)
+ match (pb.GetMemType())
+ {
+ // Indexer
+ //
+ | f is MType.Fun => checkType(pb.Ast.ty, f.to)
+
+ // Regular prop
+ //
+ | t => checkType(pb.Ast.ty, t)
+ }
else
(pb.Location, null, pb)
@@ -175,6 +212,7 @@
| lv is LocalValue => (QuickTipInfo(loc, lv))
| mm is IMember => (QuickTipInfo(loc, mm, manager))
| tv is TyVar => (QuickTipInfo(loc, tv))
+ | tc is TExpr.ImplicitValueTypeCtor => (QuickTipInfo(loc, tc.ty))
| fh is Typedtree.Fun_header => (QuickTipInfo(loc, fh))
| _ => (null)
}
@@ -202,18 +240,20 @@
List.Map(members, GotoInfo);
}
- match (tObj)
- {
- | me is TExpr.MacroEnvelope => [(GotoInfo(me))]
- | lv is LocalValue => [(GotoInfo(lv))]
- | tv is TyVar =>
- match (tv)
+ def getTypeGotoInfo(tv)
{
| MType.Class(tycon is TypeBuilder, _) =>
List.Map(tycon.PartsLocation, GotoInfo);
| MType.Class(tycon, _) => getMembers(tycon);
| _ => []
}
+
+ match (tObj)
+ {
+ | me is TExpr.MacroEnvelope => [(GotoInfo(me))]
+ | lv is LocalValue => [(GotoInfo(lv))]
+ | tc is TExpr.ImplicitValueTypeCtor => getTypeGotoInfo(tc.ty)
+ | tv is TyVar => getTypeGotoInfo(tv)
| tb is TypeBuilder => List.Map(tb.PartsLocation, GotoInfo);
| ti is TypeInfo => getMembers(ti);
| fh is Typedtree.Fun_header => [(GotoInfo(fh))]
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 Nov 10 05:38:56 2006
@@ -14,7 +14,10 @@
public AddCompilerMessage(message : string, location : Location, kind : MessageKind, ) : void
{
+ if (null != _currentMessages)
_currentMessages.Add(CompilerMessage(message, location, kind));
+ else
+ System.Diagnostics.Trace.WriteLine("_currentMessages is null???");
}
ProcessTopLevelCompilerMessage(location : Location, message : string) : void
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/Class1-2.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/Class1-2.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/Class1-2.n Fri Nov 10 05:38:56 2006
@@ -18,6 +18,16 @@
{
null
}
+
+ m5() : int * string * XStruct /*TupleMethod:-5*/
+ {
+ (0, "str", XStruct())
+ }
+
+ p1 : int * list[string * XStruct] /*TupleProp:-5*/
+ {
+ get { (0, [("str", XStruct())]) }
+ }
}
}
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.n Fri Nov 10 05:38:56 2006
@@ -399,5 +399,31 @@
Test();
Test();
}
+
+ [Test]
+ public QuickTip_Tuple() : void
+ {
+ def file = FilePath2;
+ def (line, col) = ReadLocation(file, "TupleMethod");
+
+ def result = _project.GetQuickTipInfo(file, line, col);
+
+ Assert.IsNotNull(result, "result is null");
+ WriteLine(result.Text);
+ Assert.AreEqual (result.Text.Split('\n')[0], "internal sealed struct XStruct");
+ }
+
+ [Test]
+ public QuickTip_Tuple_FIXME() : void
+ {
+ def file = FilePath2;
+ def (line, col) = ReadLocation(file, "TupleProp");
+
+ def result = _project.GetQuickTipInfo(file, line, col);
+
+ Assert.IsNotNull(result, "result is null");
+ WriteLine(result.Text);
+ Assert.AreEqual (result.Text.Split('\n')[0], "internal sealed struct XStruct");
+ }
}
}
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 Fri Nov 10 05:38:56 2006
@@ -477,5 +477,41 @@
Uri(asm.CodeBase).LocalPath;
}
+ public IndexOf ['a] (this l : list ['a], a : 'a) : int
+ {
+ def loop(l, a, idx)
+ {
+ match (l)
+ {
+ | h :: t =>
+ if (h.Equals (a))
+ idx
+ else
+ loop (t, a, idx + 1)
+ | [] => -1
+ }
+ }
+
+ loop(l, a, 0)
+ }
+
+ public FindIndexOf ['a] (this l : list ['a], pred : 'a -> bool) : int
+ {
+ def loop(l, pred, idx)
+ {
+ match (l)
+ {
+ | h :: t =>
+ if (pred(h))
+ idx
+ else
+ loop (t, pred, idx + 1)
+ | [] => -1
+ }
+ }
+
+ loop(l, pred, 0)
+ }
+
} // End of Utils module
} // End of namespace
Modified: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs Fri Nov 10 05:38:56 2006
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Diagnostics.SymbolStore;
using System.Windows.Forms;
@@ -145,17 +146,21 @@
gotoInfo.SetLocation(documents[0].URL, lines[0], columns[0], endLines[0], endColumns[0]);
}
}
- catch (COMException)
+ catch (COMException ex)
{
- //VladD2: Ýòî íå äåëî. Òàê, áåç åäèíîãî çâóêà, çàìàçûâàòü èñêëþ÷åíèÿ íåëüçÿ!
- // Abstract method or something. Eat exception and continue.
+ // Abstract method or not a method at all. Sequence points are available only for methods.
+ //
+ Trace.WriteLineIf(TS.TraceError,
+ string.Format("{0}, code 0x{1:X8}", ex.Message, ex.ErrorCode), TS.DisplayName);
}
}
}
- catch (COMException)
+ catch (COMException ex)
{
- //VladD2: Ýòî íå äåëî. Òàê, áåç åäèíîãî çâóêà, çàìàçûâàòü èñêëþ÷åíèÿ íåëüçÿ!
// The file was not found or line numbers were stripped from pdb.
+ //
+ Trace.WriteLineIf(TS.TraceError,
+ string.Format("{0}, code 0x{1:8X}", ex.Message, ex.ErrorCode), TS.DisplayName);
}
finally
{
@@ -232,5 +237,23 @@
}
#endregion
+
+ #region Debug
+
+ private static TraceSwitch _authoringScopeTrace;
+
+ private static TraceSwitch TS
+ {
+ get
+ {
+ return
+ _authoringScopeTrace ??
+ (_authoringScopeTrace = new TraceSwitch("NemerleAuthoringScope",
+ "Enables Nemerle.VsIntegration.LanguageService.NemerleAuthoringScope trace"));
+ }
+ }
+
+ #endregion
+
}
}
More information about the svn
mailing list