@Override public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModel linkedModel) throws CoreException { ASTRewrite rewrite= cuRewrite.getASTRewrite(); IBinding binding= fUnusedName.resolveBinding(); CompilationUnit root= (CompilationUnit) fUnusedName.getRoot(); String displayString= FixMessages.UnusedCodeFix_RemoveUnusedTypeParameter_description; TextEditGroup group= createTextEditGroup(displayString, cuRewrite); if (binding.getKind() == IBinding.TYPE) { ITypeBinding decl= ((ITypeBinding) binding).getTypeDeclaration(); ASTNode declaration= root.findDeclaringNode(decl); if (declaration.getParent() instanceof TypeDeclarationStatement) { declaration= declaration.getParent(); } rewrite.remove(declaration, group); } }
@Override public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModel linkedModel) throws CoreException { ASTRewrite rewrite = cuRewrite.getASTRewrite(); IBinding binding = fUnusedName.resolveBinding(); CompilationUnit root = (CompilationUnit) fUnusedName.getRoot(); String displayString = FixMessages.UnusedCodeFix_RemoveUnusedTypeParameter_description; TextEditGroup group = createTextEditGroup(displayString, cuRewrite); if (binding.getKind() == IBinding.TYPE) { ITypeBinding decl = ((ITypeBinding) binding).getTypeDeclaration(); ASTNode declaration = root.findDeclaringNode(decl); if (declaration.getParent() instanceof TypeDeclarationStatement) { declaration = declaration.getParent(); } rewrite.remove(declaration, group); } }
@Override public void endVisit(TypeDeclarationStatement node) { if (skipNode(node)) { return; } assignFlowInfo(node, node.getDeclaration()); }
@Override public boolean visit(TypeDeclarationStatement node) { ITypeBinding typeBinding = node.resolveBinding(); addNewBinding(typeBinding, node); addNewTypeBinding(typeBinding); return true; }
@Override public boolean visit(TypeDeclarationStatement node) { if (hasFlag(TYPES, fFlags) && node.getStartPosition() + node.getLength() < fPosition) { fBreak = fRequestor.acceptBinding(node.resolveBinding()); return false; } return !fBreak && isInside(node); }
@Override public boolean visit(TypeDeclarationStatement node) { if (hasFlag(TYPES, fFlags) && fPosition < node.getStartPosition()) { fBreak = fRequestor.acceptBinding(node.resolveBinding()); } return false; }
/** * @param scope not a TypeDeclaration * @return Set containing Strings representing simple names */ private Set<String> getLocallyDeclaredNames(BodyDeclaration scope) { Assert.isTrue(!(scope instanceof AbstractTypeDeclaration)); final Set<String> result = new HashSet<String>(); if (scope instanceof FieldDeclaration) return result; scope.accept( new HierarchicalASTVisitor() { @Override public boolean visit(AbstractTypeDeclaration node) { Assert.isTrue(node.getParent() instanceof TypeDeclarationStatement); result.add(node.getName().getIdentifier()); return false; } @Override public boolean visit(AnonymousClassDeclaration anonDecl) { return false; } @Override public boolean visit(VariableDeclaration varDecl) { result.add(varDecl.getName().getIdentifier()); return false; } }); return result; }
/** * @param scope not a TypeDeclaration * @return Set containing Strings representing simple names */ private Set<String> getLocallyDeclaredNames(BodyDeclaration scope) { Assert.isTrue(!(scope instanceof AbstractTypeDeclaration)); final Set<String> result= new HashSet<String>(); if (scope instanceof FieldDeclaration) return result; scope.accept(new HierarchicalASTVisitor() { @Override public boolean visit(AbstractTypeDeclaration node) { Assert.isTrue(node.getParent() instanceof TypeDeclarationStatement); result.add(node.getName().getIdentifier()); return false; } @Override public boolean visit(AnonymousClassDeclaration anonDecl) { return false; } @Override public boolean visit(VariableDeclaration varDecl) { result.add(varDecl.getName().getIdentifier()); return false; } }); return result; }
@Override public boolean visit(TypeDeclarationStatement node) { if (hasFlag(TYPES, fFlags) && node.getStartPosition() + node.getLength() < fPosition) { fBreak= fRequestor.acceptBinding(node.resolveBinding()); return false; } return !fBreak && isInside(node); }
@Override public boolean visit(TypeDeclarationStatement node) { if (hasFlag(TYPES, fFlags) && fPosition < node.getStartPosition()) { fBreak= fRequestor.acceptBinding(node.resolveBinding()); } return false; }
@Override public boolean visit(TypeDeclarationStatement node) { if (node.getAST().apiLevel() >= JLS3) { node.getDeclaration().accept(this); } return false; }
public boolean visit(TypeDeclarationStatement node) { if (node.getAST().apiLevel() == JLS2) { getTypeDeclaration(node).accept(this); } if (node.getAST().apiLevel() >= JLS3) { node.getDeclaration().accept(this); } return false; }
@Override public boolean visit(TypeDeclarationStatement node) { fScope.addName(node.getDeclaration().getName().getIdentifier()); return false; }
@Override public boolean visit(TypeDeclarationStatement node) { names.add(node.getDeclaration().getName().getIdentifier()); return false; }
/** {@inheritDoc} */ @Override public void endVisit(TypeDeclarationStatement node) { logger.warn("Method endVisitTypeDeclarationStatement for " + node + " for " + node + " not implemented!"); super.endVisit(node); }
/** {@inheritDoc} */ @Override public boolean visit(TypeDeclarationStatement node) { logger.warn("Method visitTypeDeclarationStatement for " + node + " not implemented!"); return super.visit(node); }
@Override public boolean visit(final TypeDeclarationStatement node) { return false; }
@Override public boolean visit(final TypeDeclarationStatement node) { // not instrumentable, may contain instrumentable nodes return true; }
@Override public boolean visit(final TypeDeclarationStatement node) { addToMap(identifiers, node, node.getDeclaration().getName() .toString()); return super.visit(node); }
private boolean isInLocalTypeInsideInputType(ASTNode node, AbstractTypeDeclaration declaration) { final TypeDeclarationStatement statement= (TypeDeclarationStatement) ASTNodes.getParent(node, TypeDeclarationStatement.class); return statement != null && ASTNodes.isParent(statement, declaration); }
@Override public final void endVisit(final TypeDeclarationStatement node) { fTypeDeclarationStatement= false; super.endVisit(node); }
@Override public final boolean visit(final TypeDeclarationStatement node) { fTypeDeclarationStatement= true; return super.visit(node); }
@Override public void endVisit(TypeDeclarationStatement node) { if (skipNode(node)) return; assignFlowInfo(node, node.getDeclaration()); }
@Override public boolean visit(TypeDeclarationStatement node) { if (node.subtreeMatch(fMatcher, fNodeToMatch)) return matches(node); return super.visit(node); }
@Override public boolean visit(TypeDeclarationStatement node) { add(fCreator.create(node)); return true; }
@Override public void endVisit(TypeDeclarationStatement node) { endVisitNode(node); }
@Override public boolean visit(TypeDeclarationStatement node) { return visitNode(node); }
@Override public boolean visit(TypeDeclarationStatement node) { // don't dive into local type declarations. return false; }