/** * Convert set of IProblems to IProblemLocations * @param problems the problems to convert * @return the converted set */ protected static IProblemLocation[] convertProblems(IProblem[] problems) { IProblemLocation[] result= new IProblemLocation[problems.length]; for (int i= 0; i < problems.length; i++) { result[i]= new ProblemLocation(problems[i]); } return result; }
@Override public String toString() { StringBuffer buf= new StringBuffer(); buf.append("Id: ").append(getErrorCode(fId)).append('\n'); //$NON-NLS-1$ buf.append('[').append(fOffset).append(", ").append(fLength).append(']').append('\n'); //$NON-NLS-1$ String[] arg= fArguments; for (int i= 0; i < arg.length; i++) { buf.append(arg[i]); buf.append('\n'); } return buf.toString(); }
private static ImportDeclaration getProblematicImport(IProblem problem, CompilationUnit cu) { ASTNode coveringNode= new ProblemLocation(problem).getCoveringNode(cu); if (coveringNode != null) { ASTNode importNode= ASTNodes.getParent(coveringNode, ASTNode.IMPORT_DECLARATION); if (importNode instanceof ImportDeclaration) { return (ImportDeclaration) importNode; } } return null; }
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 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()]); }
/** * Convert set of IProblems to IProblemLocations * @param problems the problems to convert * @return the converted set */ protected static IProblemLocation[] convertProblems(IProblem[] problems) { IProblemLocation[] result= new IProblemLocation[problems.length]; for (int i= 0; i < problems.length; i++) { result[i]= new ProblemLocation(problems[i]); } return result; }
public String toString() { StringBuffer buf= new StringBuffer(); buf.append("Id: ").append(getErrorCode(fId)).append('\n'); //$NON-NLS-1$ buf.append('[').append(fOffset).append(", ").append(fLength).append(']').append('\n'); //$NON-NLS-1$ String[] arg= fArguments; if (arg != null) { for (int i= 0; i < arg.length; i++) { buf.append(arg[i]); buf.append('\n'); } } return buf.toString(); }
public static ICleanUpFix createCleanUp(CompilationUnit compilationUnit, boolean addSerialVersionIds) { IProblem[] problems= compilationUnit.getProblems(); IProblemLocation[] locations= new IProblemLocation[problems.length]; for (int i= 0; i < problems.length; i++) { locations[i]= new ProblemLocation(problems[i]); } return createCleanUp(compilationUnit, locations, addSerialVersionIds); }
public static ICleanUpFix createCleanUp(CompilationUnit compilationUnit, boolean insertInferredTypeArguments, boolean removeRedundantTypeArguments) { IProblem[] problems= compilationUnit.getProblems(); IProblemLocation[] locations= new IProblemLocation[problems.length]; for (int i= 0; i < problems.length; i++) { locations[i]= new ProblemLocation(problems[i]); } return createCleanUp(compilationUnit, locations, insertInferredTypeArguments, removeRedundantTypeArguments); }
public static ICleanUpFix createCleanUp(CompilationUnit compilationUnit, boolean addSerialVersionIds) { IProblem[] problems= compilationUnit.getProblems(); IProblemLocation[] locations= new IProblemLocation[problems.length]; for (int i= 0; i < problems.length; i++) { locations[i]= new ProblemLocation(problems[i]); } return createCleanUp(compilationUnit, locations, addSerialVersionIds); }
public static IFix createCleanUp(CompilationUnit compilationUnit, boolean addNLSTag, boolean removeNLSTag) throws CoreException, JavaModelException { if (!addNLSTag && !removeNLSTag) return null; IProblem[] problems= compilationUnit.getProblems(); IProblemLocation[] locations= new IProblemLocation[problems.length]; for (int i= 0; i < problems.length; i++) { locations[i]= new ProblemLocation(problems[i]); } return createCleanUp(compilationUnit, addNLSTag, removeNLSTag, locations); }
public static ICleanUpFix createCleanUp(CompilationUnit compilationUnit, boolean addNLSTag, boolean removeNLSTag) throws CoreException, JavaModelException { if (!addNLSTag && !removeNLSTag) return null; IProblem[] problems= compilationUnit.getProblems(); IProblemLocation[] locations= new IProblemLocation[problems.length]; for (int i= 0; i < problems.length; i++) { locations[i]= new ProblemLocation(problems[i]); } return createCleanUp(compilationUnit, addNLSTag, removeNLSTag, locations); }
public static ICleanUpFix createCleanUp(CompilationUnit compilationUnit, boolean addNLSTag, boolean removeNLSTag) throws CoreException, JavaModelException { if (!addNLSTag && !removeNLSTag) return null; IProblem[] problems= compilationUnit.getProblems(); IProblemLocation[] locations= new IProblemLocation[problems.length]; for (int i= 0; i < problems.length; i++) { locations[i]= new ProblemLocation(problems[i]); } return createCleanUp(compilationUnit, addNLSTag, removeNLSTag, locations); }
public static ICleanUpFix createCleanUp(CompilationUnit compilationUnit, boolean insertInferredTypeArguments, boolean removeRedundantTypeArguments) { IProblem[] problems= compilationUnit.getProblems(); IProblemLocation[] locations= new IProblemLocation[problems.length]; for (int i= 0; i < problems.length; i++) { locations[i]= new ProblemLocation(problems[i]); } return createCleanUp(compilationUnit, locations, insertInferredTypeArguments, removeRedundantTypeArguments); }
public static IFix createCleanUp(CompilationUnit compilationUnit, boolean addSerialVersionIds) { IProblem[] problems= compilationUnit.getProblems(); IProblemLocation[] locations= new IProblemLocation[problems.length]; for (int i= 0; i < problems.length; i++) { locations[i]= new ProblemLocation(problems[i]); } return createCleanUp(compilationUnit, locations, addSerialVersionIds); }
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; }
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; }
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; }
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; }
private final static class ToStaticAccessOperation extends AbstractFixRewriteOperation { private final ITypeBinding fDeclaringTypeBinding; private final Expression fQualifier; public ToStaticAccessOperation(ITypeBinding declaringTypeBinding, Expression qualifier) { super(); fDeclaringTypeBinding= declaringTypeBinding; fQualifier= qualifier; } public String getAccessorName() { return fDeclaringTypeBinding.getName(); } /* (non-Javadoc) * @see org.eclipse.jdt.internal.corext.fix.AbstractFix.IFixRewriteOperation#rewriteAST(org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite, java.util.List) */ public void rewriteAST(CompilationUnitRewrite cuRewrite, List textEditGroups) throws CoreException { Type type= importType(fDeclaringTypeBinding, fQualifier, cuRewrite.getImportRewrite(), cuRewrite.getRoot()); TextEditGroup group= createTextEditGroup(FixMessages.CodeStyleFix_ChangeAccessUsingDeclaring_description); textEditGroups.add(group); cuRewrite.getASTRewrite().replace(fQualifier, type, group); } }