public IResource getResource() { Object adapter = getEditorInput().getAdapter(IResource.class); if (adapter != null) { return (IResource) adapter; } return null; }
protected URI getResourceURI(XtextEditor editor) { IEditorInput editorInput = editor.getEditorInput(); if (editorInput instanceof IStorageEditorInput) { try { return storage2UriMapper.getUri(((IStorageEditorInput) editorInput).getStorage()); } catch (CoreException e) { LOG.error("Error getting URI for storage", e); } } return null; }
protected IAnnotationModel getAnnotationModel(XtextEditor editor) { if(editor != null) { IEditorInput editorInput = editor.getEditorInput(); if(editorInput != null) { IDocumentProvider documentProvider = editor.getDocumentProvider(); if(documentProvider != null) { return documentProvider.getAnnotationModel(editorInput); } } } return null; }
@SuppressWarnings("rawtypes") private Annotation getAnnotation(final int offset, final int length) { final IAnnotationModel model = getDocumentProvider().getAnnotationModel(getEditorInput()); if (model == null) return null; Iterator iterator; if (model instanceof IAnnotationModelExtension2) { iterator = ((IAnnotationModelExtension2) model).getAnnotationIterator(offset, length, true, true); } else { iterator = model.getAnnotationIterator(); } while (iterator.hasNext()) { final Annotation a = (Annotation) iterator.next(); final Position p = model.getPosition(a); if (p != null && p.overlapsWith(offset, length)) return a; } return null; }
final IResource res = breakpointUtil.getBreakpointResource(xtextEditor.getEditorInput()); final URI uri = breakpointUtil.getBreakpointURI(xtextEditor.getEditorInput()); final int offset = ((TextSelection) selection).getOffset(); final int line = xtextEditor.getDocument().getLineOfOffset(offset) + 1;
public IMarkerResolution[] getResolutions(IMarker marker) { final IMarkerResolution[] emptyResult = new IMarkerResolution[0]; try { if(!marker.isSubtypeOf(MarkerTypes.ANY_VALIDATION)) return emptyResult; } catch (CoreException e) { return emptyResult; } if(!languageResourceHelper.isLanguageResource(marker.getResource())) { return emptyResult; } XtextEditor editor = getEditor(marker.getResource()); if(editor == null) return emptyResult; IAnnotationModel annotationModel = editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput()); if(annotationModel != null && !isMarkerStillValid(marker, annotationModel)) return emptyResult; final Iterable<IssueResolution> resolutions = getResolutions(getIssueUtil().createIssue(marker), editor.getDocument()); return getAdaptedResolutions(Lists.newArrayList(resolutions)); }