Rav*_*sha 4 eclipse plugins breadcrumbs
我已经创建了一个Eclipse插件,可以在按下快捷键的情况下打印输出对象.我已经能够做到这一点,但我也想在日志中添加当前方法和当前类名.我不确定如何进一步处理.我试图搜索breadcrumb API,但我无法从我的项目中引用该包.我对插件开发很新,有人可以指导我如何实现我的目标.提前致谢.
从Breadcrumb获取这些东西真的很难,你必须使用反射才能得到它.
这是从编辑器获取当前方法的代码.
ITextEditor editor = (ITextEditor) PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage().getActiveEditor();
ITextSelection selection = (ITextSelection) editor
.getSelectionProvider().getSelection();
IEditorInput editorInput = editor.getEditorInput();
IJavaElement elem = JavaUI.getEditorInputJavaElement(editorInput);
if (elem instanceof ICompilationUnit) {
ICompilationUnit unit = (ICompilationUnit) elem;
IJavaElement selected = unit.getElementAt(selection.getOffset());
System.out.println("selected=" + selected);
System.out.println("selected.class=" + selected.getClass());
}Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1025 次 |
| 最近记录: |