Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 51836253af..6c1afa589c 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
@@ -90,6 +90,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 0a8e7b7c24..bbf6ab8a1b 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
@@ -1590,6 +1590,19 @@ public class CompletionTests extends CompletionTestBase {
assertCompletionResults(fCursorOffset, expectedDisplay, 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 b4b55fad94..56856446a9 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
@@ -703,10 +703,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 (canBeCall && function.getParameters() != null && function.getParameters().length != 0
- && isBeforeParameters(cContext)) {
+ if (fGuessArguments && canBeCall && function.getParameters() != null
+ && function.getParameters().length != 0 && isBeforeParameters(cContext)) {
proposals.add(ParameterGuessingProposal.createProposal(cContext, 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