Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 355349

Summary: XtextEditor IAdaptable.getAdapter() is not precise enough
Product: [Modeling] TMF Reporter: Balazs Varnai <bvarnai>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: sebastian.zarnekow
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Balazs Varnai CLA 2011-08-22 05:03:55 EDT
Build Identifier: I20110613-1736

IAdaptable implementation in org.eclipse.xtext.ui.editor.XtextEditor should never return something that is not instance of OutlinePage. Check the contract of IAdaptable.getAdapter().

Code sample as in 2.1:

public Object getAdapter(Class adapter) {
if (IContentOutlinePage.class.isAssignableFrom(adapter)) {
return getContentOutlinePage();
}
return super.getAdapter(adapter);
}

In case of multiple parts implementing IContentOutlinePage, actions could fail due to the misleading return of adapt.

My suggestion:

public Object getAdapter(Class adapter) {
  if (org.eclipse.xtext.ui.editor.outline.impl.OutlinePage.class.isAssignableFrom(adapter)) {
     return getContentOutlinePage();
   }
   return super.getAdapter(adapter);
}






Reproducible: Always

Steps to Reproduce:
Integration issue, check code.
Comment 1 Sebastian Zarnekow CLA 2011-09-29 10:46:03 EDT
A patch is welcome.
Comment 2 Sven Efftinge CLA 2012-11-23 02:54:00 EST
If you have multiple parts, and you don't want to have the 'common' outline page returned you would have to subclass and override XtextEditor.getAdapter() anyway, don't you?
Please reopen and explain your scenario in more detail if I missed something.