Example usage for org.eclipse.jdt.core.dom BooleanLiteral booleanValue

List of usage examples for org.eclipse.jdt.core.dom BooleanLiteral booleanValue

Introduction

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

Prototype

public boolean booleanValue() 

Source Link

Document

Returns the boolean value of this boolean literal node.

Usage

From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java

License:Open Source License

@Override
public boolean visit(BooleanLiteral node) {
    if (node.booleanValue() == true) {
        this.fBuffer.append("true");//$NON-NLS-1$
    } else {//w  w  w  .jav  a2  s.  co m
        this.fBuffer.append("false");//$NON-NLS-1$
    }
    return false;
}

From source file:boa.datagen.util.Java7Visitor.java

License:Apache License

@Override
public boolean visit(BooleanLiteral node) {
    boa.types.Ast.Expression.Builder b = boa.types.Ast.Expression.newBuilder();
    //      b.setPosition(pos.build());
    b.setKind(boa.types.Ast.Expression.ExpressionKind.LITERAL);
    if (node.booleanValue())
        b.setLiteral("true");
    else// ww w. j a v a  2 s .  c o m
        b.setLiteral("false");
    expressions.push(b.build());
    return false;
}

From source file:coloredide.utils.CopiedNaiveASTFlattener.java

License:Open Source License

public boolean visit(BooleanLiteral node) {
    if (node.booleanValue() == true) {
        this.buffer.append("true");//$NON-NLS-1$
    } else {/*from   w  w  w. j ava 2s .  com*/
        this.buffer.append("false");//$NON-NLS-1$
    }
    return false;
}

From source file:com.google.dart.java2dart.SyntaxTranslator.java

License:Open Source License

@Override
public boolean visit(org.eclipse.jdt.core.dom.BooleanLiteral node) {
    boolean value = node.booleanValue();
    return done(booleanLiteral(value));
}

From source file:com.google.devtools.j2cpp.gen.CppStatementGenerator.java

License:Open Source License

@Override
public boolean visit(BooleanLiteral node) {
    buffer.append(node.booleanValue() ? "YES" : "NO");
    return false;
}

From source file:com.google.devtools.j2objc.ast.DebugASTPrinter.java

License:Apache License

@Override
public boolean visit(BooleanLiteral node) {
    sb.print(node.booleanValue() ? "true" : "false");
    return false;
}

From source file:com.halware.nakedide.eclipse.ext.annot.utils.AstUtils.java

License:Open Source License

public static Object getValue(ASTNode node) {

    switch (node.getNodeType()) {
    //         case ASTNode.ANONYMOUS_CLASS_DECLARATION:
    //            return "Anonymous class declaration";
    //         case ASTNode.ARRAY_ACCESS:
    //            return "Array access";
    //         case ASTNode.ARRAY_CREATION:
    //            return "Array creation";
    //         case ASTNode.ARRAY_INITIALIZER:
    //            return "Array initializer";
    //         case ASTNode.ARRAY_TYPE:
    //            ArrayType arrayType = (ArrayType)node;
    //            return "Array type: " + arrayType.getElementType().toString();
    //         case ASTNode.ASSERT_STATEMENT:
    //            return "Assert statement";
    //         case ASTNode.ASSIGNMENT:
    //            return "Assignment";
    //         case ASTNode.BLOCK:
    //            return "Block";
    case ASTNode.BOOLEAN_LITERAL:
        BooleanLiteral booleanLiteral = (BooleanLiteral) node;
        return booleanLiteral.booleanValue();
    //         case ASTNode.BREAK_STATEMENT:
    //            return "Break statement";
    //         case ASTNode.CAST_EXPRESSION:
    //            return "Cast expression";
    //         case ASTNode.CATCH_CLAUSE:
    //            return "Catch clause";
    case ASTNode.CHARACTER_LITERAL:
        CharacterLiteral characterLiteral = (CharacterLiteral) node;
        return characterLiteral.charValue();
    //         case ASTNode.CLASS_INSTANCE_CREATION:
    //            return "Class instance creation";
    //         case ASTNode.COMPILATION_UNIT:
    //            return "Compilation unit";
    //         case ASTNode.CONDITIONAL_EXPRESSION:
    //            return "Conditional Expression";
    //         case ASTNode.CONSTRUCTOR_INVOCATION:
    //            return "constructor invocation";
    //         case ASTNode.CONTINUE_STATEMENT:
    //            return "continue statement";
    //         case ASTNode.DO_STATEMENT:
    //            return "Do statement";
    //         case ASTNode.EMPTY_STATEMENT:
    //            return "Empty statement";
    //         case ASTNode.EXPRESSION_STATEMENT:
    //            return "Expression statement";
    //         case ASTNode.FIELD_ACCESS:
    //            return "field access";
    //         case ASTNode.FIELD_DECLARATION:
    //            return "Field declaration";
    //         case ASTNode.FOR_STATEMENT:
    //            return "For statement";
    //         case ASTNode.IF_STATEMENT:
    //            return "If statement";
    //         case ASTNode.IMPORT_DECLARATION:
    //            return "Import declaration";
    //         case ASTNode.INFIX_EXPRESSION:
    //            return "Infix expression";
    //         case ASTNode.INITIALIZER:
    //            return "Initializer";
    //         case ASTNode.INSTANCEOF_EXPRESSION:
    //            return "Instanceof expression";
    //         case ASTNode.JAVADOC:
    //            return "Javadoc";
    //         case ASTNode.LABELED_STATEMENT:
    //            return "Labeled statement";
    //         case ASTNode.METHOD_DECLARATION:
    //            return "Method declaration";
    //         case ASTNode.METHOD_INVOCATION:
    //            return "Method invocation";
    //         case ASTNode.NULL_LITERAL:
    //            return "Null literal";
    case ASTNode.NUMBER_LITERAL:
        NumberLiteral numberLiteral = (NumberLiteral) node;
        String token = numberLiteral.getToken();
        try {/*  w w w  .  ja va  2 s.  com*/
            return Integer.parseInt(token);
        } catch (Exception ex) {
        }
        try {
            return Long.parseLong(token);
        } catch (Exception ex) {
        }
        try {
            return Double.parseDouble(token);
        } catch (Exception ex) {
        }
        try {
            return Float.parseFloat(token);
        } catch (Exception ex) {
        }
        return Double.NaN;
    //         case ASTNode.PACKAGE_DECLARATION:
    //            return "Package declaration";
    //         case ASTNode.PARENTHESIZED_EXPRESSION:
    //            return "Parenthesized expression";
    //         case ASTNode.POSTFIX_EXPRESSION:
    //            return "Postfix expression";
    //         case ASTNode.PREFIX_EXPRESSION:
    //            return "Prefix expression";
    //         case ASTNode.PRIMITIVE_TYPE:
    //            PrimitiveType primitiveType = (PrimitiveType) node;
    //            return "Primitive type: " + primitiveType.getPrimitiveTypeCode().toString();
    case ASTNode.QUALIFIED_NAME:
        QualifiedName qualifiedName = (QualifiedName) node;
        return new AstUtils.QualifiedNameValue(qualifiedName.getQualifier().getFullyQualifiedName(),
                qualifiedName.getName().getIdentifier());
    //         case ASTNode.RETURN_STATEMENT:
    //            return "Return statement";
    //         case ASTNode.SIMPLE_NAME:
    //            SimpleName simpleName = (SimpleName) node;
    //            return "Simple name: " + simpleName.getIdentifier();
    //         case ASTNode.SIMPLE_TYPE:
    //            SimpleType simpleType = (SimpleType) node;
    //            return "Simple type (" + simpleType.getName().toString() + ")";
    //         case ASTNode.SINGLE_VARIABLE_DECLARATION:
    //            return "Single variable declaration";
    case ASTNode.STRING_LITERAL:
        StringLiteral stringLiteral = (StringLiteral) node;
        return stringLiteral.getLiteralValue();
    //         case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
    //            return "Super constructor invocation";
    //         case ASTNode.SUPER_FIELD_ACCESS:
    //            return "Super field access";
    //         case ASTNode.SUPER_METHOD_INVOCATION:
    //            return "Super method invocation";
    //         case ASTNode.SWITCH_CASE:
    //            return "Switch case";
    //         case ASTNode.SWITCH_STATEMENT:
    //            return "Switch statement";
    //         case ASTNode.SYNCHRONIZED_STATEMENT:
    //            return "Synchronized statement";
    //         case ASTNode.THIS_EXPRESSION:
    //            return "This expression";
    //         case ASTNode.THROW_STATEMENT:
    //            return "Throw statement";
    //         case ASTNode.TRY_STATEMENT:
    //            return "Try statement";
    //         case ASTNode.TYPE_DECLARATION:
    //            return "Type declaration";
    //         case ASTNode.TYPE_DECLARATION_STATEMENT:
    //            return "Type declaration statement";
    case ASTNode.TYPE_LITERAL:
        TypeLiteral typeLiteral = (TypeLiteral) node;
        return new AstUtils.TypeLiteralValue(typeLiteral.toString());
    //         case ASTNode.VARIABLE_DECLARATION_EXPRESSION:
    //            return "Varialbe declaration expression";
    //         case ASTNode.VARIABLE_DECLARATION_FRAGMENT:
    //            return "Variable declaration fragment";
    //         case ASTNode.VARIABLE_DECLARATION_STATEMENT:
    //            return "Variable declaration statement";
    //         case ASTNode.WHILE_STATEMENT:
    //            return "While statement";
    }
    return null;
}

From source file:com.ibm.wala.cast.java.translator.jdt.JDTJava2CAstTranslator.java

License:Open Source License

private CAstNode visit(BooleanLiteral n, WalkContext context) {
    return fFactory.makeConstant(n.booleanValue());
}

From source file:edu.cmu.cs.crystal.analysis.constant.ConstantTransferFunction.java

License:Open Source License

public IResult<TupleLatticeElement<Variable, BooleanConstantLE>> transfer(LoadLiteralInstruction instr,
        List<ILabel> labels, TupleLatticeElement<Variable, BooleanConstantLE> value) {
    if (instr.getNode() instanceof BooleanLiteral) {
        BooleanLiteral boolNode = (BooleanLiteral) instr.getNode();

        if (labels.contains(BooleanLabel.getBooleanLabel(true))
                && labels.contains(BooleanLabel.getBooleanLabel(false))) {
            TupleLatticeElement<Variable, BooleanConstantLE> tVal, fVal;
            LabeledResult<TupleLatticeElement<Variable, BooleanConstantLE>> result = LabeledResult
                    .createResult(value);

            tVal = ops.copy(value);//from  w  w w  . java  2s  . com
            fVal = ops.copy(value);

            tVal.put(instr.getTarget(),
                    boolNode.booleanValue() ? BooleanConstantLE.TRUE : BooleanConstantLE.BOTTOM);
            fVal.put(instr.getTarget(),
                    !boolNode.booleanValue() ? BooleanConstantLE.FALSE : BooleanConstantLE.BOTTOM);
            value.put(instr.getTarget(),
                    boolNode.booleanValue() ? BooleanConstantLE.TRUE : BooleanConstantLE.FALSE);

            result.put(BooleanLabel.getBooleanLabel(true), tVal);
            result.put(BooleanLabel.getBooleanLabel(false), fVal);
            return result;
        } else
            value.put(instr.getTarget(),
                    boolNode.booleanValue() ? BooleanConstantLE.TRUE : BooleanConstantLE.FALSE);
    }

    return LabeledSingleResult.createResult(value, labels);
}

From source file:edu.cmu.cs.crystal.tac.eclipse.EclipseTACInstructionFactory.java

License:Open Source License

public TACInstruction create(BooleanLiteral node, IEclipseVariableQuery eclipseVariableQuery) {
    return new LoadLiteralInstructionImpl(node, node.booleanValue(), eclipseVariableQuery);
}