private IDocument getDocument() { JavaEditor editor= fEditor; if (editor == null) return null; IDocumentProvider provider= editor.getDocumentProvider(); if (provider == null) return null; return provider.getDocument(editor.getEditorInput()); }
private IDocument getDocument() { JavaEditor editor= fEditor; if (editor == null) return null; IDocumentProvider provider= editor.getDocumentProvider(); if (provider == null) return null; return provider.getDocument(editor.getEditorInput()); }
private IDocument getDocument() { JavaEditor editor= fEditor; if (editor == null) return null; IDocumentProvider provider= editor.getDocumentProvider(); if (provider == null) return null; return provider.getDocument(editor.getEditorInput()); }
private IDocument getDocument() { Assert.isTrue(fEditor != null); IDocumentProvider provider= fEditor.getDocumentProvider(); if (provider == null) return null; IDocument document= provider.getDocument(fEditor.getEditorInput()); return document; }
private IDocument getDocument() { Assert.isTrue(fEditor != null); IDocumentProvider provider= fEditor.getDocumentProvider(); if (provider == null) return null; IDocument document= provider.getDocument(fEditor.getEditorInput()); return document; }
private IDocument getDocument() { Assert.isTrue(fEditor != null); IDocumentProvider provider= fEditor.getDocumentProvider(); if (provider == null) return null; IDocument document= provider.getDocument(fEditor.getEditorInput()); return document; }
private static boolean isInJavadoc(JavaEditor editor) { ITextSelection selection= getTextSelection(editor); if (selection == null) return false; IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput()); try { String contentType= TextUtilities.getContentType(document, IJavaPartitions.JAVA_PARTITIONING, selection.getOffset(), true); return contentType.equals(IJavaPartitions.JAVA_DOC); } catch (BadLocationException e) { return false; } }
private static boolean isInJavadoc(JavaEditor editor) { ITextSelection selection= getTextSelection(editor); if (selection == null) return false; IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput()); try { String contentType= TextUtilities.getContentType(document, IJavaPartitions.JAVA_PARTITIONING, selection.getOffset(), true); return contentType.equals(IJavaPartitions.JAVA_DOC); } catch (BadLocationException e) { return false; } }
/** * Returns the annotation overlapping with the given range or <code>null</code>. * * @param offset the region offset * @param length the region length * @return the found annotation or <code>null</code> * @since 3.0 */ private Annotation getAnnotation(int offset, int length) { IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput()); Iterator e= new JavaAnnotationIterator(model, true, false); while (e.hasNext()) { Annotation a= (Annotation) e.next(); Position p= model.getPosition(a); if (p != null && p.overlapsWith(offset, length)) return a; } return null; }
public void uninstall() { ISourceViewer sourceViewer= getSourceViewer(); if (sourceViewer != null) sourceViewer.removeTextInputListener(this); IDocumentProvider documentProvider= getDocumentProvider(); if (documentProvider != null) { IDocument document= documentProvider.getDocument(getEditorInput()); if (document != null) document.removeDocumentListener(this); } }
public void uninstall() { ISourceViewer sourceViewer= getSourceViewer(); if (sourceViewer != null) sourceViewer.removeTextInputListener(this); IDocumentProvider documentProvider= getDocumentProvider(); if (documentProvider != null) { IDocument document= documentProvider.getDocument(getEditorInput()); if (document != null) document.removeDocumentListener(this); } }
public void uninstall() { ISourceViewer sourceViewer= getSourceViewer(); if (sourceViewer != null) sourceViewer.removeTextInputListener(this); IDocumentProvider documentProvider= getDocumentProvider(); if (documentProvider != null) { IDocument document= documentProvider.getDocument(getEditorInput()); if (document != null) document.removeDocumentListener(this); } }
/** * Returns the annotation overlapping with the given range or <code>null</code>. * * @param offset the region offset * @param length the region length * @return the found annotation or <code>null</code> * @since 3.0 */ private Annotation getAnnotation(int offset, int length) { IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput()); if (model == null) return null; Iterator<Annotation> parent; if (model instanceof IAnnotationModelExtension2) parent= ((IAnnotationModelExtension2)model).getAnnotationIterator(offset, length, true, true); else parent= model.getAnnotationIterator(); Iterator<Annotation> e= new JavaAnnotationIterator(parent, false); while (e.hasNext()) { Annotation a= e.next(); Position p= model.getPosition(a); if (p != null && p.overlapsWith(offset, length)) return a; } return null; }
void removeOccurrenceAnnotations() { fMarkOccurrenceModificationStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP; fMarkOccurrenceTargetRegion= null; IDocumentProvider documentProvider= getDocumentProvider(); if (documentProvider == null) return; IAnnotationModel annotationModel= documentProvider.getAnnotationModel(getEditorInput()); if (annotationModel == null || fOccurrenceAnnotations == null) return; synchronized (getLockObject(annotationModel)) { if (annotationModel instanceof IAnnotationModelExtension) { ((IAnnotationModelExtension)annotationModel).replaceAnnotations(fOccurrenceAnnotations, null); } else { for (int i= 0, length= fOccurrenceAnnotations.length; i < length; i++) annotationModel.removeAnnotation(fOccurrenceAnnotations[i]); } fOccurrenceAnnotations= null; } }
void removeOccurrenceAnnotations() { fMarkOccurrenceModificationStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP; fMarkOccurrenceTargetRegion= null; IDocumentProvider documentProvider= getDocumentProvider(); if (documentProvider == null) return; IAnnotationModel annotationModel= documentProvider.getAnnotationModel(getEditorInput()); if (annotationModel == null || fOccurrenceAnnotations == null) return; synchronized (getLockObject(annotationModel)) { if (annotationModel instanceof IAnnotationModelExtension) { ((IAnnotationModelExtension)annotationModel).replaceAnnotations(fOccurrenceAnnotations, null); } else { for (int i= 0, length= fOccurrenceAnnotations.length; i < length; i++) annotationModel.removeAnnotation(fOccurrenceAnnotations[i]); } fOccurrenceAnnotations= null; } }
void removeOccurrenceAnnotations() { fMarkOccurrenceModificationStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP; fMarkOccurrenceTargetRegion= null; IDocumentProvider documentProvider= getDocumentProvider(); if (documentProvider == null) return; IAnnotationModel annotationModel= documentProvider.getAnnotationModel(getEditorInput()); if (annotationModel == null || fOccurrenceAnnotations == null) return; synchronized (getLockObject(annotationModel)) { if (annotationModel instanceof IAnnotationModelExtension) { ((IAnnotationModelExtension)annotationModel).replaceAnnotations(fOccurrenceAnnotations, null); } else { for (int i= 0, length= fOccurrenceAnnotations.length; i < length; i++) annotationModel.removeAnnotation(fOccurrenceAnnotations[i]); } fOccurrenceAnnotations= null; } }
protected IJavaElement findSelectedJavaElement(IWorkbenchPart part, ISelection selection) { IJavaElement element; try { element= super.findSelectedJavaElement(part, selection); if (element == null && part instanceof JavaEditor && selection instanceof ITextSelection) { JavaEditor editor= (JavaEditor)part; ITextSelection textSelection= (ITextSelection)selection; IDocumentProvider documentProvider= editor.getDocumentProvider(); if (documentProvider == null) return null; IDocument document= documentProvider.getDocument(editor.getEditorInput()); if (document == null) return null; ITypedRegion typedRegion= TextUtilities.getPartition(document, IJavaPartitions.JAVA_PARTITIONING, textSelection.getOffset(), false); if (IJavaPartitions.JAVA_DOC.equals(typedRegion.getType())) return TextSelectionConverter.getElementAtOffset((JavaEditor)part, textSelection); else return null; } else return element; } catch (JavaModelException e) { return null; } catch (BadLocationException e) { return null; } }
protected void installOverrideIndicator(boolean provideAST) { uninstallOverrideIndicator(); IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput()); final ITypeRoot inputElement= getInputJavaElement(); if (model == null || inputElement == null) return; fOverrideIndicatorManager= new OverrideIndicatorManager(model, inputElement, null); if (provideAST) { IProgressMonitor monitor = getProgressMonitor(); try { SubMonitor subMonitor= SubMonitor.convert(monitor, 2); CompilationUnit ast= SharedASTProvider.getAST(inputElement, SharedASTProvider.WAIT_ACTIVE_ONLY, subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE)); fOverrideIndicatorManager.reconciled(ast, true, subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE)); } finally { monitor.done(); } } }
protected void installOverrideIndicator(boolean provideAST) { uninstallOverrideIndicator(); IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput()); final ITypeRoot inputElement= getInputJavaElement(); if (model == null || inputElement == null) return; fOverrideIndicatorManager= new OverrideIndicatorManager(model, inputElement, null); if (provideAST) { IProgressMonitor monitor = getProgressMonitor(); try { SubMonitor subMonitor= SubMonitor.convert(monitor, 2); CompilationUnit ast= SharedASTProviderCore.getAST(inputElement, SharedASTProviderCore.WAIT_ACTIVE_ONLY, subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE)); fOverrideIndicatorManager.reconciled(ast, true, subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE)); } finally { monitor.done(); } } }
protected void installOverrideIndicator(boolean provideAST) { uninstallOverrideIndicator(); IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput()); final IJavaElement inputElement= getInputJavaElement(); if (model == null || inputElement == null) return; fOverrideIndicatorManager= new OverrideIndicatorManager(model, inputElement, null); if (provideAST) { CompilationUnit ast= JavaPlugin.getDefault().getASTProvider().getAST(inputElement, ASTProvider.WAIT_ACTIVE_ONLY, getProgressMonitor()); fOverrideIndicatorManager.reconciled(ast, true, getProgressMonitor()); } }