diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java index 9f95e9dd3fc..c829a0f9f6c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java @@ -3576,13 +3576,17 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi }; SelectionListenerWithASTManager.getDefault().addListener(this, fPostSelectionListenerWithAST); if (forceUpdate && getSelectionProvider() != null) { - fForcedMarkOccurrencesSelection= getSelectionProvider().getSelection(); - ASTProvider.getASTProvider().runOnAST(getInputCElement(), ASTProvider.WAIT_NO, getProgressMonitor(), new ASTRunnable() { - @Override - public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException { - updateOccurrenceAnnotations((ITextSelection) fForcedMarkOccurrencesSelection, ast); - return Status.OK_STATUS; - }}); + ICElement inputCElement = getInputCElement(); + if (inputCElement instanceof ITranslationUnit) { + fForcedMarkOccurrencesSelection= getSelectionProvider().getSelection(); + ASTProvider.getASTProvider().runOnAST(inputCElement, ASTProvider.WAIT_NO, getProgressMonitor(), new ASTRunnable() { + @Override + public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException { + updateOccurrenceAnnotations((ITextSelection) fForcedMarkOccurrencesSelection, ast); + return Status.OK_STATUS; + } + }); + } } if (fOccurrencesFinderJobCanceler == null) {