Java 类org.eclipse.jdt.internal.compiler.ast.InstanceOfExpression 实例源码

项目:Eclipse-Postfix-Code-Completion    文件:CodeFormatterVisitor.java   
/**
 * @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.InstanceOfExpression, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
 */
public boolean visit(
    InstanceOfExpression instanceOfExpression,
    BlockScope scope) {

    final int numberOfParens = (instanceOfExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
    if (numberOfParens > 0) {
        manageOpeningParenthesizedExpression(instanceOfExpression, numberOfParens);
    }
    instanceOfExpression.expression.traverse(this, scope);
    this.scribe.printNextToken(TerminalTokens.TokenNameinstanceof, true);
    this.scribe.space();
    instanceOfExpression.type.traverse(this, scope);

    if (numberOfParens > 0) {
        manageClosingParenthesizedExpression(instanceOfExpression, numberOfParens);
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion    文件:Parser.java   
protected void consumeInstanceOfExpression() {
    // RelationalExpression ::= RelationalExpression 'instanceof' ReferenceType
    //optimize the push/pop

    //by construction, no base type may be used in getTypeReference
    Expression exp;
    this.expressionStack[this.expressionPtr] = exp =
        new InstanceOfExpression(
            this.expressionStack[this.expressionPtr],
            getTypeReference(this.intStack[this.intPtr--]));
    if (exp.sourceEnd == 0) {
        //array on base type....
        exp.sourceEnd = this.scanner.startPosition - 1;
    }
    //the scanner is on the next token already....
}
项目:Eclipse-Postfix-Code-Completion    文件:Parser.java   
protected void consumeInstanceOfExpressionWithName() {
    // RelationalExpression_NotName ::= Name instanceof ReferenceType
    //optimize the push/pop

    //by construction, no base type may be used in getTypeReference
    TypeReference reference = getTypeReference(this.intStack[this.intPtr--]);
    pushOnExpressionStack(getUnspecifiedReferenceOptimized());
    Expression exp;
    this.expressionStack[this.expressionPtr] = exp =
        new InstanceOfExpression(
            this.expressionStack[this.expressionPtr],
            reference);
    if (exp.sourceEnd == 0) {
        //array on base type....
        exp.sourceEnd = this.scanner.startPosition - 1;
    }
    //the scanner is on the next token already....
}
项目:Eclipse-Postfix-Code-Completion    文件:ProblemReporter.java   
public void notCompatibleTypesError(InstanceOfExpression expression, TypeBinding leftType, TypeBinding rightType) {
    String leftName = new String(leftType.readableName());
    String rightName = new String(rightType.readableName());
    String leftShortName = new String(leftType.shortReadableName());
    String rightShortName = new String(rightType.shortReadableName());
    if (leftShortName.equals(rightShortName)){
        leftShortName = leftName;
        rightShortName = rightName;
    }
    this.handle(
        IProblem.IncompatibleTypesInConditionalOperator,
        new String[] {leftName, rightName },
        new String[] {leftShortName, rightShortName },
        expression.sourceStart,
        expression.sourceEnd);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CodeFormatterVisitor.java   
/**
 * @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.InstanceOfExpression, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
 */
public boolean visit(
    InstanceOfExpression instanceOfExpression,
    BlockScope scope) {

    final int numberOfParens = (instanceOfExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
    if (numberOfParens > 0) {
        manageOpeningParenthesizedExpression(instanceOfExpression, numberOfParens);
    }
    instanceOfExpression.expression.traverse(this, scope);
    this.scribe.printNextToken(TerminalTokens.TokenNameinstanceof, true);
    this.scribe.space();
    instanceOfExpression.type.traverse(this, scope);

    if (numberOfParens > 0) {
        manageClosingParenthesizedExpression(instanceOfExpression, numberOfParens);
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ProblemReporter.java   
public void notCompatibleTypesError(InstanceOfExpression expression, TypeBinding leftType, TypeBinding rightType) {
    String leftName = new String(leftType.readableName());
    String rightName = new String(rightType.readableName());
    String leftShortName = new String(leftType.shortReadableName());
    String rightShortName = new String(rightType.shortReadableName());
    if (leftShortName.equals(rightShortName)){
        leftShortName = leftName;
        rightShortName = rightName;
    }
    this.handle(
        IProblem.IncompatibleTypesInConditionalOperator,
        new String[] {leftName, rightName },
        new String[] {leftShortName, rightShortName },
        expression.sourceStart,
        expression.sourceEnd);
}
项目:Eclipse-Postfix-Code-Completion    文件:ProblemReporter.java   
public void unnecessaryInstanceof(InstanceOfExpression instanceofExpression, TypeBinding checkType) {
    int severity = computeSeverity(IProblem.UnnecessaryInstanceof);
    if (severity == ProblemSeverities.Ignore) return;
    TypeBinding expressionType = instanceofExpression.expression.resolvedType;
    this.handle(
        IProblem.UnnecessaryInstanceof,
        new String[]{ new String(expressionType.readableName()), new String(checkType.readableName())},
        new String[]{ new String(expressionType.shortReadableName()), new String(checkType.shortReadableName())},
        severity,
        instanceofExpression.sourceStart,
        instanceofExpression.sourceEnd);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ProblemReporter.java   
public void unnecessaryInstanceof(InstanceOfExpression instanceofExpression, TypeBinding checkType) {
    int severity = computeSeverity(IProblem.UnnecessaryInstanceof);
    if (severity == ProblemSeverities.Ignore) return;
    TypeBinding expressionType = instanceofExpression.expression.resolvedType;
    this.handle(
        IProblem.UnnecessaryInstanceof,
        new String[]{ new String(expressionType.readableName()), new String(checkType.readableName())},
        new String[]{ new String(expressionType.shortReadableName()), new String(checkType.shortReadableName())},
        severity,
        instanceofExpression.sourceStart,
        instanceofExpression.sourceEnd);
}
项目:xapi    文件:GwtAstBuilder.java   
@Override
public void endVisit(InstanceOfExpression x, BlockScope scope) {
  try {
    SourceInfo info = makeSourceInfo(x);
    JExpression expr = pop(x.expression);
    JReferenceType testType = (JReferenceType) typeMap.get(x.type.resolvedType);
    push(new JInstanceOf(info, testType, expr));
  } catch (Throwable e) {
    throw translateException(x, e);
  }
}
项目:lombok-ianchiu    文件:HandleEqualsAndHashCode.java   
public MethodDeclaration createCanEqual(EclipseNode type, ASTNode source, List<Annotation> onParam) {
    /* protected boolean canEqual(final java.lang.Object other) {
     *     return other instanceof Outer.Inner.MyType;
     * }
     */
    int pS = source.sourceStart; int pE = source.sourceEnd;
    long p = (long)pS << 32 | pE;

    char[] otherName = "other".toCharArray();

    MethodDeclaration method = new MethodDeclaration(
            ((CompilationUnitDeclaration) type.top().get()).compilationResult);
    setGeneratedBy(method, source);
    method.modifiers = toEclipseModifier(AccessLevel.PROTECTED);
    method.returnType = TypeReference.baseTypeReference(TypeIds.T_boolean, 0);
    method.returnType.sourceStart = pS; method.returnType.sourceEnd = pE;
    setGeneratedBy(method.returnType, source);
    method.selector = "canEqual".toCharArray();
    method.thrownExceptions = null;
    method.typeParameters = null;
    method.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG;
    method.bodyStart = method.declarationSourceStart = method.sourceStart = source.sourceStart;
    method.bodyEnd = method.declarationSourceEnd = method.sourceEnd = source.sourceEnd;
    TypeReference objectRef = new QualifiedTypeReference(TypeConstants.JAVA_LANG_OBJECT, new long[] { p, p, p });
    setGeneratedBy(objectRef, source);
    method.arguments = new Argument[] {new Argument(otherName, 0, objectRef, Modifier.FINAL)};
    method.arguments[0].sourceStart = pS; method.arguments[0].sourceEnd = pE;
    if (!onParam.isEmpty()) method.arguments[0].annotations = onParam.toArray(new Annotation[0]);
    setGeneratedBy(method.arguments[0], source);

    SingleNameReference otherRef = new SingleNameReference(otherName, p);
    setGeneratedBy(otherRef, source);

    TypeReference typeReference = createTypeReference(type, p);
    setGeneratedBy(typeReference, source);

    InstanceOfExpression instanceOf = new InstanceOfExpression(otherRef, typeReference);
    instanceOf.sourceStart = pS; instanceOf.sourceEnd = pE;
    setGeneratedBy(instanceOf, source);

    ReturnStatement returnStatement = new ReturnStatement(instanceOf, pS, pE);
    setGeneratedBy(returnStatement, source);

    method.statements = new Statement[] {returnStatement};
    return method;
}
项目:lombok-ianchiu    文件:SetGeneratedByVisitor.java   
@Override public boolean visit(InstanceOfExpression node, BlockScope scope) {
    fixPositions(setGeneratedBy(node, source));
    return super.visit(node, scope);
}
项目:EasyMPermission    文件:HandleEqualsAndHashCode.java   
public MethodDeclaration createCanEqual(EclipseNode type, ASTNode source, List<Annotation> onParam) {
    /* public boolean canEqual(final java.lang.Object other) {
     *     return other instanceof Outer.Inner.MyType;
     * }
     */
    int pS = source.sourceStart; int pE = source.sourceEnd;
    long p = (long)pS << 32 | pE;

    char[] otherName = "other".toCharArray();

    MethodDeclaration method = new MethodDeclaration(
            ((CompilationUnitDeclaration) type.top().get()).compilationResult);
    setGeneratedBy(method, source);
    method.modifiers = toEclipseModifier(AccessLevel.PROTECTED);
    method.returnType = TypeReference.baseTypeReference(TypeIds.T_boolean, 0);
    method.returnType.sourceStart = pS; method.returnType.sourceEnd = pE;
    setGeneratedBy(method.returnType, source);
    method.selector = "canEqual".toCharArray();
    method.thrownExceptions = null;
    method.typeParameters = null;
    method.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG;
    method.bodyStart = method.declarationSourceStart = method.sourceStart = source.sourceStart;
    method.bodyEnd = method.declarationSourceEnd = method.sourceEnd = source.sourceEnd;
    TypeReference objectRef = new QualifiedTypeReference(TypeConstants.JAVA_LANG_OBJECT, new long[] { p, p, p });
    setGeneratedBy(objectRef, source);
    method.arguments = new Argument[] {new Argument(otherName, 0, objectRef, Modifier.FINAL)};
    method.arguments[0].sourceStart = pS; method.arguments[0].sourceEnd = pE;
    if (!onParam.isEmpty()) method.arguments[0].annotations = onParam.toArray(new Annotation[0]);
    setGeneratedBy(method.arguments[0], source);

    SingleNameReference otherRef = new SingleNameReference(otherName, p);
    setGeneratedBy(otherRef, source);

    TypeReference typeReference = createTypeReference(type, p);
    setGeneratedBy(typeReference, source);

    InstanceOfExpression instanceOf = new InstanceOfExpression(otherRef, typeReference);
    instanceOf.sourceStart = pS; instanceOf.sourceEnd = pE;
    setGeneratedBy(instanceOf, source);

    ReturnStatement returnStatement = new ReturnStatement(instanceOf, pS, pE);
    setGeneratedBy(returnStatement, source);

    method.statements = new Statement[] {returnStatement};
    return method;
}
项目:EasyMPermission    文件:SetGeneratedByVisitor.java   
@Override public boolean visit(InstanceOfExpression node, BlockScope scope) {
    fixPositions(setGeneratedBy(node, source));
    return super.visit(node, scope);
}
项目:Eclipse-Postfix-Code-Completion    文件:BinaryExpressionFragmentBuilder.java   
public boolean visit(
    InstanceOfExpression instanceOfExpression,
    BlockScope scope) {
        addRealFragment(instanceOfExpression);
        return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:BinaryExpressionFragmentBuilder.java   
public boolean visit(
    InstanceOfExpression instanceOfExpression,
    BlockScope scope) {
        addRealFragment(instanceOfExpression);
        return false;
}
项目:lombok    文件:HandleEqualsAndHashCode.java   
private MethodDeclaration createCanEqual(EclipseNode type, ASTNode source) {
    /* public boolean canEqual(final java.lang.Object other) {
     *     return other instanceof Outer.Inner.MyType;
     * }
     */
    int pS = source.sourceStart; int pE = source.sourceEnd;
    long p = (long)pS << 32 | pE;

    char[] otherName = "other".toCharArray();

    MethodDeclaration method = new MethodDeclaration(
            ((CompilationUnitDeclaration) type.top().get()).compilationResult);
    setGeneratedBy(method, source);
    method.modifiers = toEclipseModifier(AccessLevel.PUBLIC);
    method.returnType = TypeReference.baseTypeReference(TypeIds.T_boolean, 0);
    method.returnType.sourceStart = pS; method.returnType.sourceEnd = pE;
    setGeneratedBy(method.returnType, source);
    method.selector = "canEqual".toCharArray();
    method.thrownExceptions = null;
    method.typeParameters = null;
    method.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG;
    method.bodyStart = method.declarationSourceStart = method.sourceStart = source.sourceStart;
    method.bodyEnd = method.declarationSourceEnd = method.sourceEnd = source.sourceEnd;
    TypeReference objectRef = new QualifiedTypeReference(TypeConstants.JAVA_LANG_OBJECT, new long[] { p, p, p });
    setGeneratedBy(objectRef, source);
    method.arguments = new Argument[] {new Argument(otherName, 0, objectRef, Modifier.FINAL)};
    method.arguments[0].sourceStart = pS; method.arguments[0].sourceEnd = pE;
    setGeneratedBy(method.arguments[0], source);

    SingleNameReference otherRef = new SingleNameReference(otherName, p);
    setGeneratedBy(otherRef, source);

    TypeReference typeReference = createTypeReference(type, p);
    setGeneratedBy(typeReference, source);

    InstanceOfExpression instanceOf = new InstanceOfExpression(otherRef, typeReference);
    instanceOf.sourceStart = pS; instanceOf.sourceEnd = pE;
    setGeneratedBy(instanceOf, source);

    ReturnStatement returnStatement = new ReturnStatement(instanceOf, pS, pE);
    setGeneratedBy(returnStatement, source);

    method.statements = new Statement[] {returnStatement};
    return method;
}
项目:lombok    文件:SetGeneratedByVisitor.java   
@Override public boolean visit(InstanceOfExpression node, BlockScope scope) {
    setGeneratedBy(node, source);
    applyOffsetExpression(node);
    return super.visit(node, scope);
}