public static boolean hasCorrections(Annotation annotation) { if (annotation instanceof IJavaAnnotation) { IJavaAnnotation javaAnnotation= (IJavaAnnotation) annotation; int problemId= javaAnnotation.getId(); if (problemId != -1) { ICompilationUnit cu= javaAnnotation.getCompilationUnit(); if (cu != null) { return hasCorrections(cu, problemId, javaAnnotation.getMarkerType()); } } } if (annotation instanceof SimpleMarkerAnnotation) { return hasCorrections(((SimpleMarkerAnnotation) annotation).getMarker()); } return false; }
/** * Overlays this annotation with the given javaAnnotation. * * @param javaAnnotation annotation that is overlaid by this annotation */ public void setOverlay(IJavaAnnotation javaAnnotation) { if (fOverlay != null) fOverlay.removeOverlaid(this); fOverlay= javaAnnotation; if (!isMarkedDeleted()) markDeleted(fOverlay != null); if (fOverlay != null) fOverlay.addOverlaid(this); }
public ProblemLocation(int offset, int length, IJavaAnnotation annotation) { fId= annotation.getId(); fArguments= annotation.getArguments(); fOffset= offset; fLength= length; fIsError= JavaMarkerAnnotation.ERROR_ANNOTATION_TYPE.equals(annotation.getType()); String markerType= annotation.getMarkerType(); fMarkerType= markerType != null ? markerType : IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER; }
private boolean isIncluded(IJavaAnnotation annotation, boolean showTemporaryProblems) { // XXX: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=138601 if (annotation instanceof ProblemAnnotation && JavaMarkerAnnotation.TASK_ANNOTATION_TYPE.equals(annotation.getType())) return false; if (!annotation.isProblem()) return true; if (annotation.isMarkedDeleted() && !annotation.hasOverlay()) return true; if (annotation.hasOverlay() && !annotation.isMarkedDeleted()) return true; if (annotation.hasOverlay()) return (!isIncluded(annotation.getOverlay(), showTemporaryProblems)); return showTemporaryProblems && JavaCorrectionProcessor.hasCorrections((Annotation)annotation); }
private int getImageType(IJavaAnnotation annotation) { int imageType= NO_IMAGE; if (annotation.hasOverlay()) imageType= OVERLAY_IMAGE; else if (!annotation.isMarkedDeleted()) { if (showQuickFix(annotation)) imageType= JavaMarkerAnnotation.ERROR_ANNOTATION_TYPE.equals(annotation.getType()) ? QUICKFIX_ERROR_IMAGE : QUICKFIX_IMAGE; } else { imageType= GRAY_IMAGE; } return imageType; }
private boolean containsRelevantMarkers(IEditorPart editor) { IAnnotationModel model= JavaUI.getDocumentProvider().getAnnotationModel(editor.getEditorInput()); Iterator<Annotation> iterator= model.getAnnotationIterator(); while (iterator.hasNext()) { Annotation element= iterator.next(); if (element instanceof IJavaAnnotation) { IJavaAnnotation annot= (IJavaAnnotation) element; if (!annot.isMarkedDeleted() && annot.isPersistent() && !annot.isProblem()) return true; } } return false; }
switch (imageType) { case OVERLAY_IMAGE: IJavaAnnotation overlay= annotation.getOverlay(); image= getManagedImage((Annotation) overlay); fCachedImageType= -1; break; case GRAY_IMAGE: { String annotationType= annotation.getType(); if (JavaMarkerAnnotation.ERROR_ANNOTATION_TYPE.equals(annotationType)) { image= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_ERROR_ALT);
private ICompletionProposal[] getJavaAnnotationFixes(IJavaAnnotation javaAnnotation) { ProblemLocation location= new ProblemLocation(position.getOffset(), position.getLength(), javaAnnotation); ICompilationUnit cu= javaAnnotation.getCompilationUnit(); if (cu == null) return NO_PROPOSALS; ISourceViewer sourceViewer= null; if (viewer instanceof ISourceViewer) sourceViewer= (ISourceViewer) viewer; IInvocationContext context= new AssistContext(cu, sourceViewer, location.getOffset(), location.getLength(), SharedASTProviderCore.WAIT_ACTIVE_ONLY); if (!SpellingAnnotation.TYPE.equals(javaAnnotation.getType()) && !hasProblem(context.getASTRoot().getProblems(), location)) return NO_PROPOSALS; ArrayList<IJavaCompletionProposal> proposals= new ArrayList<>(); JavaCorrectionProcessor.collectCorrections(context, new IProblemLocation[] { location }, proposals); Collections.sort(proposals, new CompletionProposalComparator()); return proposals.toArray(new ICompletionProposal[proposals.size()]); }
private static ProblemLocation getProblemLocation(IJavaAnnotation javaAnnotation, IAnnotationModel model) { int problemId= javaAnnotation.getId(); if (problemId != -1) { Position pos= model.getPosition((Annotation) javaAnnotation); if (pos != null) { return new ProblemLocation(pos.getOffset(), pos.getLength(), javaAnnotation); // java problems all handled by the quick assist processors } } return null; }
@Override protected void updateMarkerViews(Annotation annotation) { if (annotation instanceof IJavaAnnotation) { Iterator<IJavaAnnotation> e= ((IJavaAnnotation) annotation).getOverlaidIterator(); if (e != null) { while (e.hasNext()) { Object o= e.next(); if (o instanceof MarkerAnnotation) { super.updateMarkerViews((MarkerAnnotation)o); return; } } } return; } super.updateMarkerViews(annotation); }
while (e.hasNext()) { Annotation a= e.next(); if ((a instanceof IJavaAnnotation) && ((IJavaAnnotation)a).hasOverlay() || !isNavigationTarget(a)) continue;
private boolean isIncluded(IJavaAnnotation annotation, boolean showTemporaryProblems) { // XXX: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=138601 if (annotation instanceof ProblemAnnotation && JavaMarkerAnnotation.TASK_ANNOTATION_TYPE.equals(annotation.getType())) return false; if (!annotation.isProblem()) return true; if (annotation.isMarkedDeleted() && !annotation.hasOverlay()) return true; if (annotation.hasOverlay() && !annotation.isMarkedDeleted()) return true; if (annotation.hasOverlay()) return (!isIncluded(annotation.getOverlay(), showTemporaryProblems)); return showTemporaryProblems && JavaCorrectionProcessor.hasCorrections((Annotation)annotation); }
private int getImageType(IJavaAnnotation annotation) { int imageType= NO_IMAGE; if (annotation.hasOverlay()) imageType= OVERLAY_IMAGE; else if (!annotation.isMarkedDeleted()) { if (showQuickFix(annotation)) { if (JavaMarkerAnnotation.ERROR_ANNOTATION_TYPE.equals(annotation.getType())) { imageType= QUICKFIX_ERROR_IMAGE; } else if (JavaMarkerAnnotation.WARNING_ANNOTATION_TYPE.equals(annotation.getType())) { imageType= QUICKFIX_WARNING_IMAGE; } else { imageType= QUICKFIX_INFO_IMAGE; } } } else { imageType= GRAY_IMAGE; } return imageType; }
private boolean containsRelevantMarkers(IEditorPart editor) { IAnnotationModel model= JavaUI.getDocumentProvider().getAnnotationModel(editor.getEditorInput()); Iterator iterator= model.getAnnotationIterator(); while (iterator.hasNext()) { Object element= iterator.next(); if (element instanceof IJavaAnnotation) { IJavaAnnotation annot= (IJavaAnnotation) element; if (!annot.isMarkedDeleted() && annot.isPersistent() && !annot.isProblem()) return true; } } return false; }
switch (imageType) { case OVERLAY_IMAGE: IJavaAnnotation overlay= annotation.getOverlay(); image= getManagedImage((Annotation) overlay); fCachedImageType= -1; break; case GRAY_IMAGE: { String annotationType= annotation.getType(); if (JavaMarkerAnnotation.ERROR_ANNOTATION_TYPE.equals(annotationType)) { image= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_ERROR_ALT);
private ICompletionProposal[] getJavaAnnotationFixes(IJavaAnnotation javaAnnotation) { ProblemLocation location= new ProblemLocation(position.getOffset(), position.getLength(), javaAnnotation); ICompilationUnit cu= javaAnnotation.getCompilationUnit(); if (cu == null) return NO_PROPOSALS; ISourceViewer sourceViewer= null; if (viewer instanceof ISourceViewer) sourceViewer= (ISourceViewer) viewer; IInvocationContext context= new AssistContext(cu, sourceViewer, location.getOffset(), location.getLength(), SharedASTProvider.WAIT_ACTIVE_ONLY); if (!SpellingAnnotation.TYPE.equals(javaAnnotation.getType()) && !hasProblem(context.getASTRoot().getProblems(), location)) return NO_PROPOSALS; ArrayList<IJavaCompletionProposal> proposals= new ArrayList<>(); JavaCorrectionProcessor.collectCorrections(context, new IProblemLocation[] { location }, proposals); Collections.sort(proposals, new CompletionProposalComparator()); return proposals.toArray(new ICompletionProposal[proposals.size()]); }
private static ProblemLocation getProblemLocation(IJavaAnnotation javaAnnotation, IAnnotationModel model) { int problemId= javaAnnotation.getId(); if (problemId != -1) { Position pos= model.getPosition((Annotation) javaAnnotation); if (pos != null) { return new ProblemLocation(pos.getOffset(), pos.getLength(), javaAnnotation); // java problems all handled by the quick assist processors } } return null; }
protected void updateMarkerViews(Annotation annotation) { if (annotation instanceof IJavaAnnotation) { Iterator e= ((IJavaAnnotation) annotation).getOverlaidIterator(); if (e != null) { while (e.hasNext()) { Object o= e.next(); if (o instanceof MarkerAnnotation) { super.updateMarkerViews((MarkerAnnotation)o); return; } } } return; } super.updateMarkerViews(annotation); }
while (e.hasNext()) { Annotation a= e.next(); if ((a instanceof IJavaAnnotation) && ((IJavaAnnotation)a).hasOverlay() || !isNavigationTarget(a)) continue;
private boolean isIncluded(IJavaAnnotation annotation, boolean showTemporaryProblems) { // XXX: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=138601 if (annotation instanceof ProblemAnnotation && JavaMarkerAnnotation.TASK_ANNOTATION_TYPE.equals(annotation.getType())) return false; if (!annotation.isProblem()) return true; if (annotation.isMarkedDeleted() && !annotation.hasOverlay()) return true; if (annotation.hasOverlay() && !annotation.isMarkedDeleted()) return true; if (annotation.hasOverlay()) return (!isIncluded(annotation.getOverlay(), showTemporaryProblems)); return showTemporaryProblems && JavaCorrectionProcessor.hasCorrections((Annotation)annotation); }