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

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


          this.nullReferences[i]this.nullCheckTypes[i], flowInfo);
    }
  }
  else { // no enclosing loop, be as precise as possible right now
    for (int i = 0; i < this.nullCount; i++) {
      Expression expression = this.nullReferences[i];
      // final local variable
      LocalVariableBinding local = this.nullLocals[i];
      switch (this.nullCheckTypes[i]) {
        case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL:
        case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL:
View Full Code Here


    addPotentialNullInfoFrom(callerFlowInfo.unconditionalInitsWithoutSideEffect());
  if (this.deferNullDiagnostic) {
    // check only immutable null checks on innermost looping context
    for (int i = 0; i < this.nullCount; i++) {
      LocalVariableBinding local = this.nullLocals[i];
      Expression expression = this.nullReferences[i];
      // final local variable
      switch (this.nullCheckTypes[i]) {
        case CAN_ONLY_NON_NULL | IN_COMPARISON_NULL:
        case CAN_ONLY_NON_NULL | IN_COMPARISON_NON_NULL:
          if (flowInfo.isDefinitelyNonNull(local)) {
            this.nullReferences[i] = null;
            if (this.nullCheckTypes[i] == (CAN_ONLY_NON_NULL | IN_COMPARISON_NON_NULL)) {
              scope.problemReporter().localVariableRedundantCheckOnNonNull(local, expression);
            } else {
              scope.problemReporter().localVariableNonNullComparedToNull(local, expression);
            }
            continue;
          }
          break;
        case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL:
        case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL:
          if (flowInfo.isDefinitelyNonNull(local)) {
            this.nullReferences[i] = null;
            if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) {
              scope.problemReporter().localVariableRedundantCheckOnNonNull(local, expression);
            } else {
              scope.problemReporter().localVariableNonNullComparedToNull(local, expression);
            }
            continue;
          }
          if (flowInfo.isDefinitelyNull(local)) {
            this.nullReferences[i] = null;
            if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL)) {
              scope.problemReporter().localVariableRedundantCheckOnNull(local, expression);
            } else {
              scope.problemReporter().localVariableNullComparedToNonNull(local, expression);
            }
            continue;
          }
          break;
        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:
          if (flowInfo.isDefinitelyNull(local)) {
            this.nullReferences[i] = null;
            switch(this.nullCheckTypes[i] & CONTEXT_MASK) {
              case FlowContext.IN_COMPARISON_NULL:
                scope.problemReporter().localVariableRedundantCheckOnNull(local, expression);
                continue;
              case FlowContext.IN_COMPARISON_NON_NULL:
                scope.problemReporter().localVariableNullComparedToNonNull(local, expression);
                continue;
              case FlowContext.IN_ASSIGNMENT:
                scope.problemReporter().localVariableRedundantNullAssignment(local, expression);
                continue;
              case FlowContext.IN_INSTANCEOF:
                scope.problemReporter().localVariableNullInstanceof(local, expression);
                continue;
            }
          }
          break;
        case MAY_NULL:
          if (flowInfo.isDefinitelyNull(local)) {
            this.nullReferences[i] = null;
            scope.problemReporter().localVariableNullReference(local, expression);
            continue;
          }
          break;
        default:
          // never happens
      }
      this.parent.recordUsingNullReference(scope, local, expression,
          this.nullCheckTypes[i], flowInfo);
    }
  }
  else {
    // check inconsistent null checks on outermost looping context
    for (int i = 0; i < this.nullCount; i++) {
      Expression expression = this.nullReferences[i];
      // final local variable
      LocalVariableBinding local = this.nullLocals[i];
      switch (this.nullCheckTypes[i]) {
        case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL:
        case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL:
View Full Code Here

  if (this.arguments != null) {
    boolean argHasError = false; // typeChecks all arguments
    int length = this.arguments.length;
    argumentTypes = new TypeBinding[length];
    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;
      }
      if ((argumentTypes[i] = this.arguments[i].resolveType(scope)) == null)
View Full Code Here

  int problemId = 0;
  Binding binding = null;
  String[] arguments = null;
  int start = 0, end = 0;

  Expression location = expr;
  // unwrap uninteresting nodes:
  while (true) {
    if (expr instanceof Assignment)
      return false; // don't report against the assignment, but the variable
    else if (expr instanceof CastExpression)
View Full Code Here

        "", //$NON-NLS-1$
        compilerOptions.defaultEncoding);

    CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit);
    CompilationUnitDeclaration unit = new CompilationUnitDeclaration(problemReporter, compilationResult, source.length);
    Expression result = parser.parseExpression(source, offset, length, unit);

    if (recordParsingInformation) {
      this.recordedParsingInformation = getRecordedParsingInformation(compilationResult, unit.comments);
    }
    return result;
View Full Code Here

  if (this.arguments != null) {
    boolean argHasError = false;
    int length = this.arguments.length;
    argumentTypes = new TypeBinding[length];
    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;
      }
      if ((argumentTypes[i] = argument.resolveType(scope)) == null) {
        argHasError = true;
      }
    }
    if (argHasError) {
      return this.resolvedType;
View Full Code Here

    return this.newCodeFormatter.format(source, compilationUnitDeclaration);
  }

  private TextEdit formatExpression(String source, int indentationLevel, String lineSeparator, IRegion[] regions, boolean includeComments) {
    Expression expression = this.codeSnippetParsingUtil.parseExpression(source.toCharArray(), getDefaultCompilerOptions(), true);

    if (expression == null) {
      // a problem occurred while parsing the source
      return null;
    }
View Full Code Here

      // ignore
    }
    PROBING_SCANNER.setSource((char[]) null);

    // probe for expression
    Expression expression = this.codeSnippetParsingUtil.parseExpression(source.toCharArray(), getDefaultCompilerOptions(), true);
    if (expression != null) {
      return internalFormatExpression(source, indentationLevel, lineSeparator, expression, regions, includeComments);
    }

    // probe for body declarations (fields, methods, constructors)
View Full Code Here

    }

    /*
     * Field initialization
     */
    final Expression initialization = fieldDeclaration.initialization;
    if (initialization != null) {
      this.scribe.alignFragment(memberAlignment, 1);
      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.FIELD_DECLARATION_ASSIGNMENT,
          this.preferences.alignment_for_assignment,
          Alignment.R_INNERMOST,
          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

          }

          /*
           * Field initialization
           */
          final Expression initialization = fieldDeclaration.initialization;
          if (initialization != null) {
            if (i == 0) {
              this.scribe.alignFragment(fieldAlignment, 1);
            }
            this.scribe.printNextToken(TerminalTokens.TokenNameEQUAL, this.preferences.insert_space_before_assignment_operator);
            if (this.preferences.insert_space_after_assignment_operator) {
              this.scribe.space();
            }
            initialization.traverse(this, scope);
          }

          if (i != length - 1) {
            this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_multiple_field_declarations);
            this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
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.