Package org.eclipse.jdt.internal.compiler.ast

Examples of org.eclipse.jdt.internal.compiler.ast.Expression


    final int numberOfParens = (qualifiedAllocationExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
    if (numberOfParens > 0) {
      manageOpeningParenthesizedExpression(qualifiedAllocationExpression, numberOfParens);
    }
    final Expression enclosingInstance = qualifiedAllocationExpression.enclosingInstance;
    if (enclosingInstance != null) {
      enclosingInstance.traverse(this, scope);
      this.scribe.printNextToken(TerminalTokens.TokenNameDOT);
    }

    this.scribe.printNextToken(TerminalTokens.TokenNamenew);
    // used for the new line on wrap style of formatting
View Full Code Here


   * @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.ReturnStatement, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
   */
  public boolean visit(ReturnStatement returnStatement, BlockScope scope) {

    this.scribe.printNextToken(TerminalTokens.TokenNamereturn);
    final Expression expression = returnStatement.expression;
    if (expression != null) {
      final int numberOfParens = (expression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
      if ((numberOfParens != 0 && this.preferences.insert_space_before_parenthesized_expression_in_return)
          || numberOfParens == 0) {
        this.scribe.space();
      }
      expression.traverse(this, scope);
    }
    /*
     * Print the semi-colon
     */
    this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
View Full Code Here

   * @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.ThrowStatement, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
   */
  public boolean visit(ThrowStatement throwStatement, BlockScope scope) {

    this.scribe.printNextToken(TerminalTokens.TokenNamethrow);
    Expression expression = throwStatement.exception;
    final int numberOfParens = (expression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
    if ((numberOfParens > 0 && this.preferences.insert_space_before_parenthesized_expression_in_throw)
        || numberOfParens == 0) {
      this.scribe.space();
    }
    expression.traverse(this, scope);
    /*
     * Print the semi-colon
     */
    this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
    this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
View Full Code Here

    boolean argHasError = false; // typeChecks all arguments
    int length = this.arguments.length;
    argumentTypes = new TypeBinding[length];
    TypeBinding argumentType;
    for (int i = 0; i < length; i++) {
      Expression argument = this.arguments[i];
      if (argument instanceof CastExpression) {
        argument.bits |= DisableUnnecessaryCastCheck; // will check later on
        argsContainCast = true;
      }
      argument.setExpressionContext(INVOCATION_CONTEXT);
      if ((argumentType = argumentTypes[i] = this.arguments[i].resolveType(scope)) == null)
        argHasError = true;
      if (argumentType != null && argumentType.kind() == Binding.POLY_TYPE) {
        if (this.innerInferenceHelper == null)
          this.innerInferenceHelper = new InnerInferenceHelper();
View Full Code Here

    this.scribe.printNextToken(operator, this.preferences.insert_space_before_unary_operator);
    if (this.preferences.insert_space_after_unary_operator) {
      this.scribe.space();
    }
    Expression expression = unaryExpression.expression;

    if (expression instanceof PrefixExpression) {
      PrefixExpression prefixExpression = (PrefixExpression) expression;
      final int numberOfParensForExpression = (prefixExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
      if (numberOfParensForExpression == 0) {
        switch(operatorValue) {
          case OperatorIds.PLUS:
            if (prefixExpression.operator == OperatorIds.PLUS) {
              this.scribe.space();
            }
            break;
          case OperatorIds.MINUS:
            if (prefixExpression.operator == OperatorIds.MINUS) {
              this.scribe.space();
            }
            break;
        }
      }
    } else if (expression instanceof UnaryExpression) {
      UnaryExpression unaryExpression2 = (UnaryExpression) expression;
      final int numberOfParensForExpression = (unaryExpression2.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
      if (numberOfParensForExpression == 0) {
        int operatorValue2 = (unaryExpression2.bits & ASTNode.OperatorMASK) >> ASTNode.OperatorSHIFT;
        switch(operatorValue) {
          case OperatorIds.PLUS:
            if (operatorValue2 == OperatorIds.PLUS) {
              this.scribe.space();
            }
            break;
          case OperatorIds.MINUS:
            if (operatorValue2 == OperatorIds.MINUS) {
              this.scribe.space();
            }
            break;
        }
      }
    }
    expression.traverse(this, scope);

    if (numberOfParens > 0) {
      manageClosingParenthesizedExpression(unaryExpression, numberOfParens);
    }
    return false;
View Full Code Here

      // collect containment info regarding all expressions in candidate constraints:
      // (a) find minimal enclosing expressions:
      Map<ConstraintExpressionFormula,ConstraintExpressionFormula> expressionContainedBy = new HashMap<ConstraintExpressionFormula, ConstraintExpressionFormula>();
      for (ConstraintFormula one : candidatesIII) {
        ConstraintExpressionFormula oneCEF = (ConstraintExpressionFormula) one;
        Expression exprOne = oneCEF.left;
        for (ConstraintFormula two : candidatesIII) {
          if (one == two) continue;
          ConstraintExpressionFormula twoCEF = (ConstraintExpressionFormula) two;
          Expression exprTwo = twoCEF.left;
          if (doesExpressionContain(exprOne, exprTwo)) {
            ConstraintExpressionFormula previous = expressionContainedBy.get(two);
            if (previous == null || doesExpressionContain(previous.left, exprOne)) // only if improving
              expressionContainedBy.put(twoCEF, oneCEF);
          }
View Full Code Here

    acceptPendingPolyArguments(bounds, parameterTypes, isVarargs);
    // This loops over all poly expressions for which a sub-inference was triggered:
    // (handles generic invocations)
    int len = this.innerPolies.size();
    for (int i = 0; i < len; i++) {
      Expression inner = (Expression) this.innerPolies.get(i);
      if (inner instanceof Invocation) {
        Invocation innerMessage = (Invocation) inner;
        TypeBinding innerTargetType = inner.expectedType(); // may be set from acceptPendingPolyArguments
        if (innerTargetType != null && !innerTargetType.isProperType(true))
          innerTargetType = null;
        MethodBinding binding = innerMessage.binding(innerTargetType, innerTargetType != null, this.scope);
        if (binding == null)
          continue;
        MethodBinding original = binding.shallowOriginal();

        // apply inference results onto the allocation type of inner diamonds:
        if (original.isConstructor() && inner.isPolyExpression()) {
          ReferenceBinding declaringClass = original.declaringClass;
          TypeBinding[] arguments = getSolutions(declaringClass.typeVariables(), innerMessage, bounds);
          declaringClass = this.environment.createParameterizedType(declaringClass, arguments, declaringClass.enclosingType());
          original = ((ParameterizedTypeBinding)declaringClass).createParameterizedMethod(original);
          inner.checkAgainstFinalTargetType(innerTargetType, this.scope)
          if (this.environment.globalOptions.isAnnotationBasedNullAnalysisEnabled)
            NullAnnotationMatching.checkForContraditions(original, innerMessage, this.scope);
        }
       
        // apply results of the combined inference onto the binding of the inner invocation:
View Full Code Here

    Substitution substitution = getResultSubstitution(acceptedResult);
    for (int i = 0; i < this.invocationArguments.length; i++) {
      TypeBinding targetType = getParameter(parameterTypes, i, isVarArgs);
      if (!targetType.isProperType(true))
        targetType = Scope.substitute(substitution, targetType);
      Expression expression = this.invocationArguments[i];
      if (expression instanceof Invocation) {
        Invocation invocation = (Invocation) expression;
        if (!this.innerPolies.contains(invocation)) {
          MethodBinding method = invocation.binding(targetType, true, this.scope);
          if (method instanceof ParameterizedGenericMethodBinding) {
            ParameterizedGenericMethodBinding previousBinding = (ParameterizedGenericMethodBinding) method;
            InferenceContext18 innerCtx = invocation.getInferenceContext(previousBinding);
            if (innerCtx != null) {
              // we have a non-poly generic invocation, which needs inference but is not connected via innerPolis.
              // Finish that inner inference now (incl. binding updates):
              MethodBinding innerBinding = innerCtx.inferInvocationType(invocation, previousBinding);
              if (!innerBinding.isValidBinding()) {
                innerCtx.reportInvalidInvocation(invocation, innerBinding);
              }
              if (invocation.updateBindings(innerBinding, targetType)) { // only if we are actually improving anything
                ASTNode.resolvePolyExpressionArguments(invocation, innerBinding, this.scope);
              }
            }
          } else if(method instanceof ParameterizedMethodBinding){
            expression.checkAgainstFinalTargetType(targetType, this.scope);
          }
        } else {
          expression.setExpectedType(targetType);
        }
      } else {
        expression.checkAgainstFinalTargetType(targetType, this.scope);
      }
    }
  }
View Full Code Here

          //$FALL-THROUGH$
        case CAN_ONLY_NULL | IN_COMPARISON_NULL:
        case CAN_ONLY_NULL | IN_COMPARISON_NON_NULL:
        case CAN_ONLY_NULL | IN_ASSIGNMENT:
        case CAN_ONLY_NULL | IN_INSTANCEOF:
          Expression expression = (Expression) location;
          if (flowInfo.isDefinitelyNull(local)) {
            switch(this.nullCheckTypes[i] & CONTEXT_MASK) {
              case FlowContext.IN_COMPARISON_NULL:
                if (((this.nullCheckTypes[i] & CHECK_MASK & ~HIDE_NULL_COMPARISON_WARNING_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning
                  scope.problemReporter().localVariableNullReference(local, expression);
View Full Code Here

          case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL:
          case CAN_ONLY_NULL | IN_COMPARISON_NULL:
          case CAN_ONLY_NULL | IN_COMPARISON_NON_NULL:
          case CAN_ONLY_NULL | IN_ASSIGNMENT:
          case CAN_ONLY_NULL | IN_INSTANCEOF:
            Expression reference = (Expression) location;
            if (flowInfo.cannotBeNull(local)) {
              if (checkTypeWithoutHideNullWarning == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) {
                if ((checkType & HIDE_NULL_COMPARISON_WARNING) == 0) {
                  scope.problemReporter().localVariableRedundantCheckOnNonNull(local, reference);
                }
                flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS);
              } else if (checkTypeWithoutHideNullWarning == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL)) {
                scope.problemReporter().localVariableNonNullComparedToNull(local, reference);
                flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS);
              }
              return;
            }
            if (flowInfo.canOnlyBeNull(local)) {
              switch(checkTypeWithoutHideNullWarning & CONTEXT_MASK) {
                case FlowContext.IN_COMPARISON_NULL:
                  if (((checkTypeWithoutHideNullWarning & CHECK_MASK) == CAN_ONLY_NULL) && (reference.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning
                    scope.problemReporter().localVariableNullReference(local, reference);
                    return;
                  }
                  if ((checkType & HIDE_NULL_COMPARISON_WARNING) == 0) {
                    scope.problemReporter().localVariableRedundantCheckOnNull(local, reference);
                  }
                  flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS);
                  return;
                case FlowContext.IN_COMPARISON_NON_NULL:
                  if (((checkTypeWithoutHideNullWarning & CHECK_MASK) == CAN_ONLY_NULL) && (reference.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning
                    scope.problemReporter().localVariableNullReference(local, reference);
                    return;
                  }
                  scope.problemReporter().localVariableNullComparedToNonNull(local, reference);
                  flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS);
                  return;
                case FlowContext.IN_ASSIGNMENT:
                  scope.problemReporter().localVariableRedundantNullAssignment(local, reference);
                  return;
                case FlowContext.IN_INSTANCEOF:
                  scope.problemReporter().localVariableNullInstanceof(local, reference);
                  return;
              }
            } else if (flowInfo.isPotentiallyNull(local)) {
              switch(checkTypeWithoutHideNullWarning & CONTEXT_MASK) {
                case FlowContext.IN_COMPARISON_NULL:
                  if (((checkTypeWithoutHideNullWarning & CHECK_MASK) == CAN_ONLY_NULL) && (reference.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning
                    scope.problemReporter().localVariablePotentialNullReference(local, reference);
                    return;
                  }
                  break;
                case FlowContext.IN_COMPARISON_NON_NULL:
                  if (((checkTypeWithoutHideNullWarning & CHECK_MASK) == CAN_ONLY_NULL) && (reference.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning
                    scope.problemReporter().localVariablePotentialNullReference(local, reference);
                    return;
                  }
                  break;
              }
            }
            break;
          case MAY_NULL :
            if (flowInfo.cannotBeNull(local)) {
              return;
            }
            if (flowInfo.canOnlyBeNull(local)) {
              scope.problemReporter().localVariableNullReference(local, location);
              return;
            }
            break;
          default:
            // never happens
        }
      }
      else { // no enclosing loop, be as precise as possible right now
        switch (checkTypeWithoutHideNullWarning) {
          case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL:
          case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL:
            if (flowInfo.isDefinitelyNonNull(local)) {
              if (checkTypeWithoutHideNullWarning == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) {
                if ((checkType & HIDE_NULL_COMPARISON_WARNING) == 0) {
                  scope.problemReporter().localVariableRedundantCheckOnNonNull(local, location);
                }
                flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS);
              } else {
                scope.problemReporter().localVariableNonNullComparedToNull(local, location);
                flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS);
              }
              return;
            }
            //$FALL-THROUGH$
          case CAN_ONLY_NULL | IN_COMPARISON_NULL:
          case CAN_ONLY_NULL | IN_COMPARISON_NON_NULL:
          case CAN_ONLY_NULL | IN_ASSIGNMENT:
          case CAN_ONLY_NULL | IN_INSTANCEOF:
            Expression reference = (Expression) location;
            if (flowInfo.isDefinitelyNull(local)) {
              switch(checkTypeWithoutHideNullWarning & CONTEXT_MASK) {
                case FlowContext.IN_COMPARISON_NULL:
                  if (((checkTypeWithoutHideNullWarning & CHECK_MASK) == CAN_ONLY_NULL) && (reference.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning
                    scope.problemReporter().localVariableNullReference(local, reference);
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.ast.Expression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.