Assuming you know the file's URL:
IWorkbenchPage page = activeWorkbenchPage();
if (page == null) {
throw new RuntimeException();
}
IFile file;
IFile[] files = ResourcesPlugin.getWorkspace().getRoot()
.findFilesForLocationURI(url.toURI());
file = files[0];
IMarker marker;
marker = file.createMarker(IMarker.TEXT);
HashMap<String, Object> map = new HashMap<String, Object>();
map.put(IMarker.LINE_NUMBER, lineNumber);
marker.setAttributes(map);
IDE.openEditor(page, marker);
marker.delete();
Of course you will need to catch/throw a couple of Exceptions as well, but I omitted this here for simplicity.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…