mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 02:06:01 +02:00
Bug 534189 - Do not wait for the editor's shared AST to generate parameter guesses
We want to hold the index read lock while generating the guesses, but we don't need an AST; we already have the one built for content assist. Change-Id: I5a60aaca24ce345f5ae387664e025e6fa39cd9d2
This commit is contained in:
parent
4881a2ecd4
commit
3ad16b909c
1 changed files with 7 additions and 6 deletions
|
@ -45,6 +45,7 @@ import org.eclipse.swt.graphics.Point;
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.texteditor.link.EditorLinkedModeUI;
|
import org.eclipse.ui.texteditor.link.EditorLinkedModeUI;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||||
|
@ -78,6 +79,7 @@ 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 IASTCompletionNode fCompletionNode;
|
||||||
|
|
||||||
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,
|
||||||
|
@ -118,7 +120,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);
|
context.getTranslationUnit(), document, context.getCompletionNode());
|
||||||
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,9 +149,10 @@ 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) {
|
IDocument document, IASTCompletionNode completionNode) {
|
||||||
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);
|
||||||
|
fCompletionNode = completionNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -254,14 +257,12 @@ public class ParameterGuessingProposal extends FunctionCompletionProposal {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateParameterGuesses() {
|
public void generateParameterGuesses() {
|
||||||
IStatus status = ASTProvider.getASTProvider().runOnAST(fTranslationUnit, ASTProvider.WAIT_ACTIVE_ONLY,
|
IStatus status = ASTProvider.getASTProvider().runOnAST(fTranslationUnit, ASTProvider.WAIT_NO,
|
||||||
new NullProgressMonitor(), new ASTRunnable() {
|
new NullProgressMonitor(), new ASTRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
|
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
|
||||||
if (astRoot == null)
|
|
||||||
return Status.CANCEL_STATUS;
|
|
||||||
try {
|
try {
|
||||||
CPPSemantics.pushLookupPoint(astRoot);
|
CPPSemantics.pushLookupPoint(fCompletionNode.getTranslationUnit());
|
||||||
guessParameters();
|
guessParameters();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CUIPlugin.log(e);
|
CUIPlugin.log(e);
|
||||||
|
|
Loading…
Add table
Reference in a new issue