private static boolean contains(ArrayList<IProblemLocation> problems, IProblemLocation problem) { for (int i= 0; i < problems.size(); i++) { IProblemLocation existing= problems.get(i); if (existing.getProblemId() == problem.getProblemId() && existing.getOffset() == problem.getOffset() && existing.getLength() == problem.getLength()) { return true; } } return false; }
private static ParameterizedType getParameterizedType(CompilationUnit compilationUnit, IProblemLocation problem) { ASTNode selectedNode= problem.getCoveringNode(compilationUnit); if (selectedNode == null) return null; while (!(selectedNode instanceof ParameterizedType) && !(selectedNode instanceof Statement)) { selectedNode= selectedNode.getParent(); } if (selectedNode instanceof ParameterizedType) { return (ParameterizedType) selectedNode; } return null; }
private static boolean containsMatchingProblem(IProblemLocation[] locations, int problemId) { if (locations != null) { for (int i= 0; i < locations.length; i++) { IProblemLocation location= locations[i]; if (IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER.equals(location.getMarkerType()) && location.getProblemId() == problemId) { return true; } } } return false; }
static boolean noErrorsAtLocation(IProblemLocation[] locations) { if (locations != null) { for (int i= 0; i < locations.length; i++) { IProblemLocation location= locations[i]; if (location.isError()) { if (IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER.equals(location.getMarkerType()) && JavaCore.getOptionForConfigurableSeverity(location.getProblemId()) != null) { // continue (only drop out for severe (non-optional) errors) } else { return false; } } } } return true; }
if (location.getProblemId() == JavaSpellingReconcileStrategy.SPELLING_PROBLEM_ID) { arguments= location.getProblemArguments(); if (arguments != null && arguments.length > 4) { result= new IJavaCompletionProposal[] { new ChangeCaseProposal(arguments, location.getOffset(), location.getLength(), context, engine.getLocale())}; else { result[index]= new WordCorrectionProposal(proposal.getText(), arguments, location.getOffset(), location.getLength(), context, proposal.getRank());
public static void addSuperfluousSemicolonProposal(IInvocationContext context, IProblemLocation problem, Collection proposals) { String label= CorrectionMessages.LocalCorrectionsSubProcessor_removesemicolon_description; ReplaceCorrectionProposal proposal= new ReplaceCorrectionProposal(label, context.getCompilationUnit(), problem.getOffset(), problem.getLength(), "", 6); //$NON-NLS-1$ proposals.add(proposal); }
public static void addOverrideDefaultMethodProposal(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) { CompilationUnit astRoot= context.getASTRoot(); ASTNode selectedNode= problem.getCoveringNode(astRoot); if (selectedNode == null) { return; if (problem.getProblemId() == IProblem.DuplicateInheritedDefaultMethods) { String[] args= problem.getProblemArguments(); if (args.length < 5) { return; addOverrideProposal(typeNode, typeBinding, methodName, parameters2, args[4], context, proposals); } else if (problem.getProblemId() == IProblem.InheritedDefaultMethodConflictsWithOtherInherited) { String[] args= problem.getProblemArguments(); if (args.length < 3) { return;
private static boolean hasProblem(IProblem[] problems, IProblemLocation location) { for (int i= 0; i < problems.length; i++) { IProblem problem= problems[i]; if (problem.getID() == location.getProblemId() && problem.getSourceStart() == location.getOffset()) return true; } return false; }
public static void addSuppressWarningsProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) { if (problem.isError() && ! JavaCore.ENABLED.equals(context.getCompilationUnit().getJavaProject().getOption(JavaCore.COMPILER_PB_SUPPRESS_OPTIONAL_ERRORS, true))) { return; String warningToken= CorrectionEngine.getWarningToken(problem.getProblemId()); if (warningToken == null) { return; ASTNode node= problem.getCoveringNode(context.getASTRoot()); if (node == null) { return;
@Override public boolean canFix(ICompilationUnit compilationUnit, IProblemLocation problem) { int id= problem.getProblemId(); if (id == this.handledProblemID) { // FIXME search specifically: return param (which??) // if (QuickFixes.hasExplicitNullnessAnnotation(compilationUnit, problem.getOffset())) // return false; return true; } return false; }
public static void getInferDiamondArgumentsProposal(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) { ASTNode selectedNode= problem.getCoveredNode(context.getASTRoot()); if (!(selectedNode instanceof SimpleName)) { return; } QuickAssistProcessor.getInferDiamondArgumentsProposal(context, selectedNode, null, proposals); }
for (int i= 0; i < locations.length; i++) { IProblemLocation problem= locations[i]; int id= problem.getProblemId(); if (id == IProblem.UnsafeTypeConversion || id == IProblem.RawTypeReference || id == IProblem.UnsafeRawMethodInvocation) { ASTNode node= problem.getCoveredNode(compilationUnit); if (node instanceof ClassInstanceCreation) { ASTNode rawReference= (ASTNode)node.getStructuralProperty(ClassInstanceCreation.TYPE_PROPERTY);
public static void addConfigureProblemSeverityProposal(final IInvocationContext context, final IProblemLocation problem, Collection<ICommandAccess> proposals) { final int problemId= problem.getProblemId(); String[] options= problem.getProblemArguments(); if (options != null && options.length > 0) { optionId= options[0];
public static void addTypeMismatchProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) throws CoreException { String[] args= problem.getProblemArguments(); if (args.length != 2) { return; AST ast= astRoot.getAST(); ASTNode selectedNode= problem.getCoveredNode(astRoot); if (!(selectedNode instanceof Expression)) { return;
public static UnusedCodeFix createRemoveUnusedCastFix(CompilationUnit compilationUnit, IProblemLocation problem) { if (problem.getProblemId() != IProblem.UnnecessaryCast) return null; ASTNode selectedNode= problem.getCoveringNode(compilationUnit); ASTNode curr= selectedNode; while (curr instanceof ParenthesizedExpression) { curr= ((ParenthesizedExpression) curr).getExpression(); } if (!(curr instanceof CastExpression)) return null; return new UnusedCodeFix(FixMessages.UnusedCodeFix_RemoveCast_description, compilationUnit, new CompilationUnitRewriteOperation[] {new RemoveCastOperation((CastExpression)curr)}); }
for (int i= 0; i < locations.length; i++) { IProblemLocation curr= locations[i]; if (processor.canHandleMarkerType(curr.getMarkerType())) { if (!allHandled) { // first handled problem if (res == null) {
private static boolean noErrorsAtLocation(IProblemLocation[] locations) { if (locations != null) { for (int i = 0; i < locations.length; i++) { if (locations[i].isError()) { return false; } } } return true; } private static boolean getIfReturnIntoIfElseAtEndOfVoidMethodProposals(IInvocationContext context, ASTNode covering,
if (invocationContext instanceof IQuickAssistInvocationContext) sourceViewer= ((IQuickAssistInvocationContext)invocationContext).getSourceViewer(); IQuickAssistInvocationContext context= new TextInvocationContext(sourceViewer, location.getOffset(), location.getLength()); if (location.getProblemId() == JavaSpellingReconcileStrategy.SPELLING_PROBLEM_ID) { arguments= location.getProblemArguments(); if (arguments != null && arguments.length > 4) { result= new IJavaCompletionProposal[] { new ChangeCaseProposal(arguments, location.getOffset(), location.getLength(), context, engine.getLocale())}; else { result[index]= new WordCorrectionProposal(proposal.getText(), arguments, location.getOffset(), location.getLength(), context, proposal.getRank());
public static void addSuperfluousSemicolonProposal(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) { String label= CorrectionMessages.LocalCorrectionsSubProcessor_removesemicolon_description; ReplaceCorrectionProposal proposal= new ReplaceCorrectionProposal(label, context.getCompilationUnit(), problem.getOffset(), problem.getLength(), "", IProposalRelevance.REMOVE_SEMICOLON); //$NON-NLS-1$ proposals.add(proposal); }
public static void addOverrideDefaultMethodProposal(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) { CompilationUnit astRoot= context.getASTRoot(); ASTNode selectedNode= problem.getCoveringNode(astRoot); if (selectedNode == null) { return; if (problem.getProblemId() == IProblem.DuplicateInheritedDefaultMethods) { String[] args= problem.getProblemArguments(); if (args.length < 5) { return; addOverrideProposal(typeNode, typeBinding, methodName, parameters2, args[4], context, proposals); } else if (problem.getProblemId() == IProblem.InheritedDefaultMethodConflictsWithOtherInherited) { String[] args= problem.getProblemArguments(); if (args.length < 3) { return;