private ICompletionProposal[] getMarkerAnnotationFixes(MarkerAnnotation markerAnnotation) { if (markerAnnotation.isQuickFixableStateSet() && !markerAnnotation.isQuickFixable()) return NO_PROPOSALS; IMarker marker = markerAnnotation.getMarker(); ICompilationUnit cu = getCompilationUnit(marker); if (cu == null) return NO_PROPOSALS; IEditorInput input = EditorUtility.getEditorInput(cu); if (input == null) return NO_PROPOSALS; IAnnotationModel model = JavaUI.getDocumentProvider().getAnnotationModel(input); if (model == null) return NO_PROPOSALS; ISourceViewer sourceViewer = null; if (viewer instanceof ISourceViewer) sourceViewer = (ISourceViewer) viewer; AssistContext context = new AssistContext(cu, sourceViewer, position.getOffset(), position.getLength()); ArrayList proposals = new ArrayList(); JavaCorrectionProcessor.collectProposals( context, model, new Annotation[] {markerAnnotation}, true, false, proposals); return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]); }
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 proposals = new ArrayList(); JavaCorrectionProcessor.collectCorrections( context, new IProblemLocation[] {location}, proposals); Collections.sort(proposals, new CompletionProposalComparator()); return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]); }