Example usage for org.eclipse.jdt.internal.compiler.ast ASTNode IsDiamond

List of usage examples for org.eclipse.jdt.internal.compiler.ast ASTNode IsDiamond

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.ast ASTNode IsDiamond.

Prototype

int IsDiamond

To view the source code for org.eclipse.jdt.internal.compiler.ast ASTNode IsDiamond.

Click Source Link

Usage

From source file:org.eclipse.jdt.internal.compiler.parser.Parser.java

License:Open Source License

protected void checkForDiamond(TypeReference allocType) {
    if (allocType instanceof ParameterizedSingleTypeReference) {
        ParameterizedSingleTypeReference type = (ParameterizedSingleTypeReference) allocType;
        if (type.typeArguments == TypeReference.NO_TYPE_ARGUMENTS) {
            if (this.options.sourceLevel < ClassFileConstants.JDK1_7) {
                problemReporter().diamondNotBelow17(allocType);
            }/*www  . jav a 2s  . c  o m*/
            if (this.options.sourceLevel > ClassFileConstants.JDK1_4) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=351965
                type.bits |= ASTNode.IsDiamond;
            } // else don't even bother to recognize this as <>
        }
    } else if (allocType instanceof ParameterizedQualifiedTypeReference) {
        ParameterizedQualifiedTypeReference type = (ParameterizedQualifiedTypeReference) allocType;
        if (type.typeArguments[type.typeArguments.length - 1] == TypeReference.NO_TYPE_ARGUMENTS) { // Don't care for X<>.Y<> and X<>.Y<String>
            if (this.options.sourceLevel < ClassFileConstants.JDK1_7) {
                problemReporter().diamondNotBelow17(allocType, type.typeArguments.length - 1);
            }
            if (this.options.sourceLevel > ClassFileConstants.JDK1_4) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=351965
                type.bits |= ASTNode.IsDiamond;
            } // else don't even bother to recognize this as <>
        }
    }
}