The following snippet shows how JavaUI can be used to open a Java editor and display a specific member of a Java compilation unit.
void showMethod(IMember member) { ICompilationUnit cu = member.getCompilationUnit(); IEditorPart javaEditor = JavaUI.openInEditor(cu); JavaUI.revealInEditor(javaEditor, member); }
The methods openInEditor
and revealInEditor
also
work for class files and for members contained in class files.