mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 09:46:02 +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);
|
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}
|
// {CompletionTest.h}
|
||||||
// class C1;
|
// class C1;
|
||||||
// class C2;
|
// class C2;
|
||||||
|
|
|
@ -1590,6 +1590,19 @@ public class CompletionTests extends CompletionTestBase {
|
||||||
assertCompletionResults(fCursorOffset, expectedDisplay, DISPLAY);
|
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 {
|
// struct A {
|
||||||
// void foo();
|
// void foo();
|
||||||
// };
|
// };
|
||||||
|
|
|
@ -703,10 +703,10 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
|
||||||
// The ParameterGuessingProposal will be active if the function accepts parameters and the content
|
// 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
|
// assist is invoked before typing any parameters. Otherwise, the normal parameter hint proposal will
|
||||||
// be added.
|
// be added.
|
||||||
if (canBeCall && function.getParameters() != null && function.getParameters().length != 0
|
if (fGuessArguments && canBeCall && function.getParameters() != null
|
||||||
&& isBeforeParameters(cContext)) {
|
&& function.getParameters().length != 0 && isBeforeParameters(cContext)) {
|
||||||
proposals.add(ParameterGuessingProposal.createProposal(cContext, fAvailableElements, proposal,
|
proposals.add(ParameterGuessingProposal.createProposal(cContext, fAvailableElements, proposal,
|
||||||
function, fPrefix, fGuessArguments));
|
function, fPrefix));
|
||||||
} else {
|
} else {
|
||||||
proposals.add(proposal);
|
proposals.add(proposal);
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,11 +77,10 @@ public class ParameterGuessingProposal extends FunctionCompletionProposal {
|
||||||
private char[][] fParametersNames;
|
private char[][] fParametersNames;
|
||||||
private IType[] fParametersTypes;
|
private IType[] fParametersTypes;
|
||||||
private List<IBinding> fAssignableElements;
|
private List<IBinding> fAssignableElements;
|
||||||
private final boolean fGuessArguments;
|
|
||||||
|
|
||||||
public static ParameterGuessingProposal createProposal(CContentAssistInvocationContext context,
|
public static ParameterGuessingProposal createProposal(CContentAssistInvocationContext context,
|
||||||
List<IBinding> availableElements, CCompletionProposal proposal, IFunction function,
|
List<IBinding> availableElements, CCompletionProposal proposal, IFunction function,
|
||||||
String prefix, boolean guessArguments) {
|
String prefix) {
|
||||||
String replacement = getParametersList(function);
|
String replacement = getParametersList(function);
|
||||||
String fullPrefix = function.getName() + "("; //$NON-NLS-1$
|
String fullPrefix = function.getName() + "("; //$NON-NLS-1$
|
||||||
int replacementOffset = proposal.getReplacementOffset();
|
int replacementOffset = proposal.getReplacementOffset();
|
||||||
|
@ -118,7 +117,7 @@ public class ParameterGuessingProposal extends FunctionCompletionProposal {
|
||||||
ParameterGuessingProposal ret = new ParameterGuessingProposal(replacement, replacementOffset,
|
ParameterGuessingProposal ret = new ParameterGuessingProposal(replacement, replacementOffset,
|
||||||
replacementLength, proposal.getImage(), proposal.getDisplayString(), proposal.getIdString(),
|
replacementLength, proposal.getImage(), proposal.getDisplayString(), proposal.getIdString(),
|
||||||
proposal.getRelevance(), context.getViewer(), function, invocationOffset, parseOffset,
|
proposal.getRelevance(), context.getViewer(), function, invocationOffset, parseOffset,
|
||||||
context.getTranslationUnit(), document, guessArguments);
|
context.getTranslationUnit(), document);
|
||||||
ret.setContextInformation(proposal.getContextInformation());
|
ret.setContextInformation(proposal.getContextInformation());
|
||||||
ret.fFullPrefix = fullPrefix;
|
ret.fFullPrefix = fullPrefix;
|
||||||
ret.fCEditor = getCEditor(context.getEditor());
|
ret.fCEditor = getCEditor(context.getEditor());
|
||||||
|
@ -147,10 +146,9 @@ public class ParameterGuessingProposal extends FunctionCompletionProposal {
|
||||||
public ParameterGuessingProposal(String replacementString, int replacementOffset, int replacementLength,
|
public ParameterGuessingProposal(String replacementString, int replacementOffset, int replacementLength,
|
||||||
Image image, String displayString, String idString, int relevance, ITextViewer viewer,
|
Image image, String displayString, String idString, int relevance, ITextViewer viewer,
|
||||||
IFunction function, int invocationOffset, int parseOffset, ITranslationUnit tu,
|
IFunction function, int invocationOffset, int parseOffset, ITranslationUnit tu,
|
||||||
IDocument document, boolean guessArguments) {
|
IDocument document) {
|
||||||
super(replacementString, replacementOffset, replacementLength, image, displayString, idString,
|
super(replacementString, replacementOffset, replacementLength, image, displayString, idString,
|
||||||
relevance, viewer, function, invocationOffset, parseOffset, tu, document);
|
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) {
|
public void apply(final IDocument document, char trigger, int offset) {
|
||||||
super.apply(document, trigger, offset);
|
super.apply(document, trigger, offset);
|
||||||
|
|
||||||
if (fGuessArguments) {
|
generateParameterGuesses();
|
||||||
generateParameterGuesses();
|
|
||||||
}
|
|
||||||
|
|
||||||
int baseOffset = getReplacementOffset();
|
int baseOffset = getReplacementOffset();
|
||||||
String replacement = getReplacementString();
|
String replacement = getReplacementString();
|
||||||
|
|
Loading…
Add table
Reference in a new issue