1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for 199268: [Editor] Show in Project Explorer fails outside of functions

This commit is contained in:
Anton Leherbauer 2007-09-10 13:05:29 +00:00
parent 04caf0d36f
commit f08b682189
2 changed files with 10 additions and 9 deletions

View file

@ -1047,7 +1047,7 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
*/ */
public boolean show(ShowInContext context) { public boolean show(ShowInContext context) {
ISelection selection= context.getSelection(); ISelection selection= context.getSelection();
if (selection != null) { if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
selectReveal(selection); selectReveal(selection);
return true; return true;
} }

View file

@ -1246,18 +1246,19 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
ICElement ce= null; ICElement ce= null;
try { try {
ce= SelectionConverter.getElementAtOffset(this); ce= SelectionConverter.getElementAtOffset(this);
if (ce instanceof ITranslationUnit) {
ce = null;
}
} catch (CModelException ex) { } catch (CModelException ex) {
ce= null; ce= null;
} }
if (ce != null) { final ISelection selection= ce != null ? new StructuredSelection(ce) : null;
final ISelection selection= new StructuredSelection(ce);
return new IShowInSource() { return new IShowInSource() {
public ShowInContext getShowInContext() { public ShowInContext getShowInContext() {
return new ShowInContext(getEditorInput(), selection); return new ShowInContext(getEditorInput(), selection);
} }
}; };
} }
}
if (ProjectionAnnotationModel.class.equals(required)) { if (ProjectionAnnotationModel.class.equals(required)) {
if (fProjectionSupport != null) { if (fProjectionSupport != null) {
Object adapter = fProjectionSupport.getAdapter(getSourceViewer(), required); Object adapter = fProjectionSupport.getAdapter(getSourceViewer(), required);