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

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


  }

  private void formatCascadingMessageSends(CascadingMethodInvocationFragmentBuilder builder, BlockScope scope) {
    int size = builder.size();
    MessageSend[] fragments = builder.fragments();
    Expression fragment = fragments[0].receiver;
    int startingPositionInCascade = 1;
    if (!fragment.isImplicitThis()) {
      fragment.traverse(this, scope);
    } else {
      MessageSend currentMessageSend = fragments[1];
      final int numberOfParens = (currentMessageSend.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
      if (numberOfParens > 0) {
        manageOpeningParenthesizedExpression(currentMessageSend, numberOfParens);
View Full Code Here


         this.scribe.printNextToken(TerminalTokens.TokenNameLBRACKET);
         this.scribe.printNextToken(TerminalTokens.TokenNameRBRACKET);
       }
    }

    final Expression initialization = localDeclaration.initialization;
    if (initialization != null) {
      /*
       * Print the method name
       */
      this.scribe.printNextToken(TerminalTokens.TokenNameEQUAL, this.preferences.insert_space_before_assignment_operator);
      if (this.preferences.insert_space_after_assignment_operator) {
        this.scribe.space();
      }
      Alignment assignmentAlignment = this.scribe.createAlignment(
          Alignment.LOCAL_DECLARATION_ASSIGNMENT,
          this.preferences.alignment_for_assignment,
          Alignment.R_OUTERMOST,
          1,
          this.scribe.scanner.currentPosition);
      this.scribe.enterAlignment(assignmentAlignment);
      boolean ok = false;
      do {
        try {
          this.scribe.alignFragment(assignmentAlignment, 0);
          initialization.traverse(this, scope);
          ok = true;
        } catch(AlignmentException e){
          this.scribe.redoAlignment(e);
        }
      } while (!ok);
View Full Code Here

         this.scribe.printNextToken(TerminalTokens.TokenNameLBRACKET);
         this.scribe.printNextToken(TerminalTokens.TokenNameRBRACKET);
       }
    }

    Expression defaultValue = annotationTypeMemberDeclaration.defaultValue;
    if (defaultValue != null) {
      this.scribe.printNextToken(TerminalTokens.TokenNamedefault, true);
      this.scribe.space();
      defaultValue.traverse(this, (BlockScope) null);
    }
    this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
    this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
    return false;
  }
View Full Code Here

      this.preferences.insert_space_after_opening_paren_in_enum_constant,
      this.preferences.insert_space_before_comma_in_enum_constant_arguments,
      this.preferences.insert_space_after_comma_in_enum_constant_arguments,
      this.preferences.alignment_for_arguments_in_enum_constant);

    Expression initialization = enumConstant.initialization;
    if (initialization instanceof QualifiedAllocationExpression) {
      TypeDeclaration typeDeclaration = ((QualifiedAllocationExpression) initialization).anonymousType;
      int fieldsCount = typeDeclaration.fields == null ? 0 : typeDeclaration.fields.length;
      int methodsCount = typeDeclaration.methods == null ? 0 : typeDeclaration.methods.length;
      int membersCount = typeDeclaration.memberTypes == null ? 0 : typeDeclaration.memberTypes.length;
View Full Code Here

    BlockScope scope) {

    if (explicitConstructor.isImplicitSuper()) {
      return false;
    }
    final Expression qualification = explicitConstructor.qualification;
    if (qualification != null) {
      qualification.traverse(this, scope);
      this.scribe.printNextToken(TerminalTokens.TokenNameDOT);
    }

    TypeReference[] typeArguments = explicitConstructor.typeArguments;
    if (typeArguments != null) {
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

          }
        }
      }
    }
    this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon_in_for);
    final Expression condition = forStatement.condition;
    if (condition != null) {
      if (this.preferences.insert_space_after_semicolon_in_for) {
        this.scribe.space();
      }
      condition.traverse(this, scope);
    }
    this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon_in_for);
    final Statement[] increments = forStatement.increments;
    if (increments != null) {
      if (this.preferences.insert_space_after_semicolon_in_for) {
View Full Code Here

    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

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.