Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 355349 - XtextEditor IAdaptable.getAdapter() is not precise enough
Summary: XtextEditor IAdaptable.getAdapter() is not precise enough
Status: CLOSED WORKSFORME
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-22 05:03 EDT by Balazs Varnai CLA
Modified: 2012-11-23 02:54 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.