Example usage for org.eclipse.jdt.core.dom TryStatement delete

List of usage examples for org.eclipse.jdt.core.dom TryStatement delete

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom TryStatement delete.

Prototype

public final void delete() 

Source Link

Document

Removes this node from its parent.

Usage

From source file:ch.acanda.eclipse.pmd.java.resolution.emptycode.EmptyFinallyBlockQuickFix.java

License:Open Source License

/**
 * Removes the finally block. Additionally removes the try if there are no catch blocks while keeping the try block
 * statements.// ww w .j av  a2  s .c  o  m
 */
@Override
protected boolean apply(final TryStatement node) {
    boolean success = true;
    if (node.catchClauses().isEmpty()) {
        @SuppressWarnings("unchecked")
        final List<Statement> statements = node.getBody().statements();
        if (replace(node, copy(statements))) {
            node.delete();
        } else {
            success = false;
        }
    } else {
        node.setFinally(null);
    }
    return success;
}

From source file:ch.acanda.eclipse.pmd.java.resolution.emptycode.EmptyTryBlockQuickFix.java

License:Open Source License

@Override
protected boolean apply(final TryStatement node) {
    node.delete();
    return true;
}

From source file:sourcecodefilter.filter.TryCatchFilter.java

License:Open Source License

public boolean visit(final TryStatement node) {
    final String expression = node.getBody().toString();
    for (String expectedExpression : tryCatchBlocksToBeRemoved) {
        if (expression.contains(expectedExpression)) {
            node.delete();
        }/*  www  .j av  a2 s.c o m*/
    }
    return false;
}