mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-20 07:25:23 +02:00
Save current completion node as field and make available externally. Useful for fixing #129768.
This commit is contained in:
parent
7a910a5abb
commit
4b49083517
1 changed files with 15 additions and 7 deletions
|
@ -62,16 +62,17 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
|
||||||
private String noCompletions = assistPrefix + ".noCompletions"; //$NON-NLS-1$
|
private String noCompletions = assistPrefix + ".noCompletions"; //$NON-NLS-1$
|
||||||
private String parseError = assistPrefix + ".parseError"; //$NON-NLS-1$
|
private String parseError = assistPrefix + ".parseError"; //$NON-NLS-1$
|
||||||
private String dialectError = assistPrefix + ".badDialect"; //$NON-NLS-1$
|
private String dialectError = assistPrefix + ".badDialect"; //$NON-NLS-1$
|
||||||
|
private ASTCompletionNode fCurrentCompletionNode;
|
||||||
|
|
||||||
public CCompletionProcessor2(IEditorPart editor) {
|
public CCompletionProcessor2(IEditorPart editor) {
|
||||||
this.editor = editor;
|
this.editor = editor;
|
||||||
|
fCurrentCompletionNode = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICompletionProposal[] computeCompletionProposals(final ITextViewer viewer, int offset) {
|
public ICompletionProposal[] computeCompletionProposals(final ITextViewer viewer, int offset) {
|
||||||
try {
|
try {
|
||||||
IWorkingCopy workingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
|
IWorkingCopy workingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
|
||||||
ASTCompletionNode completionNode = null;
|
String prefix = null;
|
||||||
String prefix = null;
|
|
||||||
|
|
||||||
IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
|
IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
|
||||||
boolean fileScope = store.getBoolean(ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE);
|
boolean fileScope = store.getBoolean(ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE);
|
||||||
|
@ -88,7 +89,7 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
|
||||||
readerFactory = pdom.getCodeReaderFactory(workingCopy);
|
readerFactory = pdom.getCodeReaderFactory(workingCopy);
|
||||||
else
|
else
|
||||||
readerFactory = CDOM.getInstance().getCodeReaderFactory(CDOM.PARSE_WORKING_COPY_WHENEVER_POSSIBLE);
|
readerFactory = CDOM.getInstance().getCodeReaderFactory(CDOM.PARSE_WORKING_COPY_WHENEVER_POSSIBLE);
|
||||||
completionNode = CDOM.getInstance().getCompletionNode(file, offset, readerFactory);
|
fCurrentCompletionNode = CDOM.getInstance().getCompletionNode(file, offset, readerFactory);
|
||||||
} else if (editor.getEditorInput() instanceof ExternalEditorInput) {
|
} else if (editor.getEditorInput() instanceof ExternalEditorInput) {
|
||||||
IStorage storage = ((ExternalEditorInput)(editor.getEditorInput())).getStorage();
|
IStorage storage = ((ExternalEditorInput)(editor.getEditorInput())).getStorage();
|
||||||
IProject project = workingCopy.getCProject().getProject();
|
IProject project = workingCopy.getCProject().getProject();
|
||||||
|
@ -98,11 +99,11 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
|
||||||
readerFactory = pdom.getCodeReaderFactory(workingCopy);
|
readerFactory = pdom.getCodeReaderFactory(workingCopy);
|
||||||
else
|
else
|
||||||
readerFactory = CDOM.getInstance().getCodeReaderFactory(CDOM.PARSE_WORKING_COPY_WHENEVER_POSSIBLE);
|
readerFactory = CDOM.getInstance().getCodeReaderFactory(CDOM.PARSE_WORKING_COPY_WHENEVER_POSSIBLE);
|
||||||
completionNode = CDOM.getInstance().getCompletionNode(storage, project, offset, readerFactory);
|
fCurrentCompletionNode = CDOM.getInstance().getCompletionNode(storage, project, offset, readerFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (completionNode != null)
|
if (fCurrentCompletionNode != null)
|
||||||
prefix = completionNode.getPrefix();
|
prefix = fCurrentCompletionNode.getPrefix();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +128,7 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
|
||||||
if (!(contribObject instanceof ICompletionContributor))
|
if (!(contribObject instanceof ICompletionContributor))
|
||||||
continue;
|
continue;
|
||||||
ICompletionContributor contributor = (ICompletionContributor)contribObject;
|
ICompletionContributor contributor = (ICompletionContributor)contribObject;
|
||||||
contributor.contributeCompletionProposals(viewer, offset, workingCopy, completionNode, prefix, proposals);
|
contributor.contributeCompletionProposals(viewer, offset, workingCopy, fCurrentCompletionNode, prefix, proposals);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,5 +220,12 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
|
||||||
|
|
||||||
public void allowAddingIncludes(boolean allowAddingIncludes) {
|
public void allowAddingIncludes(boolean allowAddingIncludes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the fCurrentCompletionNode
|
||||||
|
*/
|
||||||
|
public ASTCompletionNode getCurrentCompletionNode() {
|
||||||
|
return fCurrentCompletionNode;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue