List of usage examples for org.eclipse.jdt.core.dom VariableDeclaration toString
@Override public final String toString()
From source file:org.eclipse.wb.internal.core.utils.ast.AstEditor.java
License:Open Source License
/** * Removes {@link VariableDeclaration}.//w w w. j a va 2s. c o m */ public void removeVariableDeclaration(VariableDeclaration declaration) throws Exception { ASTNode parent = declaration.getParent(); if (parent instanceof FieldDeclaration) { // field FieldDeclaration fieldDeclaration = (FieldDeclaration) parent; List<VariableDeclarationFragment> fragments = DomGenerics.fragments(fieldDeclaration); if (fragments.size() == 1) { removeBodyDeclaration(fieldDeclaration); } else { removeVariableDeclaration(fieldDeclaration, fragments, fragments.indexOf(declaration)); } } else if (parent instanceof VariableDeclarationStatement) { // local variable VariableDeclarationStatement variableDeclaration = (VariableDeclarationStatement) declaration .getParent(); List<VariableDeclarationFragment> fragments = DomGenerics.fragments(variableDeclaration); if (fragments.size() == 1) { removeEnclosingStatement(declaration); } else { removeVariableDeclaration(variableDeclaration, fragments, fragments.indexOf(declaration)); } } else { // can't remove other cases throw new IllegalArgumentException( "Can not remove VariableDeclaration '" + declaration.toString() + "'"); } }
From source file:sourcecodefilter.filter.VariableDeclarationFilter.java
License:Open Source License
public boolean visit(final VariableDeclaration node) { final String fullName = node.toString(); for (String expectedDeclaration : variableDeclarationsToBeRemoved) { if (fullName.equals(expectedDeclaration)) { node.getParent().delete();/* w w w . ja va 2 s.c o m*/ } } return false; }