private void doSelectionChanged(int offset, int length, CompilationUnit astRoot) { final IAnnotationModel model= getAnnotationModel(); final ICompilationUnit cu= getCompilationUnit(); if (model == null || cu == null) { return; } final AssistContext context= new AssistContext(cu, offset, length); context.setASTRoot(astRoot); boolean hasQuickFix= hasQuickFixLightBulb(model, context.getSelectionOffset()); if (hasQuickFix) { removeLightBulb(model); return; // there is already a quick fix light bulb at the new location } calculateLightBulb(model, context); }
@Override public ASTNode getCoveringNode() { if (fNodeFinder == null) { fNodeFinder= new NodeFinder(getASTRoot(), getOffset(), getLength()); } return fNodeFinder.getCoveringNode(); }
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; }
context= new AssistContext(cu, viewer, part, documentOffset, length); ExternalNullAnnotationChangeProposals.collectExternalAnnotationProposals(context.getCompilationUnit(), context.getCoveringNode(), documentOffset, proposals);
addRemoveProposal(context, rewrite, label, proposals); AssistContext assistContext= new AssistContext(context.getCompilationUnit(), infixExpression.getRightOperand().getStartPosition() - 1, 0); assistContext.setASTRoot(root); AdvancedQuickAssistProcessor.getSplitAndConditionProposals(assistContext, infixExpression, proposals); AdvancedQuickAssistProcessor.getSplitOrConditionProposals(assistContext, infixExpression, proposals);
public ASTNode getCoveredNode() { NodeFinder finder= new NodeFinder(fOffset, fLength); getASTRoot().accept(finder); return finder.getCoveredNode(); }
return false; IEditorPart editor= ((AssistContext)context).getEditor(); if (!(editor instanceof JavaEditor)) return false;
/** * Returns the length. * @return int */ @Override public int getSelectionLength() { return Math.max(getLength(), 0); }
/** * Returns the offset. * @return int */ @Override public int getSelectionOffset() { return getOffset(); }
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; }
context= new AssistContext(cu, viewer, part, documentOffset, length); ExternalNullAnnotationChangeProposals.collectExternalAnnotationProposals(context.getCompilationUnit(), context.getCoveringNode(), documentOffset, proposals);
addRemoveProposal(context, rewrite, label, proposals); AssistContext assistContext= new AssistContext(context.getCompilationUnit(), infixExpression.getRightOperand().getStartPosition() - 1, 0); assistContext.setASTRoot(root); AdvancedQuickAssistProcessor.getSplitAndConditionProposals(assistContext, infixExpression, proposals); AdvancedQuickAssistProcessor.getSplitOrConditionProposals(assistContext, infixExpression, proposals);
public ASTNode getCoveringNode() { NodeFinder finder= new NodeFinder(fOffset, fLength); getASTRoot().accept(finder); return finder.getCoveringNode(); }
return false; IEditorPart editor= ((AssistContext)context).getEditor(); if (!(editor instanceof JavaEditor)) return false;
/** * Returns the length. * @return int */ @Override public int getSelectionLength() { return Math.max(getLength(), 0); }
/** * Returns the offset. * @return int */ @Override public int getSelectionOffset() { return getOffset(); }
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 void doSelectionChanged(int offset, int length, CompilationUnit astRoot) { final IAnnotationModel model= getAnnotationModel(); final ICompilationUnit cu= getCompilationUnit(); if (model == null || cu == null) { return; } final AssistContext context= new AssistContext(cu, offset, length); context.setASTRoot(astRoot); boolean hasQuickFix= hasQuickFixLightBulb(model, context.getSelectionOffset()); if (hasQuickFix) { removeLightBulb(model); return; // there is already a quick fix light bulb at the new location } calculateLightBulb(model, context); }
@Override public ASTNode getCoveringNode() { if (fNodeFinder == null) { fNodeFinder= new NodeFinder(getASTRoot(), getOffset(), getLength()); } return fNodeFinder.getCoveringNode(); }
model.forceInstall(); if (fContext instanceof AssistContext) { IEditorPart editor= ((AssistContext)fContext).getEditor(); if (editor instanceof JavaEditor) { model.addLinkingListener(new EditorHighlightingSynchronizer((JavaEditor) editor));