Example usage for org.eclipse.jdt.internal.compiler.flow FlowInfo markAsComparedEqualToNonNull

List of usage examples for org.eclipse.jdt.internal.compiler.flow FlowInfo markAsComparedEqualToNonNull

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.flow FlowInfo markAsComparedEqualToNonNull.

Prototype

abstract public void markAsComparedEqualToNonNull(LocalVariableBinding local);

Source Link

Document

Record that a local variable got checked to be non null.

Usage

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.util.AstGenerator.java

License:Open Source License

public Expression nullCheck(Expression value) {
    EqualExpression result = new EqualExpression(value, nullLiteral(), OperatorIds.EQUAL_EQUAL) {
        protected void checkVariableComparison(BlockScope scope, FlowContext flowContext, FlowInfo flowInfo,
                FlowInfo initsWhenTrue, FlowInfo initsWhenFalse, LocalVariableBinding local, int nullStatus,
                Expression reference) {
            // similar to super version: do mark flowInfo but avoid reporting any problems
            switch (nullStatus) {
            case FlowInfo.NULL:
                if (((this.bits & OperatorMASK) >> OperatorSHIFT) == EQUAL_EQUAL) {
                    initsWhenTrue.markAsComparedEqualToNull(local); // from thereon it is set
                    initsWhenFalse.markAsComparedEqualToNonNull(local); // from thereon it is set
                } else {
                    initsWhenTrue.markAsComparedEqualToNonNull(local); // from thereon it is set
                    initsWhenFalse.markAsComparedEqualToNull(local); // from thereon it is set
                }/*w  w w.  ja  va2 s .c o  m*/
                break;
            case FlowInfo.NON_NULL:
                if (((this.bits & OperatorMASK) >> OperatorSHIFT) == EQUAL_EQUAL) {
                    initsWhenTrue.markAsComparedEqualToNonNull(local); // from thereon it is set
                }
                break;
            }
        }
    };
    result.sourceStart = this.sourceStart;
    result.sourceEnd = this.sourceEnd;
    result.constant = Constant.NotAConstant;
    result.isGenerated = true;
    return result;
}