[svn] r6552: vs-plugin/trunk:
Nemerle.Compiler.Utils/AstBrowserForm.n
Nemerle.Compiler.Utils/CodeDomParser...
VladD2
svnadmin at nemerle.org
Fri Aug 18 04:29:20 CEST 2006
Log:
1. Sync with compiler. 2. Refactorind of completion list creation. 3. Move common static methods to Utils class. 4. Rename Project.overload.n to Project.overload.n and delete Engine.utils.n.
Author: VladD2
Date: Fri Aug 18 04:29:05 2006
New Revision: 6552
Added:
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.MakeCompletionList.n
- copied, changed from rev 6548, vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.overload.n
Removed:
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.overload.n
Modified:
vs-plugin/trunk/Nemerle.Compiler.Utils/AstBrowserForm.n
vs-plugin/trunk/Nemerle.Compiler.Utils/CodeDomParser.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/GlyphType.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Using.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/Nemerle.Completion2/Engine/CompletionElem.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Utils.n
vs-plugin/trunk/Nemerle.VsIntegration/NemerleDeclarations.cs
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/AstBrowserForm.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/AstBrowserForm.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/AstBrowserForm.n Fri Aug 18 04:29:05 2006
@@ -59,7 +59,7 @@
def tree = TreeView();
tree.Dock = DockStyle.Fill;
tree.Parent = spliter.Panel1;
- ignore(tree.Nodes.Add(FillTree(namespaceTree.Name.ToString(), namespaceTree)));
+ ignore(tree.Nodes.Add(FillTree(namespaceTree.GetDisplayName(), namespaceTree)));
def propDrid = PropertyGrid();
propDrid.Dock = DockStyle.Fill;
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/CodeDomParser.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/CodeDomParser.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/CodeDomParser.n Fri Aug 18 04:29:05 2006
@@ -113,11 +113,14 @@
private AddToNamespace(decl: TopDeclaration, codeType: CodeTypeDeclaration) : void
{
def ns = decl.ParsedName.context.CurrentNamespace;
- def nsName = if(ns.Name == null) "#default#" else ns.Name;
+ def nsName = ns.GetDisplayName();
def _namespace = GetNamespace(nsName);
// äđóăîăî ďóňč íĺ íŕřĺë ęŕę ďîëó÷čňü usings.
- def namespace_nodes = GetPropValue(decl.ParsedName.context, "nameTree"::"referenced_namespace_nodes"::[]):> System.Collections.Generic.List.[(list[NamespaceTree.Node] * Location)];
+ def namespace_nodes = GetPropValue(decl.ParsedName.context,
+ "nameTree"::"referenced_namespace_nodes"::[])
+ :> System.Collections.Generic.List.[(list[NamespaceTree.Node] * Location)];
+
when(namespace_nodes != null && namespace_nodes.Count > 0)
{
def imports = Dictionary.[string, object]();
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj Fri Aug 18 04:29:05 2006
@@ -71,9 +71,7 @@
<Compile Include="Nemerle.Completion2\Engine\Engine.Init.n" />
<Compile Include="Nemerle.Completion2\Engine\Engine.Properties.n" />
<Compile Include="Nemerle.Completion2\Engine\Engine.crud.n" />
- <Compile Include="Nemerle.Completion2\Engine\Engine.utils.n" />
<Compile Include="Nemerle.Completion2\CodeModel\Project.Type.n" />
- <Compile Include="Nemerle.Completion2\CodeModel\Project.overload.n" />
<Compile Include="Nemerle.Completion2\CodeModel\QuickTipInfo.n" />
<Compile Include="Nemerle.Completion2\CodeModel\GlyphType.n" />
<Compile Include="Const.n" />
@@ -93,6 +91,9 @@
<Compile Include="Nemerle.Completion2\CodeModel\XmlDocInfo.n" />
<Compile Include="Nemerle.Completion2\CodeModel\XmlDocReader.n" />
</ItemGroup>
+ <ItemGroup>
+ <Compile Include="Nemerle.Completion2\CodeModel\Project.MakeCompletionList.n" />
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/GlyphType.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/GlyphType.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/GlyphType.n Fri Aug 18 04:29:05 2006
@@ -10,13 +10,18 @@
| Event = 6 * 5
| Field = 6 * 7
| Interface = 6 * 8
- | Function = 6 * 12 //72
+ | Block = 6 * 9
+ | Variant = 6 * 10
+ | VariantOption = 6 * 11
+ | Method = 6 * 12
+ | Function = 6 * 13
| Namespace = 6 * 15
+ | Operator = 6 * 15
| Property = 6 * 17
- | Variant = 6 * 21
- | VariantOption = 6 * 22
- | Macro = 6 * 23
+ | Macro = 6 * 20
+ | Local = 6 * 23
| Snippet = 205
+ | Keyword = 206
}
public enum GlyphSubtype
Copied: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.MakeCompletionList.n (from rev 6548, vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.overload.n)
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.overload.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.MakeCompletionList.n Fri Aug 18 04:29:05 2006
@@ -15,97 +15,108 @@
{
public static MakeCompletionList(result : CompletionResult) : array[CompletionElem]
{
- def IsPropertyAccessor(name)
- {
- name.StartsWith("get_") || name.StartsWith("set_")
- }
+ def overloadsMap = Hashtable.[string, SCG.List[Elem]]();
+ def completionList = SCG.List();
- def IsEventAccessor(name)
+ def add(name, value)
{
- name.StartsWith("add_") || name.StartsWith("remove_")
+ def overloads = overloadsMap.GetValueOrDefault(name, () => SCG.List());
+ overloads.Add(value);
+ overloadsMap[name] = overloads;
}
- def IsOperator(name)
+ foreach (elem in result.Elems)
{
- name.StartsWith("op_")
- }
-
- def IsSpecialName(name)
+ | Local (value) => add(value.Type.ToDisplayString(), elem);
+ | Node (name, _) => add(name, elem);
+ | Overloads (values) =>
+ foreach (overload in values)
{
- name.StartsWith("value__")
+ def member = overload.Member;
+ when (IsValid(member))
+ {
+ def name = match (member.MemberType)
+ {
+ | Constructor => ReplaceSpecialName(member.DeclaringType.Name)
+ | _ => member.Name
}
- def IsValid(member)
- {
- def name = member.Name.ToString();
- !IsPropertyAccessor(name) && !IsEventAccessor(name)
- && !IsOperator(name) && !IsSpecialName(name)
+ add (name, Elem.Overload(overload))
+ }
+ }
+ | Overload => assert(false);
}
- def overloadsMap = Hashtable.[string, SCG.List[IMember]]();
- def overloads = SCG.List();
+ foreach (elem in overloadsMap)
+ {
+ def name = elem.Key;
+ def overloads = elem.Value;
+ assert(overloads.Count > 0);
- foreach (elem in result.Elems)
+ match (overloads[0])
{
| Local (value) =>
- def v = value;
- def valKind = match (v.ValKind)
+ def value = value;
+ def glyphType = match (value.ValKind)
{
- | Plain => "local variable"
- | Function(_header, _uses_closure_of) => "function"//: Fun_header, list[Fun_header];
- | FunParm(kind) =>
- (if (kind == Typedtree.ParmKind.Normal) "" else kind.ToString().ToLower() + " ")
- + "parametr"
- | ExceptionValue => "exception value"
- | PatternVariable => "pattern variable"
- | BlockReturn => "block"
- | ClosurisedThisPointer => "captured by closure"
- | MacroRedirection => "macro" //{ subst : Parsetree.PExpr; }
+ | FunParm => GlyphType.Local
+ | Plain => GlyphType.Local
+ | ExceptionValue => GlyphType.Local
+ | PatternVariable => GlyphType.Local
+ | Function => GlyphType.Function
+ | BlockReturn => GlyphType.Block
+ | ClosurisedThisPointer => GlyphType.Keyword
+ | MacroRedirection => GlyphType.Macro
};
- def mutability = if (v.IsMutable) "mutable " else "";
- def typeName = v.Type.ToDisplayString();
-
- overloads.Add(CompletionElem(
- (if (v.IsMutable) GlyphType.Field else GlyphType.Const) :> int,
- value.Name,
- $"$mutability$valKind of '$typeName' type",
- null));
+ completionList.Add(CompletionElem(glyphType :> int, value.Name, "", overloads));
- | Node (name, node) =>
- overloads.Add(CompletionElem(name, node));
+ | Node(name, node) =>
+ completionList.Add(CompletionElem(
+ node.Value.GetGlyphIndex() :> int, name, "", overloads));
- | Overloads (values) =>
- foreach (overload in values)
- {
+ | Overload (overload) =>
def member = overload.Member;
- when (IsValid(member))
- {
- def name = match (member.MemberType)
- {
- | Constructor => ReplaceSpecialName(member.DeclaringType.Name)
- | _ => member.Name
- }
+ completionList.Add(CompletionElem(member.GetGlyphIndex(), name, "", overloads));
- def members = overloadsMap.GetValueOrDefault(name, () => SCG.List());
- members.Add(member);
- overloadsMap[name] = members;
- }
+ | Overloads => assert(false);
}
}
//TODO: Đĺŕëčçîâŕňü ęîěëĺéřîí äë˙ ďđîńňđŕíńňâ čěĺí.
//TODO: Ďîďđŕâčňü ęîěďëĺéřîí äë˙ ęîíńňđóęňîđîâ.
- foreach (x in overloadsMap)
- overloads.Add(CompletionElem(x.Value[0].GetGlyphIndex(),
- x.Key, "", x.Value.ToArray()));
+ completionList.ToArray()
+ }
+
+ static IsValid(member : IMember) : bool
+ {
+ def name = member.Name.ToString();
+ !IsPropertyAccessor(name) && !IsEventAccessor(name)
+ && !IsOperator(name) && !IsSpecialName(name)
+ }
+
+ static IsPropertyAccessor(name : string) : bool
+ {
+ name.StartsWith("get_") || name.StartsWith("set_")
+ }
+
+ static IsEventAccessor(name : string) : bool
+ {
+ name.StartsWith("add_") || name.StartsWith("remove_")
+ }
+
+ static IsOperator(name : string) : bool
+ {
+ name.StartsWith("op_") : bool
+ }
- overloads.ToArray()
+ static IsSpecialName(name : string) : bool
+ {
+ name.StartsWith("value__")
}
- public static MakeName(overloadPossibility : OverloadPossibility)
- : string
+ public static MakeName(overloadPossibility : OverloadPossibility) : string
{
// Base copmletion logic
def MakeNameFromMember(member : IMember)
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Using.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Using.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Using.n Fri Aug 18 04:29:05 2006
@@ -153,7 +153,8 @@
};
foreach ((name, node) when fitForCompletion(name, node.Value) in ns.Children.KeyValuePairs)
- resalt.Add(CompletionElem(name, node));
+ resalt.Add(CompletionElem(node.Value.GetGlyphIndex() :> int,
+ name, "", array[Elem.Node(name, node)]));
resalt.ToArray();
}
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 Fri Aug 18 04:29:05 2006
@@ -159,7 +159,10 @@
for (mutable i = 0; i < counter; i++)
s += " ";
- Trace.WriteLine(s + $"$(ex.GetType().FullName) $(ex.loc.Line):$(ex.loc.Column):$(ex.loc.EndLine):$(ex.loc.EndColumn) cur:$(curLocation.Line):$(curLocation.Column):$(curLocation.EndLine):$(curLocation.EndColumn).");
+ Trace.WriteLine(s + $"$(ex.GetType().FullName) $(ex.loc.Line):"
+ "$(ex.loc.Column):$(ex.loc.EndLine):$(ex.loc.EndColumn) cur:"
+ "$(curLocation.Line):$(curLocation.Column):$(curLocation.EndLine):"
+ "$(curLocation.EndColumn).");
Trace.WriteLine(s + ex.ToString().Replace("\n", "\n" + s));
Trace.WriteLine("");
}
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 Fri Aug 18 04:29:05 2006
@@ -63,7 +63,7 @@
| [] => SetLocation (location);
}
- _text = sprintf("(%s) %s(", GetKindText(fh.decl), fh.name);
+ _text = sprintf("(%s) %s(", fh.decl.GetKindText(), fh.name);
_text += fh.parms.Map(p => p.Name + " : " + p.ty.ToDisplayString()).ToString(", ");
_text += ") : " + fh.ret_type.ToDisplayString();
}
@@ -71,22 +71,7 @@
public this(location : Location, mc : PExpr.MacroCall, texpr : TExpr)
{
SetLocation(location);
-
- _text = "macro " + mc.ns.GetDisplayName ();
-
- match (mc.ns.Value)
- {
- | MacroCall(m) =>
-
- match (m.Keywords)
- {
- | [] => ()
- | _ => _text += "\n\nKeywords:\n " + m.Keywords.ToString(", ");
- }
- | _ => ()
- }
-
- _text += "\n\n" + texpr.ToString();
+ _text = mc.MakeHint() + "\n\n" + texpr.ToString();
}
private SetLocation(location : Location) : void
@@ -113,19 +98,6 @@
_colEnd = l2.Column - 1;
}
- private GetKindText(value : LocalValue) : string
- {
- mutable kind = value.ValKind.ToString();
-
- when (kind.StartsWith("a "))
- kind = kind.Substring(2);
-
- when (value.IsMutable)
- kind = "mutable " + kind;
-
- kind
- }
-
private GetAttributeText(attrs : NemerleAttributes) : string
{
mutable s = "";
@@ -155,14 +127,14 @@
s
}
- private GetDocText(mtype : MType, location : Location) : string
+ private static GetDocText(mtype : MType, location : Location) : string
{
def info = XmlDocReader.GetInfo(mtype, location);
if (info != null) "\n" + info.GetText() else ""
}
- private GetDocText(member : IMember, location : Location) : string
+ private static GetDocText(member : IMember, location : Location) : string
{
def info = XmlDocReader.GetInfo(member, location);
@@ -216,8 +188,65 @@
private SetText(value : LocalValue) : void
{
- _text = sprintf("(%s) %s%s",
- GetKindText(value),
+ _text = value.MakeHint();
+ }
+
+ private SetText(mtype : MType) : void
+ {
+ match (mtype)
+ {
+ | Class(tycon, _) =>
+
+ _text = GetAttributeText(tycon.Attributes);
+
+ _text += match (tycon.GetTydecl())
+ {
+ | VariantOption => "variant option"
+ | Variant => "variant"
+ | Class => if (tycon.Attributes %&& NemerleAttributes.Struct) "struct" else "class"
+ | Alias => "alias"
+ | Interface => "interface"
+ | Enum => "enum"
+ }
+
+ _text += " " + tycon.FullName + GetDocText(mtype, tycon.Location) + GetLocationText(tycon.Location);
+
+ | _ => _text += mtype.ToString()
+ }
+ }
+
+ // Shared implementation
+
+ public static GetKindText(this value : LocalValue) : string
+ {
+ mutable kind = value.ValKind.ToString();
+
+ when (kind.StartsWith("a "))
+ kind = kind.Substring(2);
+ //def valKind = match (value.ValKind)
+ //{
+ // | Plain => "local variable"
+ // | Function(_header, _uses_closure_of) => "function"//: Fun_header, list[Fun_header];
+ // | FunParm(kind) =>
+ // (if (kind == Typedtree.ParmKind.Normal) "" else kind.ToString().ToLower() + " ")
+ // + "parametr"
+ // | ExceptionValue => "exception value"
+ // | PatternVariable => "pattern variable"
+ // | BlockReturn => "block"
+ // | ClosurisedThisPointer => "captured by closure"
+ // | MacroRedirection => "macro" //{ subst : Parsetree.PExpr; }
+ //};
+
+ when (value.IsMutable)
+ kind = "mutable " + kind;
+
+ kind
+ }
+
+ public static MakeHint(this value : LocalValue) : string
+ {
+ mutable text = sprintf("(%s) %s%s",
+ value.GetKindText(),
value.Name,
match (value.ValKind)
{
@@ -231,34 +260,63 @@
{
when (use.ToString() != definedIn)
{
- _text += $"\ndefined in $definedIn";
+ text += $"\ndefined in $definedIn";
break;
}
}
+
+ text
}
- private SetText(mtype : MType) : void
+ public static MakeHint(this node : NamespaceTree.Node) : string
{
- match (mtype)
+ node.EnsureCached();
+
+ def text = match (node.Value) // : NamespaceTree.TypeInfoCache
{
- | Class(tycon, _) =>
+ // TypeInfo loaded or parsed
+ | Cached(ty) => ty.GetTydecl().GetTypeKindName() + " "
+ // ambiguous TypeInfo loaded or parsed
+ | CachedAmbiguous(typeInfos) => "ambiguous (" + typeInfos.Map(
+ ty => ty.GetTydecl().GetTypeKindName()).ToString(", ") + ") "
- _text = GetAttributeText(tycon.Attributes);
+ | NamespaceReference => "namespace ";
+ | MacroCall => "macro "
+ // TypeInfo of external type not yet loaded
+ | NotLoaded | NotLoadedList | No =>
+ throw ArgumentException("Tish function can't process nade wich value is No!")
+ }
- _text += match (tycon.GetTydecl())
+ text + node.GetDisplayName()
+ }
+
+ public static MakeHint(this macroCall : PExpr.MacroCall) : string
{
- | VariantOption => "variant option"
- | Variant => "variant"
- | Class => if (tycon.Attributes %&& NemerleAttributes.Struct) "struct" else "class"
- | Alias => "alias"
- | Interface => "interface"
- | Enum => "enum"
+ "macro " + macroCall.ns.GetDisplayName() + MakeMacroCallInfo(macroCall)
}
- _text += " " + tycon.FullName + GetDocText(mtype, tycon.Location) + GetLocationText(tycon.Location);
+ private static MakeMacroCallInfo(macroCall : PExpr.MacroCall) : string
+ {
+ mutable text = "";
- | _ => _text += mtype.ToString()
+ match (macroCall.ns.Value)
+ {
+ | MacroCall(m) =>
+
+ match (m.Keywords)
+ {
+ | [] => ()
+ | _ => text += "\n\nKeywords:\n " + m.Keywords.ToString(", ");
}
+ | _ => ()
+ }
+
+ text
+ }
+
+ public static GetDocText(member : IMember) : string
+ {
+ GetDocText(member, member.Location)
}
}
}
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/CompletionElem.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/CompletionElem.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/CompletionElem.n Fri Aug 18 04:29:05 2006
@@ -5,6 +5,7 @@
using Nemerle.Compiler.Parsetree;
using Nemerle.Imperative;
using Nemerle.Utility;
+using SCG = System.Collections.Generic;
using Nemerle.Compiler.Utils;
using Typed = Nemerle.Compiler.Typedtree;
@@ -17,84 +18,39 @@
[Accessor] _glyphType : int;
[Accessor] _displayName : string;
[Accessor] _info : string;
- [Accessor] _overloads : array[IMember];
+ [Accessor] _overloads : SCG.IList[Elem];
- public this (name : string, node : NamespaceTree.Node)
+ public Description : string
{
- node.EnsureCached();
- _displayName = name;
- _info = "";
-
- match (node.Value) // : NamespaceTree.TypeInfoCache
+ get
{
- // TypeInfo loaded or parsed
- | Cached(ty) =>
- def typeDecl = ty.GetTydecl();
- _glyphType = GlyphIndexFromTypeDecl(typeDecl) :> int;
- _info = GetTypeKindName(typeDecl);
-
- // ambiguous TypeInfo loaded or parsed
- | CachedAmbiguous(_typeInfos) =>
- _glyphType = GlyphType.Snippet :> int;
- _info = "ambiguous ";
-
- // TypeInfo of external type not yet loaded
- | NotLoaded(extType) => _glyphType = GlyphIndexFromSysType(extType.SystemType);
- | NotLoadedList(_extTypes) => _glyphType = GlyphType.Snippet :> int;
- | NamespaceReference =>
- _glyphType = GlyphType.Namespace :> int;
- _info = "namespace ";
-
- | MacroCall => _glyphType = GlyphType.Macro :> int;
- | No => throw ArgumentException("Tish function can't process nade wich value is No!")
- }
+ def builder = Text.StringBuilder();
- _info += node.GetDisplayName();
+ match (Overloads[0])
+ {
+ | Local => ()
+ | Node => ()
+ | Overload(overload) =>
+ _ = builder.AppendLine(QuickTipInfo.GetDocText(
+ overload.Member).TrimStart('\n', '\r'));
+ | Overloads => assert(false);
}
- GlyphIndexFromSysType(sysType : Type) : int
+ foreach (overload in Overloads)
{
- def result =
- if (sysType.IsInterface) GlyphType.Interface
- else if (sysType.IsEnum ) GlyphType.Enum
- else if (sysType.IsSubclassOf(Const.DelegateType)) GlyphType.Delegate
- else if (IsVariantType(sysType)) GlyphType.Variant
- else if (IsVariantOptionType(sysType)) GlyphType.VariantOption
- else GlyphType.Class;
+ | Local (value) => _ = builder.AppendLine(value.MakeHint());
+ | Node(_, node) => _ = builder.AppendLine(node.MakeHint());
+ | Overload(overload) =>
+ def member = overload.Member;
+ _ = builder.AppendLine(member.ToString());
- result :> int;
+ | Overloads => assert(false);
}
- GetTypeKindName(typeDecl : Typedtree.TypeDeclaration) : string
- {
- | Class => "class "
- | Alias(ty) => "alias: " + GetTypeKindName(ty.TypeInfo.GetTydecl())
- | Interface => "interface "
- | Variant => "variant"
- | VariantOption => "variant option"
- | Enum => "enum "
+ builder.ToString().TrimEnd('\n', '\r')
}
-
- GlyphIndexFromTypeDecl(typeDecl : Typedtree.TypeDeclaration) : GlyphType
- {
- | Class => GlyphType.Class
- | Alias(ty) => GlyphIndexFromTypeDecl(ty.TypeInfo.GetTydecl())
- | Interface => GlyphType.Interface
- | Variant => GlyphType.Variant //{ members : list [TypeInfo]; }
- | VariantOption => GlyphType.VariantOption
- | Enum => GlyphType.Enum
}
public override ToString() : string { _displayName }
-
- public static IsVariantType(sysType : Type) : bool
- {
- sysType.GetCustomAttributes(Const.VariantType, false).Length == 1
- }
-
- public static IsVariantOptionType(sysType : Type) : bool
- {
- sysType.GetCustomAttributes(Const.VariantOptionType, false).Length == 1
- }
}
}
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 Aug 18 04:29:05 2006
@@ -1,14 +1,75 @@
-using Nemerle.Compiler;
using System.Diagnostics;
using System.Reflection;
+using Nemerle.Assertions;
+using Nemerle.Compiler;
using Nemerle.Completion2;
-using Nemerle.Utility;
using Nemerle.Imperative;
+using System;
+using Nemerle.Utility;
namespace Nemerle.Compiler.Utils
{
public module Utils
{
+ public IsNullOrEmpty1(this value : string) : bool
+ {
+ if (value == null) true else value.Length == 0
+ }
+
+ public IsVariantType(sysType : Type) : bool
+ {
+ sysType.GetCustomAttributes(Const.VariantType, false).Length == 1
+ }
+
+ public IsVariantOptionType(sysType : Type) : bool
+ {
+ sysType.GetCustomAttributes(Const.VariantOptionType, false).Length == 1
+ }
+
+ public GetGlyphIndex(this typeInfoCache : NamespaceTree.TypeInfoCache) : GlyphType
+ {
+ // TypeInfo loaded or parsed
+ | Cached(ty) => ty.GetTydecl().GetGlyphIndex()
+ // ambiguous TypeInfo loaded or parsed
+ | CachedAmbiguous => GlyphType.Snippet
+ // TypeInfo of external type not yet loaded
+ | NotLoaded(extType) => extType.SystemType.GetGlyphIndex()
+ | NotLoadedList(_extTypes) => GlyphType.Snippet
+ | NamespaceReference => GlyphType.Namespace
+ | MacroCall => GlyphType.Macro
+ | No => GlyphType.Snippet
+ }
+
+ public GetGlyphIndex(this sysType : Type) : GlyphType
+ {
+ if (sysType.IsInterface) GlyphType.Interface
+ else if (sysType.IsEnum ) GlyphType.Enum
+ else if (sysType.IsSubclassOf(Const.DelegateType)) GlyphType.Delegate
+ else if (IsVariantType(sysType)) GlyphType.Variant
+ else if (IsVariantOptionType(sysType)) GlyphType.VariantOption
+ else GlyphType.Class;
+ }
+
+ public GetGlyphIndex(this typeDecl : Typedtree.TypeDeclaration) : GlyphType
+ {
+ | Class => GlyphType.Class
+ | Alias(ty) => ty.TypeInfo.GetTydecl().GetGlyphIndex()
+ | Interface => GlyphType.Interface
+ | Variant => GlyphType.Variant //{ members : list [TypeInfo]; }
+ | VariantOption => GlyphType.VariantOption
+ | Enum => GlyphType.Enum
+ }
+
+ public GetTypeKindName(this typeDecl : Typedtree.TypeDeclaration) : string
+ {
+ | Class => "class "
+ | Alias(ty) => "alias: " + GetTypeKindName(ty.TypeInfo.GetTydecl())
+ | Interface => "interface "
+ | Variant => "variant"
+ | VariantOption => "variant option"
+ | Enum => "enum "
+ }
+
public static ToMethodDefinitionString(this t : TyVar) : string
{
| MType.Fun(parms, to) =>
@@ -103,7 +164,8 @@
| Method(method) => // IMethod
match (method.GetFunKind())
{
- | Method | BoundMethod | Function => GlyphType.Function
+ | Method | BoundMethod => GlyphType.Method
+ | Function => GlyphType.Method
| Constructor | StaticConstructor => GlyphType.Class
}
@@ -276,6 +338,7 @@
}
public Intersect(this l1 : Location, l2 : Location) : Location
+ requires l1.FileIndex == l2.FileIndex || l1.FileIndex == 0 || l2.FileIndex == 0
{
mutable lbeg;
mutable cbeg;
Modified: vs-plugin/trunk/Nemerle.VsIntegration/NemerleDeclarations.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/NemerleDeclarations.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/NemerleDeclarations.cs Fri Aug 18 04:29:05 2006
@@ -43,43 +43,9 @@
return _overloadPossibility[index].DisplayName;
}
- string GetDeclaration(IMember member)
- {
- string decl = member.ToString();
- const string methodPrefix = "method ";
-
- if (decl.StartsWith(methodPrefix))
- return decl.Substring(methodPrefix.Length);
-
- return decl;
- }
-
public override string GetDescription(int index)
{
- CompletionElem completionElem = _overloadPossibility[index];
-
- // return completionElem.Info if it contain data
- if (!string.IsNullOrEmpty(completionElem.Info))
- return completionElem.Info;
-
- // otherwise if completionElem.Overloads cantain data use it's
- // textul representation.
- if (completionElem.Overloads != null)
- {
- StringBuilder builder = new StringBuilder();
-
- foreach (IMember member in completionElem.Overloads)
- builder.AppendLine(member.ToString());
-
- builder.Replace('`', '\'');
-
- if (builder.Length > 0)
- builder.Length -= Environment.NewLine.Length;
-
- return builder.ToString();
- }
-
- return "No information for this item :(";
+ return _overloadPossibility[index].Description;
}
public override string GetName(int index)
@@ -89,11 +55,7 @@
public override int GetGlyph(int index)
{
- CompletionElem completionElem = _overloadPossibility[index] as CompletionElem;
- if (completionElem != null)
- return completionElem.GlyphType;
-
- return (int)GlyphType.Snippet;
+ return _overloadPossibility[index].GlyphType;
}
class ByNameComparer : IComparer<CompletionElem>
More information about the svn
mailing list