Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2017-01-19 02:18:24 -0500
committerNathan Ridge2017-02-01 11:57:04 -0500
commitcbe8e1f3cfb2f5782eea075fc26d993b3139dc8c (patch)
treeecc114e8c9b23c3865c3cbf123b379c2a2d89509
parent759a5d9a8e7123a0469ba912a0dc5adb8f185612 (diff)
downloadorg.eclipse.cdt-cbe8e1f3cfb2f5782eea075fc26d993b3139dc8c.tar.gz
org.eclipse.cdt-cbe8e1f3cfb2f5782eea075fc26d993b3139dc8c.tar.xz
org.eclipse.cdt-cbe8e1f3cfb2f5782eea075fc26d993b3139dc8c.zip
Bug 497190 - Do not use ParameterGuessingProposal at all when parameter guessing is disabled
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTestBase.java5
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java13
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParameterGuessingProposal.java12
4 files changed, 25 insertions, 11 deletions
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTestBase.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTestBase.java
index a8613f22ff..1281285b59 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTestBase.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTestBase.java
@@ -98,6 +98,11 @@ public class CompletionTestBase extends AbstractContentAssistTest {
preferenceStore.setValue(ContentAssistPreference.DEFAULT_ARGUMENT_DISPLAY_PARAMETERS_WITH_DEFAULT_ARGUMENT, value);
}
+ protected static void enableParameterGuessing(boolean value) {
+ IPreferenceStore preferenceStore = getPreferenceStore();
+ preferenceStore.setValue(ContentAssistPreference.GUESS_ARGUMENTS, value);
+ }
+
// {CompletionTest.h}
// class C1;
// class C2;
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java
index cc64d398d4..a7d8ee440b 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java
@@ -1521,6 +1521,19 @@ public class CompletionTests extends CompletionTestBase {
assertContentAssistResults(fCursorOffset, expectedDisplay, true, DISPLAY);
}
+ // void foo(int x, int y);
+ // void caller() {
+ // foo/*cursor*/
+ // }
+ public void testFunctionWithNoParameterGuesses_497190() throws Exception {
+ try {
+ enableParameterGuessing(false);
+ assertCompletionResults(new String[] { "foo()" });
+ } finally {
+ enableParameterGuessing(true);
+ }
+ }
+
// struct A {
// void foo();
// };
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java
index cd0be417b6..e656e4205c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java
@@ -644,10 +644,10 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
// The ParameterGuessingProposal will be active if the function accepts parameters and the content
// assist is invoked before typing any parameters. Otherwise, the normal parameter hint proposal will
// be added.
- if (!inUsingDeclaration && function.getParameters() != null && function.getParameters().length != 0
- && isBeforeParameters(context)) {
+ if (fGuessArguments && !inUsingDeclaration && function.getParameters() != null
+ && function.getParameters().length != 0 && isBeforeParameters(context)) {
proposals.add(ParameterGuessingProposal.createProposal(context, fAvailableElements, proposal,
- function, fPrefix, fGuessArguments));
+ function, fPrefix));
} else {
proposals.add(proposal);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParameterGuessingProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParameterGuessingProposal.java
index 1817b5e7f9..07112a2116 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParameterGuessingProposal.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParameterGuessingProposal.java
@@ -77,11 +77,10 @@ public class ParameterGuessingProposal extends FunctionCompletionProposal {
private char[][] fParametersNames;
private IType[] fParametersTypes;
private List<IBinding> fAssignableElements;
- private final boolean fGuessArguments;
public static ParameterGuessingProposal createProposal(CContentAssistInvocationContext context,
List<IBinding> availableElements, CCompletionProposal proposal, IFunction function,
- String prefix, boolean guessArguments) {
+ String prefix) {
String replacement = getParametersList(function);
String fullPrefix = function.getName() + "("; //$NON-NLS-1$
int replacementOffset = proposal.getReplacementOffset();
@@ -118,7 +117,7 @@ public class ParameterGuessingProposal extends FunctionCompletionProposal {
ParameterGuessingProposal ret = new ParameterGuessingProposal(replacement, replacementOffset,
replacementLength, proposal.getImage(), proposal.getDisplayString(), proposal.getIdString(),
proposal.getRelevance(), context.getViewer(), function, invocationOffset, parseOffset,
- context.getTranslationUnit(), document, guessArguments);
+ context.getTranslationUnit(), document);
ret.setContextInformation(proposal.getContextInformation());
ret.fFullPrefix = fullPrefix;
ret.fCEditor = getCEditor(context.getEditor());
@@ -147,10 +146,9 @@ public class ParameterGuessingProposal extends FunctionCompletionProposal {
public ParameterGuessingProposal(String replacementString, int replacementOffset, int replacementLength,
Image image, String displayString, String idString, int relevance, ITextViewer viewer,
IFunction function, int invocationOffset, int parseOffset, ITranslationUnit tu,
- IDocument document, boolean guessArguments) {
+ IDocument document) {
super(replacementString, replacementOffset, replacementLength, image, displayString, idString,
relevance, viewer, function, invocationOffset, parseOffset, tu, document);
- this.fGuessArguments = guessArguments;
}
/**
@@ -175,9 +173,7 @@ public class ParameterGuessingProposal extends FunctionCompletionProposal {
public void apply(final IDocument document, char trigger, int offset) {
super.apply(document, trigger, offset);
- if (fGuessArguments) {
- generateParameterGuesses();
- }
+ generateParameterGuesses();
int baseOffset = getReplacementOffset();
String replacement = getReplacementString();

Back to the top