本文整理汇总了Java中org.eclipse.jdt.internal.compiler.lookup.TypeBinding.kind方法的典型用法代码示例。如果您正苦于以下问题:Java TypeBinding.kind方法的具体用法?Java TypeBinding.kind怎么用?Java TypeBinding.kind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.compiler.lookup.TypeBinding
的用法示例。
在下文中一共展示了TypeBinding.kind方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: areSameTypes
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
/** Are both types identical wrt the unannotated type and any null type annotations? Only unstructured types and captures are considered. */
protected static boolean areSameTypes(TypeBinding requiredType, TypeBinding providedType, TypeBinding providedSubstitute) {
if (requiredType == providedType) //$IDENTITY-COMPARISON$ // short cut for really-really-same types
return true;
if (requiredType.isParameterizedType() || requiredType.isArrayType())
return false; // not analysing details here
if (TypeBinding.notEquals(requiredType, providedType)) {
if (requiredType instanceof CaptureBinding) {
// when providing exactly the lower bound of the required type we're definitely fine:
TypeBinding lowerBound = ((CaptureBinding)requiredType).lowerBound;
if (lowerBound != null && areSameTypes(lowerBound, providedType, providedSubstitute))
return true;
} else if (requiredType.kind() == Binding.TYPE_PARAMETER && requiredType == providedSubstitute) { //$IDENTITY-COMPARISON$
return true;
} else if (providedType instanceof CaptureBinding) {
// when requiring exactly the upper bound of the provided type we're fine, too:
TypeBinding upperBound = ((CaptureBinding)providedType).upperBound();
if (upperBound != null && areSameTypes(requiredType, upperBound, providedSubstitute))
return true;
}
return false;
}
return (requiredType.tagBits & TagBits.AnnotationNullMASK) == (providedType.tagBits & TagBits.AnnotationNullMASK);
}
示例2: checkInvocationArgument
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
private static int checkInvocationArgument(BlockScope scope, Expression argument, TypeBinding parameterType, TypeBinding argumentType, TypeBinding originalParameterType) {
argument.computeConversion(scope, parameterType, argumentType);
if (argumentType != TypeBinding.NULL && parameterType.kind() == Binding.WILDCARD_TYPE) { // intersection types are tolerated
WildcardBinding wildcard = (WildcardBinding) parameterType;
if (wildcard.boundKind != Wildcard.SUPER) {
return INVOCATION_ARGUMENT_WILDCARD;
}
}
TypeBinding checkedParameterType = parameterType; // originalParameterType == null ? parameterType : originalParameterType;
if (TypeBinding.notEquals(argumentType, checkedParameterType) && argumentType.needsUncheckedConversion(checkedParameterType)) {
scope.problemReporter().unsafeTypeConversion(argument, argumentType, checkedParameterType);
return INVOCATION_ARGUMENT_UNCHECKED;
}
return INVOCATION_ARGUMENT_OK;
}
示例3: unboxedType
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
@Override
public PrimitiveType unboxedType(TypeMirror t) {
if (!(((TypeMirrorImpl)t)._binding instanceof ReferenceBinding)) {
// Not an unboxable type - could be primitive, array, not a type at all, etc.
throw new IllegalArgumentException("Given type mirror cannot be unboxed"); //$NON-NLS-1$
}
ReferenceBinding boxed = (ReferenceBinding)((TypeMirrorImpl)t)._binding;
TypeBinding unboxed = _env.getLookupEnvironment().computeBoxingType(boxed);
if (unboxed.kind() != Binding.BASE_TYPE) {
// No boxing conversion was found
throw new IllegalArgumentException();
}
return (PrimitiveType) _env.getFactory().newTypeMirror((BaseTypeBinding)unboxed);
}
示例4: resolveType
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
public TypeBinding resolveType(BlockScope scope, boolean checkBounds, int location) {
// return the lub (least upper bound of all type binding)
int length = this.typeReferences.length;
TypeBinding[] allExceptionTypes = new TypeBinding[length];
boolean hasError = false;
for (int i = 0; i < length; i++) {
TypeBinding exceptionType = this.typeReferences[i].resolveType(scope, checkBounds, location);
if (exceptionType == null) {
return null;
}
switch(exceptionType.kind()) {
case Binding.PARAMETERIZED_TYPE :
if (exceptionType.isBoundParameterizedType()) {
hasError = true;
scope.problemReporter().invalidParameterizedExceptionType(exceptionType, this.typeReferences[i]);
// fall thru to create the variable - avoids additional errors because the variable is missing
}
break;
case Binding.TYPE_PARAMETER :
scope.problemReporter().invalidTypeVariableAsException(exceptionType, this.typeReferences[i]);
hasError = true;
// fall thru to create the variable - avoids additional errors because the variable is missing
break;
}
if (exceptionType.findSuperTypeOriginatingFrom(TypeIds.T_JavaLangThrowable, true) == null
&& exceptionType.isValidBinding()) {
scope.problemReporter().cannotThrowType(this.typeReferences[i], exceptionType);
hasError = true;
}
allExceptionTypes[i] = exceptionType;
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=340486, ensure types are of union type.
for (int j = 0; j < i; j++) {
if (allExceptionTypes[j].isCompatibleWith(exceptionType)) {
scope.problemReporter().wrongSequenceOfExceptionTypes(
this.typeReferences[j],
allExceptionTypes[j],
exceptionType);
hasError = true;
} else if (exceptionType.isCompatibleWith(allExceptionTypes[j])) {
scope.problemReporter().wrongSequenceOfExceptionTypes(
this.typeReferences[i],
exceptionType,
allExceptionTypes[j]);
hasError = true;
}
}
}
if (hasError) {
return null;
}
// compute lub
return (this.resolvedType = scope.lowerUpperBound(allExceptionTypes));
}
示例5: resolveType
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
public TypeBinding resolveType(BlockScope scope, boolean checkBounds) {
// return the lub (least upper bound of all type binding)
int length = this.typeReferences.length;
TypeBinding[] allExceptionTypes = new TypeBinding[length];
boolean hasError = false;
for (int i = 0; i < length; i++) {
TypeBinding exceptionType = this.typeReferences[i].resolveType(scope, checkBounds);
if (exceptionType == null) {
return null;
}
switch(exceptionType.kind()) {
case Binding.PARAMETERIZED_TYPE :
if (exceptionType.isBoundParameterizedType()) {
hasError = true;
scope.problemReporter().invalidParameterizedExceptionType(exceptionType, this.typeReferences[i]);
// fall thru to create the variable - avoids additional errors because the variable is missing
}
break;
case Binding.TYPE_PARAMETER :
scope.problemReporter().invalidTypeVariableAsException(exceptionType, this.typeReferences[i]);
hasError = true;
// fall thru to create the variable - avoids additional errors because the variable is missing
break;
}
if (exceptionType.findSuperTypeOriginatingFrom(TypeIds.T_JavaLangThrowable, true) == null
&& exceptionType.isValidBinding()) {
scope.problemReporter().cannotThrowType(this.typeReferences[i], exceptionType);
hasError = true;
}
allExceptionTypes[i] = exceptionType;
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=340486, ensure types are of union type.
for (int j = 0; j < i; j++) {
if (allExceptionTypes[j].isCompatibleWith(exceptionType)) {
scope.problemReporter().wrongSequenceOfExceptionTypes(
this.typeReferences[j],
allExceptionTypes[j],
exceptionType);
hasError = true;
} else if (exceptionType.isCompatibleWith(allExceptionTypes[j])) {
scope.problemReporter().wrongSequenceOfExceptionTypes(
this.typeReferences[i],
exceptionType,
allExceptionTypes[j]);
hasError = true;
}
}
}
if (hasError) {
return null;
}
// compute lub
return (this.resolvedType = scope.lowerUpperBound(allExceptionTypes));
}