From 4b49083517e1df126faed916dfee0e19ed32d96d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norbert=20Pl=F6tt?= Date: Mon, 6 Mar 2006 09:25:37 +0000 Subject: [PATCH] Save current completion node as field and make available externally. Useful for fixing #129768. --- .../contentassist/CCompletionProcessor2.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProcessor2.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProcessor2.java index c1332b24e4e..95d89b3490d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProcessor2.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProcessor2.java @@ -62,16 +62,17 @@ public class CCompletionProcessor2 implements IContentAssistProcessor { private String noCompletions = assistPrefix + ".noCompletions"; //$NON-NLS-1$ private String parseError = assistPrefix + ".parseError"; //$NON-NLS-1$ private String dialectError = assistPrefix + ".badDialect"; //$NON-NLS-1$ + private ASTCompletionNode fCurrentCompletionNode; public CCompletionProcessor2(IEditorPart editor) { this.editor = editor; + fCurrentCompletionNode = null; } public ICompletionProposal[] computeCompletionProposals(final ITextViewer viewer, int offset) { try { IWorkingCopy workingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput()); - ASTCompletionNode completionNode = null; - String prefix = null; + String prefix = null; IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore(); boolean fileScope = store.getBoolean(ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE); @@ -88,7 +89,7 @@ public class CCompletionProcessor2 implements IContentAssistProcessor { readerFactory = pdom.getCodeReaderFactory(workingCopy); else 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) { IStorage storage = ((ExternalEditorInput)(editor.getEditorInput())).getStorage(); IProject project = workingCopy.getCProject().getProject(); @@ -98,11 +99,11 @@ public class CCompletionProcessor2 implements IContentAssistProcessor { readerFactory = pdom.getCodeReaderFactory(workingCopy); else 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) - prefix = completionNode.getPrefix(); + if (fCurrentCompletionNode != null) + prefix = fCurrentCompletionNode.getPrefix(); } @@ -127,7 +128,7 @@ public class CCompletionProcessor2 implements IContentAssistProcessor { if (!(contribObject instanceof ICompletionContributor)) continue; 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) { } + + /** + * @return the fCurrentCompletionNode + */ + public ASTCompletionNode getCurrentCompletionNode() { + return fCurrentCompletionNode; + } }