[svn] r6546: vs-plugin/trunk: Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Namespace.n Nem...

VladD2 svnadmin at nemerle.org
Thu Aug 17 14:48:22 CEST 2006


Log:
1. Completion list now represent by array[CompletionElem].
2. Fix icons showing when complete empty using directive.

Author: VladD2
Date: Thu Aug 17 14:48:09 2006
New Revision: 6546

Modified:
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Namespace.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.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/Project.overload.n
   vs-plugin/trunk/Nemerle.VsIntegration/Engine/ProjectInfo.cs
   vs-plugin/trunk/Nemerle.VsIntegration/NemerleDeclarations.cs
   vs-plugin/trunk/Nemerle.VsIntegration/NemerleLanguage.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Parsing/NemerleAuthoringScope.cs

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Namespace.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Namespace.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Namespace.n	Thu Aug 17 14:48:09 2006
@@ -12,7 +12,7 @@
 	public partial class Project
 	{
     CompleteInNamespace(_ns : Decl.Namespace, _fileIndex : int, _line : int, _col : int,
-      _getText : GetText) : array[object]
+      _getText : GetText) : array[CompletionElem]
     {
       _topKeywords
     }

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	Thu Aug 17 14:48:09 2006
@@ -17,7 +17,7 @@
 	{
     /// Complete word inside the method.
     CompleteInType(@type : Decl.Type, fileIndex : int, line : int, col : int, 
-      getText : GetText) : array[object]
+      getText : GetText) : array[CompletionElem]
     {
       def typeBuilder = @type.Builder;
       // Find member under cursor
@@ -48,7 +48,7 @@
             else
             {
               Trace.WriteLine($"# RunCompletionEngine() return $(result.ObjectType)");
-              MakeOverloads(result).ToBase();
+              MakeCompletionList(result);
             }
           }
           else

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	Thu Aug 17 14:48:09 2006
@@ -17,7 +17,7 @@
 
     /// Complete word inside the using directive.
     CompleteInUsing(us : Decl.Using, fileIndex : int, line : int, col : int,
-      getText : GetText) : array[object]
+      getText : GetText) : array[CompletionElem]
     {
       def loc = us.Location;
 
@@ -26,8 +26,7 @@
         if (loc.Line == line && col <= loc.Column + UsingLen)
           array(0) // completion on the end of "using" keyword
         else
-          us.BeforeEnv.CurrentNamespace.Children.Keys
-            .ToArrayFiltered(elem => elem != _autoModule).ToBase();
+          GetCompletionElems(us.BeforeEnv.CurrentNamespace, null, false);
       }
       else
       {
@@ -110,9 +109,9 @@
       ns       : NamespaceTree.Node, 
       lastName : string,
       isAlias  : bool
-      ) : array[object]
+      ) : array[CompletionElem]
     {
-      def resalt = SCG.List.[object]();
+      def resalt = SCG.List.[CompletionElem]();
 
       def fitForAliace(typeInfo : NamespaceTree.TypeInfoCache)
       {

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	Thu Aug 17 14:48:09 2006
@@ -26,7 +26,7 @@
       line : int,
       col : int,
       [NotNull] getText : GetText
-      ) : array[object]
+      ) : array[CompletionElem]
     {
       def fileIndex = _compileUnits.GetFileIndex(filePath);
       // Find the declaration under text cursor.
@@ -42,8 +42,29 @@
       }
     }
 
-    static _topKeywords : array[object] = 
-      array["using" : object, "class", "struct", "variant", "namespace", "enum"];
+    static StrsToCompletionElems(
+      strs      : SCG.IEnumerable[string],
+      glyphType : int,
+      info      : string
+      )         : array[CompletionElem]
+    {
+      def ary = SCG.List();
+
+      foreach (name when name != null in strs)
+        ary.Add(CompletionElem(glyphType, name, info, null));
+      
+      ary.ToArray();
+    }
+
+    static this()
+    {
+      def topKeywords = ["using", "class", "struct", 
+                         "variant", "namespace", "enum"];
+      _topKeywords = StrsToCompletionElems(topKeywords, 
+        GlyphType.Snippet :> int, "snippet or top level keyword");
+    }
+
+    static _topKeywords : array[CompletionElem];
 
     static _autoModule = "_N_AutoModule";
 

Modified: 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.overload.n	Thu Aug 17 14:48:09 2006
@@ -13,8 +13,7 @@
 {
 	public partial class Project
 	{
-    public static MakeOverloads(result : CompletionResult)
-      : array[object]
+    public static MakeCompletionList(result : CompletionResult) : array[CompletionElem]
     {
       def IsPropertyAccessor(name)
       {

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Engine/ProjectInfo.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Engine/ProjectInfo.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Engine/ProjectInfo.cs	Thu Aug 17 14:48:09 2006
@@ -178,7 +178,7 @@
 			return null;
 		}
 
-		internal object[] CompleteWord(
+		internal CompletionElem[] CompleteWord(
 			string filePath, int line, int col, GetText getText)
 		{
 			Project project = Engine.GetProject();

Modified: vs-plugin/trunk/Nemerle.VsIntegration/NemerleDeclarations.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/NemerleDeclarations.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/NemerleDeclarations.cs	Thu Aug 17 14:48:09 2006
@@ -23,24 +23,13 @@
 {
 	public class NemerleDeclarations : Declarations
 	{
-		readonly object[] _overloadPossibility;
+		readonly CompletionElem[] _overloadPossibility;
 
-		public NemerleDeclarations(object[] overloadPossibility)
+		public NemerleDeclarations(CompletionElem[] overloadPossibility)
 		{
 			_overloadPossibility = overloadPossibility;
 			Sort();
 		}
-		//List<Declaration> declarations;
-		//private LanguageService languageService;
-		//private TextSpan commitSpan;
-
-		//public NemerleDeclarations(IList<Declaration> declarations, 
-		//  LanguageService langService)
-		//  : base()
-		//{
-		//  this.declarations = new List<Declaration>(declarations);
-		//  languageService = langService;
-		//}
 
 		// Disable the "UsePropertiesWhereAppropriate" warning.
 		[SuppressMessage("Microsoft.Design", "CA1024")]
@@ -51,50 +40,24 @@
 
 		public override string GetDisplayText(int index)
 		{
-			string str = _overloadPossibility[index] as string;
-			if (str != null)
-				return str;
-
-			CompletionElem completionElem = _overloadPossibility[index] as CompletionElem;
-			if (completionElem != null)
-				return completionElem.DisplayName;
-
-			return "<error>";
+			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 GetName(int index)
-		{
-			return GetName(_overloadPossibility[index]);
-		}
-
-		private static string GetName(object elem)
-		{
-			string str = elem as string;
-			if (str != null)
-				return str;
-
-			CompletionElem completionElem = elem as CompletionElem;
-			if (completionElem != null)
-				return completionElem.DisplayName;
-
-			return "<error>";
-		}
-
 		public override string GetDescription(int index)
 		{
-			CompletionElem completionElem = _overloadPossibility[index] as CompletionElem;
-			if (completionElem != null) // if item is CompletionElem
-			{
+			CompletionElem completionElem = _overloadPossibility[index];
+
 				// return completionElem.Info if it contain data
 				if (!string.IsNullOrEmpty(completionElem.Info))
 					return completionElem.Info;
@@ -115,11 +78,14 @@
 
 					return builder.ToString();
 				}
-			}
 
-			return "No information for this item :(.";
+			return "No information for this item :(";
 		}
 
+		public override string GetName(int index)
+		{
+			return _overloadPossibility[index].DisplayName;
+		}
 
 		public override int GetGlyph(int index)
 		{
@@ -130,12 +96,13 @@
 			return (int)GlyphType.Snippet;
 		}
 
-		class ByNameComparer : IComparer<object>
+		class ByNameComparer : IComparer<CompletionElem>
 		{
 			public static readonly ByNameComparer Instace = new ByNameComparer();
-			public int Compare(object x, object y)
+
+			public int Compare(CompletionElem x, CompletionElem y)
 			{
-				return GetName(x).CompareTo(GetName(y));
+				return x.DisplayName.CompareTo(y.DisplayName);
 			}
 		}
 
@@ -144,13 +111,6 @@
 			Array.Sort(_overloadPossibility, ByNameComparer.Instace);
 		}
 
-		//// This method is used to add declarations to the internal list.
-		//public void AddDeclaration(Declaration declaration)
-		//{
-		//  //declarations.Add(declaration);
-		//  throw new NotImplementedException();
-		//}
-
 		// This method is called to get the string to commit to the source buffer.
 		// Note that the initial extent is only what the user has typed so far.
 		// Disable the "ParameterNamesShouldMatchBaseDeclaration" warning.
@@ -164,7 +124,6 @@
 			//commitSpan = initialExtent;
 			return base.OnCommit(textView, textSoFar, commitCharacter, index, 
 				ref initialExtent);
-			//throw new NotImplementedException();
 		}
 
 		// This method is called after the string has been committed to the 

Modified: vs-plugin/trunk/Nemerle.VsIntegration/NemerleLanguage.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/NemerleLanguage.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/NemerleLanguage.cs	Thu Aug 17 14:48:09 2006
@@ -239,7 +239,7 @@
 				return bodyCode;
 			};
 
-			object[] overloads = proj.CompleteWord(
+			CompletionElem[] overloads = proj.CompleteWord(
 				filePath, request.Line, request.Col, getText);
 
 			if (overloads.Length > 0)

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Parsing/NemerleAuthoringScope.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Parsing/NemerleAuthoringScope.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Parsing/NemerleAuthoringScope.cs	Thu Aug 17 14:48:09 2006
@@ -11,7 +11,7 @@
 {
 	class NemerleAuthoringScope : AuthoringScope
 	{
-		public NemerleAuthoringScope(object[] overloadPossibility)
+		public NemerleAuthoringScope(CompletionElem[] overloadPossibility)
 		{
 			_overloadPossibility = overloadPossibility;
 		}
@@ -26,10 +26,10 @@
 
 		public NemerleAuthoringScope()
 		{
-			_overloadPossibility = new object[0];
+			_overloadPossibility = new CompletionElem[0];
 		}
 
-		private object[]    _overloadPossibility;
+		private CompletionElem[] _overloadPossibility;
 		private ProjectInfo _project;
 		private string      _filePath;
 		private GetText     _getText;



More information about the svn mailing list