Markers are a great feature of Eclipse and there are some great articles on creating Markers. However, I couldn’t find a good article on opening markers in an editor. So, here’s the best call sequence that I could figure out:
IJavaElement element = ...; IEditorInput input = EditorUtility.getEditorInput(element); IEditorPart editor = getSite().getPage().openEditor(input, (input instanceof FileEditorInput) ? : JavaUI.ID_CU_EDITOR : JavaUI.ID_CF_EDITOR); IDE.gotoMarker(editor, sNode.getMarker());
EditorUtility is an internal JDT class, but I couldn’t find a better way of doing this. A check on the return type of the getEditorInput call is necessary to since it can return either a file editor (for compilation units) or a class file editor.









0 Responses to “Opening a Marker in an Eclipse Java Editor”