public String getCurrentEditorContent() { final IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getActiveEditor(); if (!(editor instanceof ITextEditor)) return null; ITextEditor ite = (ITextEditor)editor; IDocument doc = ite.getDocumentProvider().getDocument(ite.getEditorInput()); return doc.get(); }
@Override protected IAnnotationModel getAnnotationModel() { final IDocumentProvider documentProvider= fEditor.getDocumentProvider(); if (documentProvider == null) return null; return documentProvider.getAnnotationModel(fEditor.getEditorInput()); } }
/** * Returns the <code>AbstractMarkerAnnotationModel</code> of the editor's input. * * @return the marker annotation model */ protected AbstractMarkerAnnotationModel getAnnotationModel() { IDocumentProvider provider= fTextEditor.getDocumentProvider(); IAnnotationModel model= provider.getAnnotationModel(fTextEditor.getEditorInput()); if (model instanceof AbstractMarkerAnnotationModel) return (AbstractMarkerAnnotationModel) model; return null; }
/** * Returns the text editor's document. * * @param part the text editor * @return the document of the given text editor */ private IDocument getDocument(ITextEditor part) { IDocumentProvider provider= part.getDocumentProvider(); return provider.getDocument(part.getEditorInput()); }
/** * Returns the text editor's document. * * @param part the text editor * @return the document of the given text editor */ private IDocument getDocument(ITextEditor part) { IDocumentProvider provider= part.getDocumentProvider(); return provider.getDocument(part.getEditorInput()); }
/** * Returns the <code>IDocument</code> of the editor's input. * * @return the document of the editor's input */ protected final IDocument getDocument() { IDocumentProvider provider= fTextEditor.getDocumentProvider(); return provider.getDocument(fTextEditor.getEditorInput()); }
/** * Returns the <code>AbstractMarkerAnnotationModel</code> of the editor's input. * * @return the marker annotation model */ protected AbstractMarkerAnnotationModel getAnnotationModel() { IDocumentProvider provider= fTextEditor.getDocumentProvider(); IAnnotationModel model= provider.getAnnotationModel(fTextEditor.getEditorInput()); if (model instanceof AbstractMarkerAnnotationModel) return (AbstractMarkerAnnotationModel) model; return null; }
/** * Returns the <code>IDocument</code> of the editor's input. * * @return the document of the editor's input */ protected IDocument getDocument() { IDocumentProvider provider= fTextEditor.getDocumentProvider(); return provider.getDocument(fTextEditor.getEditorInput()); }
/** * Returns the <code>IDocument</code> of the editor's input. * * @return the document of the editor's input */ protected IDocument getDocument() { IDocumentProvider provider= fTextEditor.getDocumentProvider(); return provider.getDocument(fTextEditor.getEditorInput()); }
private static IRegion getRegionOfInterest(ITextEditor editor, int invocationLocation) throws BadLocationException { IDocumentProvider documentProvider= editor.getDocumentProvider(); if (documentProvider == null) { return null; } IDocument document= documentProvider.getDocument(editor.getEditorInput()); if (document == null) { return null; } return document.getLineInformationOfOffset(invocationLocation); }
/** * Inserts the given template into the editor. * * @param template the template */ private void insertTemplate(Template template) { IDocument document= fTextEditor.getDocumentProvider().getDocument(fTextEditor.getEditorInput()); insertTemplate(template, document); }
public IAnnotationModel getAnnotationModel(Match match) { IAnnotationModel annoModel = null; ITextEditor textEditor = getTextEditor(); if (textEditor != null) { annoModel = textEditor.getDocumentProvider().getAnnotationModel(textEditor.getEditorInput()); } return annoModel; } };
private static IRegion getRegionOfInterest(ITextEditor editor, int invocationLocation) throws BadLocationException { IDocumentProvider documentProvider= editor.getDocumentProvider(); if (documentProvider == null) { return null; } IDocument document= documentProvider.getDocument(editor.getEditorInput()); if (document == null) { return null; } return document.getLineInformationOfOffset(invocationLocation); }
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IWorkbenchPage activePage = window.getActivePage(); // null check omitted IEditorPart editorPart = activePage.getActiveEditor(); // null check omitted ITextEditor textEditor = (ITextEditor) editorPart; // casting check omitted IDocument currentDocument = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
protected CompilationUnit parseCompilationUnit(ITextEditor editor) throws CoreException { IEditorInput editorInput = editor.getEditorInput(); IDocumentProvider documentProvider = editor.getDocumentProvider(); if (documentProvider == null) { throw new CoreException(Status.CANCEL_STATUS); } IDocument document = documentProvider.getDocument(editorInput); ASTParser parser = ASTParser.newParser(AST.JLS3); parser.setSource(document.get().toCharArray()); return (CompilationUnit) parser.createAST(null); }
/** * Returns the <code>AbstractMarkerAnnotationModel</code> of the editor's input. * * @return the marker annotation model or <code>null</code> if there's none */ protected IAnnotationModel getAnnotationModel() { IDocumentProvider provider= getTextEditor().getDocumentProvider(); return provider.getAnnotationModel(getTextEditor().getEditorInput()); }
/** * Returns the context type ids supported at the current * caret position of the editor. * * @return an array with the the supported context type ids */ private String[] getEditorContextTypeIds() { Point selectedRange=fViewer.getSelectedRange(); int offset= selectedRange.x + selectedRange.y; IDocument document= fTextEditor.getDocumentProvider().getDocument(fTextEditor.getEditorInput()); return getContextTypeIds(document, offset); }
public void update() { ITextEditor editor= getTextEditor(); if (!(editor instanceof AbstractTextEditor)) { setEnabled(false); return; } IAnnotationModel model= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput()); setEnabled(model != null); } }
private void revealLine(ITextEditor editor, int lineNumber) throws BadLocationException { IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput()); IRegion region= document.getLineInformation(lineNumber - 1); editor.selectAndReveal(region.getOffset(), 0); }
/** * Remove the annotation from the document model. */ private void removeAnnotationFromModel(InstructionPointerContext ipc){ IDocumentProvider docProvider = ipc.getEditor().getDocumentProvider(); if (docProvider != null) { IAnnotationModel annotationModel = docProvider.getAnnotationModel(ipc.getEditor().getEditorInput()); if (annotationModel != null) { annotationModel.removeAnnotation(ipc.getAnnotation()); } } }