List of usage examples for org.eclipse.jdt.core.dom ImportDeclaration delete
public final void delete()
From source file:com.google.devtools.j2cpp.translate.DeadCodeEliminator.java
License:Open Source License
@Override public void endVisit(ImportDeclaration node) { IBinding binding = node.resolveBinding(); if (binding instanceof IMethodBinding) { // Remove static imports for dead methods IMethodBinding method = (IMethodBinding) binding; if (allMethodsDeadWithName(method.getDeclaringClass(), getProGuardName(method))) { node.delete(); }/*w ww .j ava2 s. c o m*/ } else if (binding instanceof IVariableBinding) { // Remove static imports for dead non-constant fields IVariableBinding var = (IVariableBinding) binding; String clazz = Types.getSignature(var.getDeclaringClass()); String name = var.getName(); if (deadCodeMap.isDeadField(clazz, name) && var.getConstantValue() == null) { node.delete(); } } // Skip on-demand imports }
From source file:fr.opensagres.maven.plugins.noannotations.RemoveAnnotationsMojo.java
License:Apache License
private void removeUnusedImports(final CompilationUnit cu, final Set<Name> annotations) { cu.accept(new ASTVisitor() { @Override//from w w w. ja va2 s . c o m public boolean visit(ImportDeclaration node) { for (Name name : annotations) { if (node.getName().getFullyQualifiedName().endsWith("." + name.getFullyQualifiedName())) { node.delete(); } } return super.visit(node); } }); }