private ICompletionProposal findCorrection(String id, boolean isAssist, ITextSelection selection, ICompilationUnit cu, IAnnotationModel model) { AssistContext context= new AssistContext(cu, selection.getOffset(), selection.getLength()); Collection proposals= new ArrayList(10); if (isAssist) { if (id.equals(LinkedNamesAssistProposal.ASSIST_ID)) { return getLocalRenameProposal(context); // shortcut for local rename } JavaCorrectionProcessor.collectAssists(context, new ProblemLocation[0], proposals); } else { try { boolean goToClosest= selection.getLength() == 0; Annotation[] annotations= getAnnotations(selection.getOffset(), goToClosest); JavaCorrectionProcessor.collectProposals(context, model, annotations, true, false, proposals); } catch (BadLocationException e) { return null; } } for (Iterator iter= proposals.iterator(); iter.hasNext();) { Object curr= iter.next(); if (curr instanceof ICommandAccess) { if (id.equals(((ICommandAccess) curr).getCommandId())) { return (ICompletionProposal) curr; } } } return null; }
private ICompletionProposal findCorrection(String id, boolean isAssist, ITextSelection selection, ICompilationUnit cu, IAnnotationModel model) { AssistContext context= new AssistContext(cu, fEditor.getViewer(), fEditor, selection.getOffset(), selection.getLength()); Collection<IJavaCompletionProposal> proposals= new ArrayList<>(10); if (isAssist) { if (id.equals(LinkedNamesAssistProposal.ASSIST_ID)) { return getLocalRenameProposal(context); // shortcut for local rename } JavaCorrectionProcessor.collectAssists(context, new ProblemLocation[0], proposals); } else { try { boolean goToClosest= selection.getLength() == 0; Annotation[] annotations= getAnnotations(selection.getOffset(), goToClosest); JavaCorrectionProcessor.collectProposals(context, model, annotations, true, false, proposals); } catch (BadLocationException e) { return null; } } for (Iterator<IJavaCompletionProposal> iter= proposals.iterator(); iter.hasNext();) { Object curr= iter.next(); if (curr instanceof ICommandAccess) { if (id.equals(((ICommandAccess) curr).getCommandId())) { return (ICompletionProposal) curr; } } } return null; }
private ICompletionProposal findCorrection(String id, boolean isAssist, ITextSelection selection, ICompilationUnit cu, IAnnotationModel model) { AssistContext context= new AssistContext(cu, fEditor.getViewer(), fEditor, selection.getOffset(), selection.getLength()); Collection<IJavaCompletionProposal> proposals= new ArrayList<>(10); if (isAssist) { if (id.equals(LinkedNamesAssistProposal.ASSIST_ID)) { return getLocalRenameProposal(context); // shortcut for local rename } JavaCorrectionProcessor.collectAssists(context, new ProblemLocation[0], proposals); } else { try { boolean goToClosest= selection.getLength() == 0; Annotation[] annotations= getAnnotations(selection.getOffset(), goToClosest); JavaCorrectionProcessor.collectProposals(context, model, annotations, true, false, proposals); } catch (BadLocationException e) { return null; } } for (Iterator<IJavaCompletionProposal> iter= proposals.iterator(); iter.hasNext();) { Object curr= iter.next(); if (curr instanceof ICommandAccess) { if (id.equals(((ICommandAccess) curr).getCommandId())) { return (ICompletionProposal) curr; } } } return null; }
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<IJavaCompletionProposal> proposals= new ArrayList<>(); JavaCorrectionProcessor.collectProposals(context, model, new Annotation[] { markerAnnotation }, true, false, proposals); Collections.sort(proposals, new CompletionProposalComparator()); return proposals.toArray(new ICompletionProposal[proposals.size()]); }
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<IJavaCompletionProposal> proposals= new ArrayList<>(); JavaCorrectionProcessor.collectProposals(context, model, new Annotation[] { markerAnnotation }, true, false, proposals); return proposals.toArray(new ICompletionProposal[proposals.size()]); }
if (model != null && context != null && annotations != null) { ArrayList<IJavaCompletionProposal> proposals= new ArrayList<>(10); IStatus status= collectProposals(context, model, annotations, true, !fAssistant.isUpdatedOffset(), proposals); res= proposals.toArray(new ICompletionProposal[proposals.size()]); if (!status.isOK()) {
if (model != null && annotations != null) { ArrayList proposals= new ArrayList(10); IStatus status= collectProposals(context, model, annotations, true, !fAssistant.isUpdatedOffset(), proposals); res= (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]); if (!status.isOK()) {
if (model != null && context != null && annotations != null) { ArrayList<IJavaCompletionProposal> proposals= new ArrayList<>(10); IStatus status= collectProposals(context, model, annotations, true, !fAssistant.isUpdatedOffset(), proposals); res= proposals.toArray(new ICompletionProposal[proposals.size()]); if (!status.isOK()) {