I wrote an IEditorActionDelegate to fire from a context menu on a CompilationUnitEditor. From there I want to create a marker at the start line of the selected text. I have an ITextSelection, and an IEditorPart object. How can I get an IResource from those so that I can call resource.createMarker()?
Thanks
May be you can look at how Eclipse does something similar in its org.eclipse.jdt.internal.ui.javaeditor.EditorUtility
class.
You can see (line 222 and following) it:
final IEditorInput input= editor.getEditorInput();
marker= ((IFileEditorInput)input).getFile().createMarker(IMarker.TEXT);
marker.setAttribute(IMarker.CHAR_START, offset);
marker.setAttribute(IMarker.CHAR_END, offset + length);
With offset
and length
something you should be able to infer from your TextSelection
.