[svn] r6814: vs-plugin/trunk:
Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n
Nemerle.Co...
IT
svnadmin at nemerle.org
Tue Oct 31 04:26:37 CET 2006
Log:
1. Enum tool tip info enhancement.
2. Skip add/remove reference if com/dll reference assembly does not exist.
3. Some ExprFinder changes.
Author: IT
Date: Tue Oct 31 04:26:32 2006
New Revision: 6814
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/CodeModel/QuickTipInfo.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Utils.n
vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleReferenceContainerNode.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 Tue Oct 31 04:26:32 2006
@@ -96,7 +96,10 @@
{
| StaticRef(from, mem, _) => // { from : MType.Class; mem : IMember; type_parms : list [TyVar]; }
- if (from.tycon.Name == PExprName) from else mem : object
+ if (mem.MemberType != MemberTypes.Constructor && from.tycon.Name == PExprName)
+ from
+ else
+ mem : object
| TypeConversion(_, tt, _) => // { mutable expr : TExpr; target_type : TyVar; kind : ConversionKind; }
@@ -147,6 +150,8 @@
| LocalRef(LocalValue where (ValKind = ClosurisedThisPointer)) => expr.Location == _texprLocation
| TypeConversion => _Debug(obj); true
| Literal => expr.ToString() != PExprName
+// | StaticRef => _texprObject is TExpr.Call
+ | Error => true
| _ => false
}
| _ => false
@@ -263,10 +268,15 @@
for (mutable i = 0; i < level; i++)
s += " ";
+ mutable os = obj.ToString();
+
+ when (os.Length > 200)
+ os = os.Substring(0, 200) + "...";
+
Trace.WriteLine("");
Trace.WriteLine(s + $"$(obj.GetType().FullName) $(loc.Line):$(loc.Column):"
"$(loc.EndLine):$(loc.EndColumn) $_line:$_col.");
- Trace.WriteLine(s + obj.ToString().Replace("\n", "\n" + s));
+ Trace.WriteLine(s + os.Replace("\n", "\n" + s));
#endif
ignore(obj); ignore(loc); ignore(level);
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 Tue Oct 31 04:26:32 2006
@@ -83,7 +83,17 @@
def typeBuilder = typeDecl.Builder;
def member =
if (typeBuilder.IsDelegate) typeBuilder : IMember
- else typeBuilder.GetActiveMember(fileIndex, line, col, (f) => f is PropertyBuilder);
+ else typeBuilder.GetActiveMember(fileIndex, line, col,
+ fun(m1, m2)
+ {
+ def loc1 = m1.Location;
+ def loc2 = m2.Location;
+
+ if (loc1 == loc2)
+ if (m2 is PropertyBuilder) m2 else m1
+ else
+ if (loc1.Intersect(loc2) == loc1) m1 else m2
+ });
match (member)
{
@@ -104,7 +114,19 @@
(Location.Default, null, null)
}
- | fb is FieldBuilder => (fb.Location, null, fb)
+ | fb is FieldBuilder =>
+
+ if (typeDecl.Builder.IsEnum)
+ if (fb.Attributes %&& NemerleAttributes.SpecialName)
+ (Location.Default, null, null)
+ else
+ (fb.Location, null, fb)
+ else
+ if (fb.Ast.ty.Location.Contains(line, col))
+ (fb.Ast.ty.Location, null, fb.GetMemType())
+ else
+ (fb.Location, null, fb)
+
| pb is PropertyBuilder => (pb.Location, null, pb)
| tb is TypeBuilder => (tb.Location, null, tb)
| null => (Location.Default, null, null)
@@ -119,7 +141,8 @@
fileIndex : int,
line : int,
col : int,
- source : ISourceTextManager
+ source : ISourceTextManager,
+ manager : ManagerClass
)
: QuickTipInfo
{
@@ -129,12 +152,12 @@
{
| me is TExpr.MacroEnvelope => (QuickTipInfo(loc, me))
| lv is LocalValue => (QuickTipInfo(loc, lv))
- | mm is IMember => (QuickTipInfo(loc, mm))
+ | mm is IMember => (QuickTipInfo(loc, mm, manager))
| tv is TyVar => (QuickTipInfo(loc, tv))
| fh is Typedtree.Fun_header => (QuickTipInfo(loc, fh))
- | fb is FieldBuilder => (QuickTipInfo(fb.Location, fb))
- | pb is PropertyBuilder => (QuickTipInfo(pb.Location, pb))
- | tb is TypeBuilder => (QuickTipInfo(tb.Location, tb))
+ | fb is FieldBuilder => (QuickTipInfo(fb.Location, fb, manager))
+ | pb is PropertyBuilder => (QuickTipInfo(pb.Location, pb, manager))
+ | tb is TypeBuilder => (QuickTipInfo(tb.Location, tb, manager))
| _ => (null)
}
}
@@ -156,11 +179,7 @@
| lv is LocalValue => (GotoInfo(lv))
| tv is TyVar => (GotoInfo(tv))
| fh is Typedtree.Fun_header => (GotoInfo(fh))
- | fb is FieldBuilder =>
- if (fb.Ast.ty.Location.Contains(line, col))
- (GotoInfo(fb.GetMemType()))
- else
- (GotoInfo(fb))
+ | fb is FieldBuilder => (GotoInfo(fb))
| pb is PropertyBuilder => (GotoInfo(pb))
| mm is IMember => (GotoInfo(mm))
| tb is TypeBuilder => (GotoInfo(tb))
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 Tue Oct 31 04:26:32 2006
@@ -130,7 +130,7 @@
match (decl)
{
| Using as us => GetUsingQuickTip(us, fileIndex, line, col)
- | Type as tp => GetTypeQuickTip (tp, fileIndex, line, col, source);
+ | Type as tp => GetTypeQuickTip (tp, fileIndex, line, col, source, _engine);
| None => throw System.Exception()
| _ => null
}
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/QuickTipInfo.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/QuickTipInfo.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/QuickTipInfo.n Tue Oct 31 04:26:32 2006
@@ -31,10 +31,10 @@
}
}
- public this(location : Location, member : IMember)
+ public this(location : Location, member : IMember, manager : ManagerClass)
{
SetLocation (location);
- SetMemberText(member);
+ SetMemberText(member, manager);
}
public this(location : Location, value : LocalValue)
@@ -150,7 +150,7 @@
"\n\n" + location.ToString();
}
- private SetMemberText(member : IMember) : void
+ private SetMemberText(member : IMember, manager : ManagerClass) : void
{
mutable name = match (member)
{
@@ -182,6 +182,78 @@
| _ => ()
}
+ match (member)
+ {
+ | fb is FieldBuilder when fb.IsLiteral && fb.DeclaringType.IsEnum =>
+
+ match (fb.const_value)
+ {
+ | Integer(val, is_negative, _) =>
+
+ def toHex(val)
+ {
+ mutable s = val.ToString("X");
+ while (s.Length % 4 != 0)
+ s = "0" + s;
+ "0x" + s
+ }
+
+ _text += string.Format("\n\nValue: {0}{1} ({2}) {3}",
+ if (is_negative) "-" else "",
+ val,
+ toHex(val),
+ {
+ if (fb.DeclaringType.HasAttribute(manager.InternalType.FlagsAttribute_tc))
+ {
+ mutable n = val;
+ def fields = fb.DeclaringType.GetMembers(BindingFlags.Static %| BindingFlags.Public);
+ def fields = fields.Filter(f =>
+ {
+ match (f)
+ {
+ | f is FieldBuilder when fb.IsLiteral =>
+ match (f.const_value)
+ {
+ | Integer(f_val, f_is_negative, _) =>
+
+ if (!fb.Equals(f) && f_val != 0 && is_negative == f_is_negative && (val & f_val == f_val))
+ {
+ n &= ~f_val;
+ true;
+ }
+ else
+ false
+
+ | _ => false
+ }
+ | _ => false
+ }
+ });
+
+ if (fields.Length > 0)
+ {
+ def sb = System.Text.StringBuilder("= ");
+
+ foreach (f :> FieldBuilder in fields)
+ _ = sb.Append(f.Name).Append(" | ");
+
+ if (n != 0) _ = sb.Append(toHex(n));
+ else _ = sb.Remove(sb.Length - 2, 2);
+
+ sb.ToString()
+ }
+ else
+ ""
+ }
+ else
+ ""
+ });
+ | _ => ()
+ }
+
+ | _ => ()
+ }
+
_text += GetDocText(member, member.Location) + GetLocationText(member.Location);
}
@@ -313,7 +385,12 @@
}
)
+
- "\n\n" + mc.expanded.ToString();
+ "\n\n" + mc.ToString();
+ }
+
+ _debug[T](o : T) : void
+ {
+ _ = o.ToString();
}
}
}
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 Tue Oct 31 04:26:32 2006
@@ -212,18 +212,20 @@
fileIndex : int,
line : int,
col : int,
- predicate : IMember -> bool
+ comparator : IMember * IMember -> IMember
)
: IMember
{
def members = typeBuilder.GetActiveMembers(fileIndex, line, col);
- match (members)
+ def filter(mlist)
{
| [m] => m
| [] => null
- | m :: tail => tail.FindWithDefault(m, predicate)
+ | m1 :: m2 :: tail => filter(comparator(m1, m2) :: tail)
}
+
+ filter(members)
}
public GetActiveMembers(
Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleReferenceContainerNode.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleReferenceContainerNode.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleReferenceContainerNode.cs Tue Oct 31 04:26:32 2006
@@ -69,10 +69,14 @@
{
if (node is ComReferenceNode || node is AssemblyReferenceNode)
{
+ // IT: if dll does not exist, the Url will be null.
+ //
+ if (node.Url != null)
+ {
AssemblyName assemblyName = AssemblyName.GetAssemblyName(node.Url);
-
project.ProjectInfo.AddAssembly(assemblyName);
}
+ }
else if (node is ProjectReferenceNode)
{
project.ProjectInfo.AddProject((ProjectReferenceNode)node);
@@ -90,10 +94,12 @@
{
if (node is ComReferenceNode || node is AssemblyReferenceNode)
{
+ if (node.Url != null)
+ {
AssemblyName assemblyName = AssemblyName.GetAssemblyName(node.Url);
-
project.ProjectInfo.RemoveAssembly(assemblyName);
}
+ }
else if (node is ProjectReferenceNode)
{
project.ProjectInfo.RemoveProject((ProjectReferenceNode)node);
More information about the svn
mailing list