[autocomplete] 40/143: Fixed autocomplete bug with overloaded functions. Fixed autocomplete bug - capitalization should be corrected when completing a parameterized completion. Internal changes to how RSTALanguageSupport tracks text areas, parsers, and AutoCompletes. Fixed Perl completion support bug when not using params around function completion params. Parsers now specify whether they are "enabled", and if they aren't, they won't parse code in a text area, even if it is installed.

Benjamin Mesing ben at alioth.debian.org
Sat Oct 19 12:53:14 UTC 2013


This is an automated email from the git hooks/post-receive script.

ben pushed a commit to branch master
in repository autocomplete.

commit 54618cda9b9fba84fe74539b584fad4383546b12
Author: bobbylight <robert at fifesoft.com>
Date:   Sat May 22 18:07:39 2010 +0000

    Fixed autocomplete bug with overloaded functions.
    Fixed autocomplete bug - capitalization should be corrected when completing a parameterized completion.
    Internal changes to how RSTALanguageSupport tracks text areas, parsers, and AutoCompletes.
    Fixed Perl completion support bug when not using params around function completion params.
    Parsers now specify whether they are "enabled", and if they aren't, they won't parse code in a text area, even if it is installed.
---
 .../autocomplete/AbstractCompletionProvider.java   |   14 ++++++++-
 src/org/fife/ui/autocomplete/AutoCompletion.java   |   33 +++++++++++++-------
 .../fife/ui/autocomplete/FunctionCompletion.java   |   10 ++++--
 3 files changed, 42 insertions(+), 15 deletions(-)

diff --git a/src/org/fife/ui/autocomplete/AbstractCompletionProvider.java b/src/org/fife/ui/autocomplete/AbstractCompletionProvider.java
index 20fd031..18bf46f 100644
--- a/src/org/fife/ui/autocomplete/AbstractCompletionProvider.java
+++ b/src/org/fife/ui/autocomplete/AbstractCompletionProvider.java
@@ -180,9 +180,21 @@ public abstract class AbstractCompletionProvider
 		if (text!=null) {
 
 			int index = Collections.binarySearch(completions, text, comparator);
-			if (index<0) {
+			if (index<0) { // No exact match
 				index = -index - 1;
 			}
+			else {
+				// If there are several overloads for the function being
+				// completed, Collections.binarySearch() will return the index
+				// of one of those overloads, but we must return all of them,
+				// so search backward until we find the first one.
+				int pos = index - 1;
+				while (pos>0 &&
+						comparator.compare(completions.get(pos), text)==0) {
+					retVal.add(completions.get(pos));
+					pos--;
+				}
+			}
 
 			while (index<completions.size()) {
 				Completion c = (Completion)completions.get(index);
diff --git a/src/org/fife/ui/autocomplete/AutoCompletion.java b/src/org/fife/ui/autocomplete/AutoCompletion.java
index 9c540db..6ff3c5c 100644
--- a/src/org/fife/ui/autocomplete/AutoCompletion.java
+++ b/src/org/fife/ui/autocomplete/AutoCompletion.java
@@ -233,7 +233,8 @@ public class AutoCompletion implements HierarchyListener {
 		// Don't bother with a tooltip if there are no parameters.
 		if (pc.getParamCount()==0) {
 			CompletionProvider p = pc.getProvider();
-			String text = Character.toString(p.getParameterListEnd());
+			char end = p.getParameterListEnd(); // Might be '\0'
+			String text = end=='\0' ? "" : Character.toString(end);
 			if (addParamListStart) {
 				text = p.getParameterListStart() + text;
 			}
@@ -560,8 +561,13 @@ try {
 		installTriggerKey(getTriggerKey());
 
 		// Install the function completion key, if there is one.
+		// NOTE: We cannot do this if the start char is ' ' (e.g. just a space
+		// between the function name and parameters) because it overrides
+		// RSTA's special space action.  It seems KeyStorke.getKeyStroke(' ')
+		// hoses ctrl+space, shift+space, etc., even though I think it
+		// shouldn't...
 		char start = provider.getParameterListStart();
-		if (start!=0) {
+		if (start!=0 && start!=' ') {
 			InputMap im = c.getInputMap();
 			ActionMap am = c.getActionMap();
 			KeyStroke ks = KeyStroke.getKeyStroke(start);
@@ -1017,19 +1023,22 @@ try {
 		}
 
 		public void actionPerformed(ActionEvent e) {
-			hidePopupWindow(); // Prevents keystrokes from messing up
-			textComponent.replaceSelection(start);
-			if (!isParameterAssistanceEnabled()) {
+
+			// Prevents keystrokes from messing up
+			boolean wasVisible = hidePopupWindow();
+
+			// Only proceed if they were selecting a completion
+			if (!wasVisible || !isParameterAssistanceEnabled()) {
+				textComponent.replaceSelection(start);
 				return;
 			}
-			List completions = provider.
-								getParameterizedCompletions(textComponent);
-			if (completions!=null && completions.size()>0) {
-				// TODO: Have tooltip let you select between multiple, like VS
-				ParameterizedCompletion pc =
-								(ParameterizedCompletion)completions.get(0);
-				displayDescriptionToolTip(pc, false);
+
+			Completion c = popupWindow.getSelection();
+			if (c instanceof ParameterizedCompletion) { // Should always be true
+				// Fixes capitalization of the entered text.
+				insertCompletion(c);
 			}
+
 		}
 
 	}
diff --git a/src/org/fife/ui/autocomplete/FunctionCompletion.java b/src/org/fife/ui/autocomplete/FunctionCompletion.java
index 24f1414..8edd19d 100644
--- a/src/org/fife/ui/autocomplete/FunctionCompletion.java
+++ b/src/org/fife/ui/autocomplete/FunctionCompletion.java
@@ -127,7 +127,10 @@ public class FunctionCompletion extends VariableCompletion
 
 		// Add parameters for functions.
 		CompletionProvider provider = getProvider();
-		sb.append(provider.getParameterListStart());
+		char start = provider.getParameterListStart();
+		if (start!=0) {
+			sb.append(start);
+		}
 		for (int i=0; i<getParamCount(); i++) {
 			Parameter param = getParam(i);
 			type = param.getType();
@@ -145,7 +148,10 @@ public class FunctionCompletion extends VariableCompletion
 				sb.append(provider.getParameterListSeparator());
 			}
 		}
-		sb.append(provider.getParameterListEnd());
+		char end = provider.getParameterListEnd();
+		if (end!=0) {
+			sb.append(end);
+		}
 
 		return sb.toString();
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/autocomplete.git



More information about the pkg-java-commits mailing list