[svn] r7254: vs-plugin/trunk: Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/MethodTipInfo.n Nemerle...

IT svnadmin at nemerle.org
Fri Jan 12 06:09:26 CET 2007


Log:
MethodTip fixes & improvements.

Author: IT
Date: Fri Jan 12 06:09:21 2007
New Revision: 7254

Modified:
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/MethodTipInfo.n
   vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleSource.cs
   vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleViewFilter.cs

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/MethodTipInfo.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/MethodTipInfo.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/MethodTipInfo.n	Fri Jan 12 06:09:21 2007
@@ -98,7 +98,7 @@
       {
         // TODO: This works incorrectly and should be redone.
         //
-        _defaultMethod = _overloads.FindIndex(o => (o.Member :> IMethod).GetParameters().Length == _nextParameters.Count + 1);
+        _defaultMethod = _overloads.FindIndex(o => (o.Member :> IMethod).GetParameters().Length == _nextParameters.Count);
 
         when (_defaultMethod < 0)
           _defaultMethod = 0;

Modified: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleSource.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleSource.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleSource.cs	Fri Jan 12 06:09:21 2007
@@ -230,35 +230,13 @@
 					this.MatchBraces(textView, line, idx, info);
 				}
 			}
-			//displayed & a trigger found
-			// todo: This means the method tip disappears if you type "ENTER" 
-			// while entering method arguments, which is bad.
-			if ((triggerClass & TokenTriggers.MethodTip) != 0 && _methodData.IsDisplayed)
-			{
-				if ((triggerClass & TokenTriggers.MethodTip) == TokenTriggers.ParameterNext)
-				{
-					//this is an optimization
-					//_methodData.AdjustCurrentParameter((backward && idx > 0) ? -1 : +1);
 
-					// IT: Fucking optimizers.
-					//
-					_methodData.AdjustCurrentParameter(backward? 0: 1);
-				}
-				else
-				{
-					//this is the general case
-					this.MethodTip(textView, line, (backward && idx > 0) ? idx - 1 : idx, info);
-				}
-			}
-			else if ((triggerClass & TokenTriggers.MethodTip) != 0 && (command == VsCommands2K.TYPECHAR) && _service.Preferences.ParameterInformation)
-			{
-				//not displayed & trigger found & character typed & method info enabled
-				this.MethodTip(textView, line, idx, info);
-			}
-			else if (_methodData.IsDisplayed)
+			if (!_methodData.IsDisplayed &&
+				(triggerClass & TokenTriggers.MethodTip) != 0 &&
+				command == VsCommands2K.TYPECHAR &&
+				_service.Preferences.ParameterInformation)
 			{
-				//displayed & complex command
-				this.MethodTip(textView, line, idx, info);
+				MethodTip(textView, line, idx, info);
 			}
 		}
 

Modified: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleViewFilter.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleViewFilter.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleViewFilter.cs	Fri Jan 12 06:09:21 2007
@@ -204,19 +204,28 @@
 			return base.QueryCommandStatus(ref guidCmdGroup, nCmdId);
 		}
 
+		int _startLine;
+		int _startPos;
+
 		public override bool HandlePreExec(
 			ref Guid guidCmdGroup, uint nCmdId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
 		{
+			_startLine = -1;
+
 			if (guidCmdGroup == VSConstants.VSStd2K)
 			{
-				switch (nCmdId)
-				{
-					case (uint)VSConstants.VSStd2KCmdID.FORMATSELECTION:
+				if (Source.MethodData.IsDisplayed)
+					TextView.GetCaretPos(out _startLine, out _startPos);
+
+				VsCommands2K cmd = (VsCommands2K)nCmdId;
+
+				switch (cmd)
 						{
+					case VsCommands2K.FORMATSELECTION:
 							this.ReformatSelection();
 							return true;
-						}
-					case (uint)VSConstants.VSStd2KCmdID.INSERTSNIPPET:
+
+					case VsCommands2K.INSERTSNIPPET:
 						{
 							ExpansionProvider ep = GetExpansionProvider();
 
@@ -225,7 +234,8 @@
 
 							return true; // Handled the command.
 						}
-					case (uint)VSConstants.VSStd2KCmdID.SURROUNDWITH:
+
+					case VsCommands2K.SURROUNDWITH:
 						{
 							ExpansionProvider ep = GetExpansionProvider();
 
@@ -234,6 +244,38 @@
 
 							return true; // Handled the command.
 						}
+
+					case VsCommands2K.UP:
+						if (Source.MethodData.IsDisplayed && Source.MethodData.GetCurMethod() == 0)
+						{
+							int count = Source.MethodData.GetOverloadCount();
+
+							if (count > 1)
+							{
+								while (Source.MethodData.NextMethod() < count - 1) ;
+								Source.MethodData.UpdateView();
+
+								return true;
+							}
+						}
+
+						break;
+
+					case VsCommands2K.DOWN:
+						if (Source.MethodData.IsDisplayed)
+						{
+							int count = Source.MethodData.GetOverloadCount();
+
+							if (count > 1 && Source.MethodData.GetCurMethod() == count - 1)
+							{
+								while (Source.MethodData.PrevMethod() > 0) ;
+								Source.MethodData.UpdateView();
+
+								return true;
+							}
+						}
+
+						break;
 				}
 			}
 			
@@ -245,30 +287,38 @@
 		public override void HandlePostExec(
 			ref Guid guidCmdGroup, uint nCmdId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut, bool bufferWasChanged)
 		{
-			if (guidCmdGroup == typeof(VsCommands2K).GUID)
-			{
-				switch ((VsCommands2K)nCmdId)
+			base.HandlePostExec(ref guidCmdGroup, nCmdId, nCmdexecopt, pvaIn, pvaOut, bufferWasChanged);
+
+			if (_startLine >= 0 && Source.MethodData.IsDisplayed)
 				{
-					case VsCommands2K.PAGEUP:
-					case VsCommands2K.UP:
-					case VsCommands2K.PAGEDN:
-					case VsCommands2K.DOWN:
-						if (Source.MethodData.IsDisplayed)
+				int line;
+				int pos;
+
+				TextView.GetCaretPos(out line, out pos);
+
+				if (line != _startLine || pos != _startPos)
 						{
-							if (Source.MethodData.GetOverloadCount() == 1)
+					VsCommands2K cmd = (VsCommands2K)nCmdId;
+
+					bool backward =
+						cmd == VsCommands2K.BACKSPACE ||
+						cmd == VsCommands2K.BACKTAB   ||
+						cmd == VsCommands2K.LEFT      ||
+						cmd == VsCommands2K.LEFT_EXT;
+
+					TokenInfo     info         = Source.GetTokenInfo(line, pos);
+					TokenTriggers triggerClass = info.Trigger;
+
+					if (!backward && (triggerClass & TokenTriggers.MethodTip) == TokenTriggers.ParameterNext)
 							{
-								Source.DismissCompletor();
+						Source.MethodData.AdjustCurrentParameter(1);
 							}
 							else
 							{
-								
-							}
+						Source.MethodTip(TextView, line, pos, info);
 						}
-						break;
 				}
 			}
-
-			base.HandlePostExec(ref guidCmdGroup, nCmdId, nCmdexecopt, pvaIn, pvaOut, bufferWasChanged);
 		}
 
 		/// <summary>



More information about the svn mailing list