Example usage for org.eclipse.jdt.core.dom PrefixExpression.Operator toString

List of usage examples for org.eclipse.jdt.core.dom PrefixExpression.Operator toString

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom PrefixExpression.Operator toString.

Prototype

@Override
public final String toString() 

Source Link

Document

Returns a string representation of this node suitable for debugging purposes only.

Usage

From source file:org.eclipse.jem.workbench.utility.ParseTreeCreationFromAST.java

License:Open Source License

public boolean visit(PrefixExpression node) {
    if (node.getOperand().getNodeType() == ASTNode.NUMBER_LITERAL) {
        // For number literals we see if it is a "+" or "-" prefix, and if it is, we simply
        // create a PTNumberLiteral with the operator already in it. It is a simplification.
        // Any other operator we've left alone since those won't be decoded simply by the
        // Number decoder.
        // If not a number literal, then leave alone since needs to be handled as a prefix
        // operation.
        PrefixExpression.Operator operator = node.getOperator();
        if (operator == PrefixExpression.Operator.PLUS || operator == PrefixExpression.Operator.MINUS) {
            PTNumberLiteral nm = InstantiationFactory.eINSTANCE.createPTNumberLiteral();
            nm.setToken(operator.toString() + ((NumberLiteral) node.getOperand()).getToken());
            expression = nm;//  w  w w  .ja va  2  s  . co m
            return false;
        }
    }

    PTPrefixExpression pe = InstantiationFactory.eINSTANCE.createPTPrefixExpression();
    PTPrefixOperator ptoper = getParsePrefix(node.getOperator());
    if (ptoper == null) {
        // It is not one we can handle.
        throw new InvalidExpressionException(MessageFormat.format(
                WorkbenchUtilityMessages.ParseTreeCreationFromAST_OperatorTooComplicatedToHandle_EXC_,
                new Object[] { node.getOperator().toString() }));
    }
    pe.setOperator(ptoper);
    pe.setExpression(perform(node.getOperand()));
    expression = pe;
    return false;
}