[svn] r6910: vs-plugin/trunk: Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n Nemerle....

pbludov svnadmin at nemerle.org
Thu Nov 16 06:34:02 CET 2006


Log:
Fixes for generic types & abstract methods.

Author: pbludov
Date: Thu Nov 16 06:33:58 2006
New Revision: 6910

Modified:
   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/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	Thu Nov 16 06:33:58 2006
@@ -145,6 +145,12 @@
         {
           if (ast.header.ret_type.Location.Contains(line, col))
             checkType(ast.header.ret_type, method.ReturnType);
+          else if (ast.modifiers.custom_attrs.Contains(line, col))
+          {
+            // PB06116: TODO: CustomAttributes
+            //
+            (Location.Default, null, null)
+          }
           else
           {
             def parms = ast.header.parms;

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 Nov 16 06:33:58 2006
@@ -184,8 +184,9 @@
     {
       def isType = member is System.Type && Attribute.GetCustomAttribute(member, typeof(Nemerle.Internal.VariantOptionAttribute)) == null;
       def ty = if (isType) member :> System.Type else member.DeclaringType;
+      def fullName = ty.FullName.Split('`')[0];
 
-      def typeBuilder = Array.Find(NamespaceTree.GetTypeBuilders(), (p) => p.FullName == ty.FullName);
+      def typeBuilder = Array.Find(NamespaceTree.GetTypeBuilders(), p => p.FullName == fullName);
       if (typeBuilder != null)
       {
         def lst = 

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	Thu Nov 16 06:33:58 2006
@@ -324,6 +324,15 @@
         false
     }
 
+    public Contains[a'](this lst : list[a'], testLine : int, testCol : int) : bool
+      where a' : Located
+    {
+      if (lst.IsEmpty)
+        false
+      else
+        (lst.Head.Location + lst.Last.Location).Contains(testLine, testCol)
+    }
+
     public Contains(this location : Location, testLine : int, testCol : int)
       : bool
     {

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	Thu Nov 16 06:33:58 2006
@@ -73,7 +73,7 @@
 		#region Constants
 
 		private /*readonly*/ Guid   IID_MetaDataImport = new Guid("7DAC8207-D3AE-4c75-9B67-92801A497D44");
-		private const BindingFlags  AllMethods         = BindingFlags.DeclaredOnly
+		private const BindingFlags  DeclaredMembers    = BindingFlags.DeclaredOnly
 										| BindingFlags.Instance | BindingFlags.Static
 										| BindingFlags.Public | BindingFlags.NonPublic;
 
@@ -181,7 +181,7 @@
 			Debug.Assert(info != null, "LookupLocationsFromPdb lacks required parameter");
 
 			if (info.Member == null || string.IsNullOrEmpty(info.FilePath) || !File.Exists(info.FilePath))
-				return new GotoInfo[0];
+				return null;
 
 			object            unkMetaDataImport;
 			IntPtr            ptrMetaDataImport;
@@ -220,7 +220,16 @@
 			try
 			{
 				if (info.Member is MethodBase)
-					methods.Add((MethodBase)info.Member);
+				{
+					MethodBase mb = (MethodBase)info.Member;
+
+					// Abstract methods does not contain any code.
+					//
+					if (mb.IsAbstract)
+						methods.AddRange(mb.DeclaringType.GetMethods(DeclaredMembers));
+					else
+						methods.Add(mb);
+				}
 				else if (info.Member is PropertyInfo)
 				{
 					PropertyInfo pi = (PropertyInfo)info.Member;
@@ -229,7 +238,7 @@
 				else if (info.Member is FieldInfo)
 				{
 					Type t = info.Member.DeclaringType;
-					methods.AddRange(t.GetMethods(AllMethods));
+					methods.AddRange(t.GetMethods(DeclaredMembers));
 				}
 				else if (info.Member is EventInfo)
 				{
@@ -242,7 +251,7 @@
 				else if (info.Member is Type)
 				{
 					Type t = (Type)info.Member;
-					methods.AddRange(t.GetMethods(AllMethods));
+					methods.AddRange(t.GetMethods(DeclaredMembers));
 				}
 				else
 					Trace.Fail("Unexpected MemberInfo " + info.Member.GetType().FullName);
@@ -279,7 +288,7 @@
 			}
 			catch (COMException ex)
 			{
-				// The file was not found or line numbers were stripped from pdb.
+				// The file was not found or source locations were stripped from the pdb.
 				//
 				Trace.WriteLineIf(TS.TraceError,
 					string.Format("{0}, code 0x{1:8X}", ex.Message, ex.ErrorCode), TS.DisplayName);
@@ -290,7 +299,12 @@
 					Marshal.Release(ptrMetaDataImport);
 			}
 
-			// In case of a Method we already succeeded
+			// No sources were found
+			//
+			if (infos.Count == 0)
+				return null;
+
+			// In case of a Method we already succeeded.
 			//
 			if (info.Member is MethodBase)
 			{
@@ -302,6 +316,8 @@
 			{
 				// Quickly compile and find the _exact_ location(s)
 				//
+				try
+				{
 				Nemerle.Completion2.ProjectManager pm = new Nemerle.Completion2.ProjectManager();
 				Nemerle.Completion2.Engine         e  = new Nemerle.Completion2.Engine(pm, new TraceWriter());
 
@@ -310,7 +326,20 @@
 				foreach (GotoInfo gi in infos)
 					e.Sources.AddOrUpdate(gi.FilePath, File.ReadAllText(gi.FilePath));
 
-				return e.Project.GetGotoInfo(info.Member);
+					GotoInfo[] exactInfo = e.Project.GetGotoInfo(info.Member);
+
+					if (null != exactInfo && exactInfo.Length > 0)
+						return exactInfo;
+				}
+				catch (Exception ex)
+				{
+					// This is definitelly unreachable, but since we have a backup route, it make sence.
+					//
+					Trace.WriteLineIf(TS.TraceError,
+						string.Format("({0}) {1}", info.Member.Name, ex.Message), TS.DisplayName);
+				}
+
+				// Fall through to backup route
 			}
 
 			return infos.ToArray();



More information about the svn mailing list