Example usage for org.eclipse.jdt.core.dom ParenthesizedExpression getLength

List of usage examples for org.eclipse.jdt.core.dom ParenthesizedExpression getLength

Introduction

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

Prototype

public final int getLength() 

Source Link

Document

Returns the length in characters of the original source file indicating where the source fragment corresponding to this node ends.

Usage

From source file:org.eclipse.wb.internal.core.utils.ast.AstEditor.java

License:Open Source License

/**
 * Inlines all {@link ParenthesizedExpression} that enclose given {@link Expression}.
 *//*  w ww  .  j a v  a  2  s  .com*/
public void inlineParenthesizedExpression(Expression expression) throws Exception {
    while (expression.getParent() instanceof ParenthesizedExpression) {
        ParenthesizedExpression parent = (ParenthesizedExpression) expression.getParent();
        parent.setExpression(expression.getAST().newSimpleName("__wbp_tmp"));
        replaceNode(parent, expression);
        replaceSubstring(parent.getStartPosition(), parent.getLength(), getSource(expression));
        AstNodeUtils.setSourceBegin(expression, parent.getStartPosition());
    }
}