[svn] r6362: nemerle/trunk/ncc: completion/CodeCompletionEngine.n
testsuite/completion-playground/compl-s2...
trupill
svnadmin at nemerle.org
Fri Jun 2 21:31:47 CEST 2006
Log:
Add GetNameFromType to the engine, to convert from a MType to its string
representation. That kind of code would be impossible to write in C#,
and should be used as an utility in IDEs. Updates testcases.
Author: trupill
Date: Fri Jun 2 21:31:43 2006
New Revision: 6362
Modified:
nemerle/trunk/ncc/completion/CodeCompletionEngine.n
nemerle/trunk/ncc/testsuite/completion-playground/compl-s2.n
nemerle/trunk/ncc/testsuite/completion-playground/compl3.n
Modified: nemerle/trunk/ncc/completion/CodeCompletionEngine.n
==============================================================================
--- nemerle/trunk/ncc/completion/CodeCompletionEngine.n (original)
+++ nemerle/trunk/ncc/completion/CodeCompletionEngine.n Fri Jun 2 21:31:43 2006
@@ -457,6 +457,37 @@
this.NameTree.namespace_tree
}
+
+ public static GetNameFromType (t : MType) : string
+ {
+ | Class as c => mutable name = c.tycon.FrameworkTypeName;
+ when (c.args.Length > 0)
+ {
+ name += "[";
+ foreach (tyvar in c.args)
+ {
+ | x is MType => name += GetNameFromType (x) + ", ";
+ | _ => ();
+ }
+ name = name.Trim(',', ' ') + "]";
+ }
+ name
+
+ | TyVarRef as r => r.tyvar.Name
+ | Fun as f => def name = GetNameFromType (f.from :> MType) + " -> " + GetNameFromType (f.to :> MType); name
+ | Tuple as tuple => mutable name = "(";
+ foreach (tx in tuple.args)
+ {
+ | x is MType => name += GetNameFromType (x) + ", ";
+ | _ => ();
+ }
+ name = name.Trim(',', ' ') + ")";
+ name
+ | Array as a => def name = "array[" + GetNameFromType (a.t :> MType) + "]"; name
+ | Void => "void"
+ | _ => ""
+ }
+
} // end class CodeCompletionEngine
} // end namespace
Modified: nemerle/trunk/ncc/testsuite/completion-playground/compl-s2.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/completion-playground/compl-s2.n (original)
+++ nemerle/trunk/ncc/testsuite/completion-playground/compl-s2.n Fri Jun 2 21:31:43 2006
@@ -6,7 +6,7 @@
namespace Example {
public class SomeClass {
- mutable n : Loc;
+ mutable n : string;
public Foo () : void
{
@@ -25,5 +25,17 @@
}
}
-public class SomeOtherClass {
+public class SomeOtherClass['a] {
+ public class MoreClasses {
+
+ }
+
+ mutable N : Dictionary ['a, string];
+ public T : 'a;
+ public X : 'a -> void;
+}
+
+public variant Seasons {
+| Winter
+| Summer
}
Modified: nemerle/trunk/ncc/testsuite/completion-playground/compl3.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/completion-playground/compl3.n (original)
+++ nemerle/trunk/ncc/testsuite/completion-playground/compl3.n Fri Jun 2 21:31:43 2006
@@ -36,6 +36,15 @@
| Cached as c =>
match (c.tycon) {
| tb is TypeBuilder => System.Console.WriteLine (tb.FrameworkTypeName);
+ foreach (n in tb.GetMembers ())
+ {
+ match (n.GetKind ())
+ {
+ | Field as f => System.Console.WriteLine ("* " + f.field.Name + " : " +
+ Engine.GetNameFromType (f.field.GetMemType ()));
+ | _ => System.Console.WriteLine("* " + n.Name);
+ }
+ }
| _ => ();
}
| _ => ()
More information about the svn
mailing list