/** * Constructor for CorrectTypeNameProposal. * @param cu the compilation unit * @param context the invocation context * @param oldTypeName the old type name * @param newTypeName the new type name * @param relevance the relevance */ public CorrectMainTypeNameProposal(ICompilationUnit cu, IInvocationContext context, String oldTypeName, String newTypeName, int relevance) { super("", cu, null, relevance, null); //$NON-NLS-1$ fContext= context; setDisplayName(Messages.format(CorrectionMessages.ReorgCorrectionsSubProcessor_renametype_description, BasicElementLabels.getJavaElementName(newTypeName))); setImage(JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE)); fOldName= oldTypeName; fNewName= newTypeName; }
@Override protected ASTRewrite getRewrite() throws CoreException { CompilationUnit astRoot= fContext.getASTRoot(); AST ast= astRoot.getAST(); ASTRewrite rewrite= ASTRewrite.create(ast); AbstractTypeDeclaration decl= findTypeDeclaration(astRoot.types(), fOldName); if (decl != null) { ASTNode[] sameNodes= LinkedNodeFinder.findByNode(astRoot, decl.getName()); for (int i= 0; i < sameNodes.length; i++) { rewrite.replace(sameNodes[i], ast.newSimpleName(fNewName), null); } } return rewrite; }
proposals.add(new CorrectMainTypeNameProposal(cu, context, currTypeName, newTypeName, IProposalRelevance.RENAME_TYPE));
@Override protected ASTRewrite getRewrite() throws CoreException { CompilationUnit astRoot= fContext.getASTRoot(); AST ast= astRoot.getAST(); ASTRewrite rewrite= ASTRewrite.create(ast); AbstractTypeDeclaration decl= findTypeDeclaration(astRoot.types(), fOldName); if (decl != null) { ASTNode[] sameNodes= LinkedNodeFinder.findByNode(astRoot, decl.getName()); for (int i= 0; i < sameNodes.length; i++) { rewrite.replace(sameNodes[i], ast.newSimpleName(fNewName), null); } } return rewrite; }
proposals.add(new CorrectMainTypeNameProposal(cu, context, currTypeName, newTypeName, IProposalRelevance.RENAME_TYPE));
/** * Constructor for CorrectTypeNameProposal. * @param cu the compilation unit * @param context the invocation context * @param oldTypeName the old type name * @param newTypeName the new type name * @param relevance the relevance */ public CorrectMainTypeNameProposal(ICompilationUnit cu, IInvocationContext context, String oldTypeName, String newTypeName, int relevance) { super("", cu, null, relevance, null); //$NON-NLS-1$ fContext= context; setDisplayName(Messages.format(CorrectionMessages.ReorgCorrectionsSubProcessor_renametype_description, BasicElementLabels.getJavaElementName(newTypeName))); setImage(JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE)); fOldName= oldTypeName; fNewName= newTypeName; }