Package org.eclipse.jdt.internal.compiler.lookup

Examples of org.eclipse.jdt.internal.compiler.lookup.TypeBinding


  List missingTypes = constructor.collectMissingTypes(null);
  if (missingTypes == null) {
    System.err.println("The constructor " + constructor + " is wrongly tagged as containing missing types"); //$NON-NLS-1$ //$NON-NLS-2$
    return;
  }
  TypeBinding missingType = (TypeBinding) missingTypes.get(0);
  int start = location.sourceStart;
  int end = location.sourceEnd;
  if (location instanceof QualifiedAllocationExpression) {
    QualifiedAllocationExpression qualifiedAllocation = (QualifiedAllocationExpression) location;
    if (qualifiedAllocation.anonymousType != null) {
      start = qualifiedAllocation.anonymousType.sourceStart;
      end = qualifiedAllocation.anonymousType.sourceEnd;
    }
  }
  this.handle(
      IProblem.MissingTypeInConstructor,
      new String[] {
              new String(constructor.declaringClass.readableName()),
              typesAsString(constructor, false),
               new String(missingType.readableName()),
      },
      new String[] {
              new String(constructor.declaringClass.shortReadableName()),
              typesAsString(constructor, true),
               new String(missingType.shortReadableName()),
      },
      start,
      end);
}
View Full Code Here


  List missingTypes = method.collectMissingTypes(null);
  if (missingTypes == null) {
    System.err.println("The method " + method + " is wrongly tagged as containing missing types"); //$NON-NLS-1$ //$NON-NLS-2$
    return;
  }
  TypeBinding missingType = (TypeBinding) missingTypes.get(0);
  this.handle(
      IProblem.MissingTypeInMethod,
      new String[] {
              new String(method.declaringClass.readableName()),
              new String(method.selector),
              typesAsString(method, false),
               new String(missingType.readableName()),
      },
      new String[] {
              new String(method.declaringClass.shortReadableName()),
              new String(method.selector),
              typesAsString(method, true),
               new String(missingType.shortReadableName()),
      },
      (int) (messageSend.nameSourcePosition >>> 32),
      (int) messageSend.nameSourcePosition);
}
View Full Code Here

        boolean[] locallyCaught = new boolean[raisedCount]; // at most

        for (int caughtIndex = 0; caughtIndex < caughtCount; caughtIndex++) {
          ReferenceBinding caughtException = caughtExceptions[caughtIndex];
          for (int raisedIndex = 0; raisedIndex < raisedCount; raisedIndex++) {
            TypeBinding raisedException;
            if ((raisedException = raisedExceptions[raisedIndex]) != null) {
                int state = caughtException == null
                  ? Scope.EQUAL_OR_MORE_SPECIFIC /* any exception */
                    : Scope.compareTypes(raisedException, caughtException);
                if (abruptlyExitedLoops != null && caughtException != null && state != Scope.NOT_RELATED) {
                  for (int i = 0, abruptlyExitedLoopsCount = abruptlyExitedLoops.size(); i < abruptlyExitedLoopsCount; i++) {
                  LoopingFlowContext loop = (LoopingFlowContext) abruptlyExitedLoops.get(i);
                  loop.recordCatchContextOfEscapingException(exceptionContext, caughtException);
                }
              }
              switch (state) {
                case Scope.EQUAL_OR_MORE_SPECIFIC :
                  exceptionContext.recordHandlingException(
                    caughtException,
                    flowInfo.unconditionalInits(),
                    raisedException,
                    raisedException, // precise exception that will be caught
                    location,
                    locallyCaught[raisedIndex]);
                  // was already definitely caught ?
                  if (!locallyCaught[raisedIndex]) {
                    locallyCaught[raisedIndex] = true;
                    // remember that this exception has been definitely caught
                    remainingCount--;
                  }
                  break;
                case Scope.MORE_GENERIC :
                  exceptionContext.recordHandlingException(
                    caughtException,
                    flowInfo.unconditionalInits(),
                    raisedException,
                    caughtException,
                    location,
                    false);
                  // was not caught already per construction
              }
            }
          }
        }
        // remove locally caught exceptions from the remaining ones
        for (int i = 0; i < raisedCount; i++) {
          if (locallyCaught[i]) {
            raisedExceptions[i] = null; // removed from the remaining ones.
          }
        }
      }
      // method treatment for unchecked exceptions
      if (exceptionContext.isMethodContext) {
        for (int i = 0; i < raisedCount; i++) {
          TypeBinding raisedException;
          if ((raisedException = raisedExceptions[i]) != null) {
            if (raisedException.isUncheckedException(false)) {
              remainingCount--;
              raisedExceptions[i] = null;
            }
          }
        }
        // anonymous constructors are allowed to throw any exceptions (their thrown exceptions
        // clause will be fixed up later as per JLS 8.6).
        if (exceptionContext.associatedNode instanceof AbstractMethodDeclaration){
          AbstractMethodDeclaration method = (AbstractMethodDeclaration)exceptionContext.associatedNode;
          if (method.isConstructor() && method.binding.declaringClass.isAnonymousType()){

            for (int i = 0; i < raisedCount; i++) {
              TypeBinding raisedException;
              if ((raisedException = raisedExceptions[i]) != null) {
                exceptionContext.mergeUnhandledException(raisedException);
              }
            }
            return; // no need to complain, will fix up constructor exceptions
          }
        }
        break; // not handled anywhere, thus jump to error handling
      }
        } else if (traversedContext instanceof LoopingFlowContext) {
      if (abruptlyExitedLoops == null) {
        abruptlyExitedLoops = new ArrayList(5);
      }
      abruptlyExitedLoops.add(traversedContext);
    }
    if (remainingCount == 0)
      return;

    traversedContext.recordReturnFrom(flowInfo.unconditionalInits());

    if (traversedContext instanceof InsideSubRoutineFlowContext) {
      ASTNode node = traversedContext.associatedNode;
      if (node instanceof TryStatement) {
        TryStatement tryStatement = (TryStatement) node;
        flowInfo.addInitializationsFrom(tryStatement.subRoutineInits); // collect inits
      }
    }
    traversedContext = traversedContext.parent;
  }
  // if reaches this point, then there are some remaining unhandled exception types.
  nextReport: for (int i = 0; i < raisedCount; i++) {
    TypeBinding exception;
    if ((exception = raisedExceptions[i]) != null) {
      // only one complaint if same exception declared to be thrown more than once
      for (int j = 0; j < i; j++) {
        if (raisedExceptions[j] == exception) continue nextReport; // already reported
      }
View Full Code Here

}
public void typeHiding(TypeDeclaration typeDecl, TypeVariableBinding hiddenTypeParameter) {
  int severity = computeSeverity(IProblem.TypeHidingTypeParameterFromType);
  if (severity == ProblemSeverities.Ignore) return;
  if (hiddenTypeParameter.declaringElement instanceof TypeBinding) {
    TypeBinding declaringType = (TypeBinding) hiddenTypeParameter.declaringElement;
    this.handle(
      IProblem.TypeHidingTypeParameterFromType,
      new String[] { new String(typeDecl.name) , new String(hiddenTypeParameter.readableName()), new String(declaringType.readableName())  },
      new String[] { new String(typeDecl.name) , new String(hiddenTypeParameter.shortReadableName()), new String(declaringType.shortReadableName()) },
      severity,
      typeDecl.sourceStart,
      typeDecl.sourceEnd);
  } else {
    // type parameter of generic method
View Full Code Here

  }
}
public void typeHiding(TypeParameter typeParam, Binding hidden) {
  int severity = computeSeverity(IProblem.TypeParameterHidingType);
  if (severity == ProblemSeverities.Ignore) return;
  TypeBinding hiddenType = (TypeBinding) hidden;
  this.handle(
    IProblem.TypeParameterHidingType,
    new String[] { new String(typeParam.name) , new String(hiddenType.readableName())  },
    new String[] { new String(typeParam.name) , new String(hiddenType.shortReadableName()) },
    severity,
    typeParam.sourceStart,
    typeParam.sourceEnd);
}
View Full Code Here

    StringBuffer buffer = new StringBuffer(10);
    for (int i = 0, length = types.length; i < length; i++) {
      if (i != 0) {
        buffer.append(", "); //$NON-NLS-1$
      }
      TypeBinding type = types[i];
      boolean isVarargType = i == length-1;
      if (isVarargType) {
        type = ((ArrayBinding)type).elementsType();
      }
      buffer.append(new String(makeShort ? type.shortReadableName() : type.readableName()));
      if (isVarargType) {
        buffer.append("..."); //$NON-NLS-1$
      }
    }
    return buffer.toString();
  }
  StringBuffer buffer = new StringBuffer(10);
  for (int i = 0, length = parameters.length; i < length; i++) {
    if (i != 0) {
      buffer.append(", "); //$NON-NLS-1$
    }
    TypeBinding type = parameters[i];
    boolean isVarargType = methodBinding.isVarargs() && i == length-1;
    if (isVarargType) {
      type = ((ArrayBinding)type).elementsType();
    }
    buffer.append(new String(makeShort ? type.shortReadableName() : type.readableName()));
    if (isVarargType) {
      buffer.append("..."); //$NON-NLS-1$
    }
  }
  return buffer.toString();
View Full Code Here

  StringBuffer buffer = new StringBuffer(10);
  for (int i = 0, length = types.length; i < length; i++) {
    if (i != 0) {
      buffer.append(", "); //$NON-NLS-1$
    }
    TypeBinding type = types[i];
    buffer.append(new String(makeShort ? type.shortReadableName() : type.readableName()));
  }
  return buffer.toString();
}
View Full Code Here

    compilationResult);
}
public void unnecessaryCast(CastExpression castExpression) {
  int severity = computeSeverity(IProblem.UnnecessaryCast);
  if (severity == ProblemSeverities.Ignore) return;
  TypeBinding castedExpressionType = castExpression.expression.resolvedType;
  this.handle(
    IProblem.UnnecessaryCast,
    new String[]{ new String(castedExpressionType.readableName()), new String(castExpression.type.resolvedType.readableName())},
    new String[]{ new String(castedExpressionType.shortReadableName()), new String(castExpression.type.resolvedType.shortReadableName())},
    severity,
    castExpression.sourceStart,
    castExpression.sourceEnd);
}
View Full Code Here

    expression.sourceEnd);
}
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);
}
View Full Code Here

}
public void unsafeCast(CastExpression castExpression, Scope scope) {
  if (this.options.sourceLevel < ClassFileConstants.JDK1_5) return; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=305259
  int severity = computeSeverity(IProblem.UnsafeGenericCast);
  if (severity == ProblemSeverities.Ignore) return;
  TypeBinding castedExpressionType = castExpression.expression.resolvedType;
  TypeBinding castExpressionResolvedType = castExpression.resolvedType;
  this.handle(
    IProblem.UnsafeGenericCast,
    new String[]{
      new String(castedExpressionType.readableName()),
      new String(castExpressionResolvedType.readableName())
    },
    new String[]{
      new String(castedExpressionType.shortReadableName()),
      new String(castExpressionResolvedType.shortReadableName())
    },
    severity,
    castExpression.sourceStart,
    castExpression.sourceEnd);
}
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.lookup.TypeBinding

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.