mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 01:06:01 +02:00
Bug 497190 - Do not use ParameterGuessingProposal at all when parameter guessing is disabled
Change-Id: I9feda3d365eeb935296adbc7144b0f504017f87a
This commit is contained in:
parent
a90caec05e
commit
b332cdaf75
4 changed files with 25 additions and 11 deletions
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
// };
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue