下列片段顯示如何使用 JavaUI,來開啟 Java 編輯器,並顯示 Java 編譯單元的特定成員。
void showMethod(IMember member) { ICompilationUnit cu = member.getCompilationUnit();
IEditorPart javaEditor = JavaUI.openInEditor(cu);
JavaUI.revealInEditor(javaEditor, member);
}
openInEditor 與 revealInEditor
方法亦適用於類別檔,以及適用於類別檔中的成員。