本文整理汇总了Java中org.eclipse.jdt.internal.compiler.lookup.TypeBinding.isTypeVariable方法的典型用法代码示例。如果您正苦于以下问题:Java TypeBinding.isTypeVariable方法的具体用法?Java TypeBinding.isTypeVariable怎么用?Java TypeBinding.isTypeVariable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.compiler.lookup.TypeBinding
的用法示例。
在下文中一共展示了TypeBinding.isTypeVariable方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: nullityMismatchIsNull
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
public void nullityMismatchIsNull(Expression expression, TypeBinding requiredType) {
int problemId = IProblem.RequiredNonNullButProvidedNull;
boolean below18 = this.options.sourceLevel < ClassFileConstants.JDK1_8;
if (!below18 && requiredType.isTypeVariable() && !requiredType.hasNullTypeAnnotations())
problemId = IProblem.NullNotCompatibleToFreeTypeVariable;
if (requiredType instanceof CaptureBinding) {
CaptureBinding capture = (CaptureBinding) requiredType;
if (capture.wildcard != null)
requiredType = capture.wildcard;
}
String[] arguments;
String[] argumentsShort;
if (below18) {
arguments = new String[] { annotatedTypeName(requiredType, this.options.nonNullAnnotationName) };
argumentsShort = new String[] { shortAnnotatedTypeName(requiredType, this.options.nonNullAnnotationName) };
} else {
if (problemId == IProblem.NullNotCompatibleToFreeTypeVariable) {
arguments = new String[] { new String(requiredType.sourceName()) }; // don't show any bounds
argumentsShort = new String[] { new String(requiredType.sourceName()) };
} else {
arguments = new String[] { new String(requiredType.nullAnnotatedReadableName(this.options, false)) };
argumentsShort = new String[] { new String(requiredType.nullAnnotatedReadableName(this.options, true)) };
}
}
this.handle(problemId, arguments, argumentsShort, expression.sourceStart, expression.sourceEnd);
}
示例2: resolveSuperType
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
public TypeBinding resolveSuperType(ClassScope scope) {
// assumes the implementation of resolveType(ClassScope) will call back to detect cycles
TypeBinding superType = resolveType(scope);
if (superType == null) return null;
if (superType.isTypeVariable()) {
if (this.resolvedType.isValidBinding()) {
this.resolvedType = new ProblemReferenceBinding(getTypeName(), (ReferenceBinding)this.resolvedType, ProblemReasons.IllegalSuperTypeVariable);
reportInvalidType(scope);
}
return null;
}
return superType;
}
示例3: requiredNullTagBits
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
static long requiredNullTagBits(TypeBinding type, CheckMode mode) {
long tagBits = type.tagBits & TagBits.AnnotationNullMASK;
if (tagBits != 0)
return validNullTagBits(tagBits);
if (type.isWildcard()) {
WildcardBinding wildcard = (WildcardBinding)type;
if (wildcard.boundKind == Wildcard.UNBOUND)
return 0;
tagBits = wildcard.bound.tagBits & TagBits.AnnotationNullMASK;
if (tagBits == 0)
return 0;
switch (wildcard.boundKind) {
case Wildcard.EXTENDS :
if (tagBits == TagBits.AnnotationNonNull)
return TagBits.AnnotationNonNull;
return TagBits.AnnotationNullMASK; // wildcard accepts @Nullable or better
case Wildcard.SUPER :
if (tagBits == TagBits.AnnotationNullable)
return TagBits.AnnotationNullable;
return TagBits.AnnotationNullMASK; // wildcard accepts @NonNull or worse
}
return 0;
}
if (type.isTypeVariable()) {
// assume we must require @NonNull, unless lower @Nullable bound
// (annotation directly on the TV has already been checked above)
if (type.isCapture()) {
TypeBinding lowerBound = ((CaptureBinding) type).lowerBound;
if (lowerBound != null) {
tagBits = lowerBound.tagBits & TagBits.AnnotationNullMASK;
if (tagBits == TagBits.AnnotationNullable)
return TagBits.AnnotationNullable; // type cannot require @NonNull
}
}
if (mode != CheckMode.BOUND_CHECK) // no pessimistic checks during boundcheck (we *have* the instantiation)
return TagBits.AnnotationNonNull; // instantiation could require @NonNull
}
return 0;
}
示例4: providedNullTagBits
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
static long providedNullTagBits(TypeBinding type) {
long tagBits = type.tagBits & TagBits.AnnotationNullMASK;
if (tagBits != 0)
return validNullTagBits(tagBits);
if (type.isWildcard()) { // wildcard can be 'provided' during inheritance checks
WildcardBinding wildcard = (WildcardBinding)type;
if (wildcard.boundKind == Wildcard.UNBOUND)
return 0;
tagBits = wildcard.bound.tagBits & TagBits.AnnotationNullMASK;
if (tagBits == 0)
return 0;
switch (wildcard.boundKind) {
case Wildcard.EXTENDS :
if (tagBits == TagBits.AnnotationNonNull)
return TagBits.AnnotationNonNull;
return TagBits.AnnotationNullMASK; // @Nullable or better
case Wildcard.SUPER :
if (tagBits == TagBits.AnnotationNullable)
return TagBits.AnnotationNullable;
return TagBits.AnnotationNullMASK; // @NonNull or worse
}
return 0;
}
if (type.isTypeVariable()) { // incl. captures
TypeVariableBinding typeVariable = (TypeVariableBinding)type;
boolean haveNullBits = false;
if (typeVariable.isCapture()) {
TypeBinding lowerBound = ((CaptureBinding) typeVariable).lowerBound;
if (lowerBound != null) {
tagBits = lowerBound.tagBits & TagBits.AnnotationNullMASK;
if (tagBits == TagBits.AnnotationNullable)
return TagBits.AnnotationNullable; // cannot be @NonNull
haveNullBits |= (tagBits != 0);
}
}
if (typeVariable.firstBound != null) {
long boundBits = typeVariable.firstBound.tagBits & TagBits.AnnotationNullMASK;
if (boundBits == TagBits.AnnotationNonNull)
return TagBits.AnnotationNonNull; // cannot be @Nullable
haveNullBits |= (boundBits != 0);
}
if (haveNullBits)
return TagBits.AnnotationNullMASK; // could be either, can only match to a wildcard accepting both
}
return 0;
}
示例5: detectAssertionUtility
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
private int detectAssertionUtility(int argumentIdx) {
TypeBinding[] parameters = this.binding.original().parameters;
if (argumentIdx < parameters.length) {
TypeBinding parameterType = parameters[argumentIdx];
if (this.actualReceiverType != null && parameterType != null) {
switch (this.actualReceiverType.id) {
case TypeIds.T_OrgEclipseCoreRuntimeAssert:
if (parameterType.id == TypeIds.T_boolean)
return TRUE_ASSERTION;
if (parameterType.id == TypeIds.T_JavaLangObject && CharOperation.equals(TypeConstants.IS_NOTNULL, this.selector))
return NONNULL_ASSERTION;
break;
case TypeIds.T_JunitFrameworkAssert:
case TypeIds.T_OrgJunitAssert:
if (parameterType.id == TypeIds.T_boolean) {
if (CharOperation.equals(TypeConstants.ASSERT_TRUE, this.selector))
return TRUE_ASSERTION;
if (CharOperation.equals(TypeConstants.ASSERT_FALSE, this.selector))
return FALSE_ASSERTION;
} else if (parameterType.id == TypeIds.T_JavaLangObject) {
if (CharOperation.equals(TypeConstants.ASSERT_NOTNULL, this.selector))
return NONNULL_ASSERTION;
if (CharOperation.equals(TypeConstants.ASSERT_NULL, this.selector))
return NULL_ASSERTION;
}
break;
case TypeIds.T_OrgApacheCommonsLangValidate:
if (parameterType.id == TypeIds.T_boolean) {
if (CharOperation.equals(TypeConstants.IS_TRUE, this.selector))
return TRUE_ASSERTION;
} else if (parameterType.id == TypeIds.T_JavaLangObject) {
if (CharOperation.equals(TypeConstants.NOT_NULL, this.selector))
return NONNULL_ASSERTION;
}
break;
case TypeIds.T_OrgApacheCommonsLang3Validate:
if (parameterType.id == TypeIds.T_boolean) {
if (CharOperation.equals(TypeConstants.IS_TRUE, this.selector))
return TRUE_ASSERTION;
} else if (parameterType.isTypeVariable()) {
if (CharOperation.equals(TypeConstants.NOT_NULL, this.selector))
return NONNULL_ASSERTION;
}
break;
case TypeIds.T_ComGoogleCommonBasePreconditions:
if (parameterType.id == TypeIds.T_boolean) {
if (CharOperation.equals(TypeConstants.CHECK_ARGUMENT, this.selector)
|| CharOperation.equals(TypeConstants.CHECK_STATE, this.selector))
return TRUE_ASSERTION;
} else if (parameterType.isTypeVariable()) {
if (CharOperation.equals(TypeConstants.CHECK_NOT_NULL, this.selector))
return NONNULL_ASSERTION;
}
break;
case TypeIds.T_JavaUtilObjects:
if (parameterType.isTypeVariable()) {
if (CharOperation.equals(TypeConstants.REQUIRE_NON_NULL, this.selector))
return NONNULL_ASSERTION;
}
break;
}
}
}
return 0;
}
示例6: nullityMismatchingTypeAnnotation
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
public void nullityMismatchingTypeAnnotation(Expression expression, TypeBinding providedType, TypeBinding requiredType, NullAnnotationMatching status)
{
if (providedType.id == TypeIds.T_null) {
nullityMismatchIsNull(expression, requiredType);
return;
}
String[] arguments ;
String[] shortArguments;
int problemId = 0;
String superHint = null;
String superHintShort = null;
if (status.superTypeHint != null) {
problemId = (status.isUnchecked()
? IProblem.NullityUncheckedTypeAnnotationDetailSuperHint
: IProblem.NullityMismatchingTypeAnnotationSuperHint);
superHint = status.superTypeHintName(this.options, false);
superHintShort = status.superTypeHintName(this.options, true);
} else {
problemId = (status.isUnchecked()
? IProblem.NullityUncheckedTypeAnnotationDetail
: (requiredType.isTypeVariable() && !requiredType.hasNullTypeAnnotations())
? IProblem.NullityMismatchAgainstFreeTypeVariable
: IProblem.NullityMismatchingTypeAnnotation);
if (problemId == IProblem.NullityMismatchAgainstFreeTypeVariable) {
arguments = new String[] { null, null, new String(requiredType.sourceName()) }; // don't show bounds here
shortArguments = new String[] { null, null, new String(requiredType.sourceName()) };
} else {
arguments = new String[2];
shortArguments = new String[2];
}
}
String requiredName;
String requiredNameShort;
if (problemId == IProblem.NullityMismatchAgainstFreeTypeVariable) {
requiredName = new String(requiredType.sourceName()); // don't show bounds here
requiredNameShort = new String(requiredType.sourceName()); // don't show bounds here
} else {
requiredName = new String(requiredType.nullAnnotatedReadableName(this.options, false));
requiredNameShort = new String(requiredType.nullAnnotatedReadableName(this.options, true));
}
String providedName = String.valueOf(providedType.nullAnnotatedReadableName(this.options, false));
String providedNameShort = String.valueOf(providedType.nullAnnotatedReadableName(this.options, true));
// assemble arguments:
if (superHint != null) {
arguments = new String[] { requiredName, providedName, superHint };
shortArguments = new String[] { requiredNameShort, providedNameShort, superHintShort };
} else {
arguments = new String[] { requiredName, providedName };
shortArguments = new String[] { requiredNameShort, providedNameShort };
}
this.handle(problemId, arguments, shortArguments, expression.sourceStart, expression.sourceEnd);
}
示例7: recordNestedType
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
public static void recordNestedType(ClassFile classFile, TypeBinding typeBinding) {
if (classFile.visitedTypes == null) {
classFile.visitedTypes = new HashSet(3);
} else if (classFile.visitedTypes.contains(typeBinding)) {
// type is already visited
return;
}
classFile.visitedTypes.add(typeBinding);
if (typeBinding.isParameterizedType()
&& ((typeBinding.tagBits & TagBits.ContainsNestedTypeReferences) != 0)) {
ParameterizedTypeBinding parameterizedTypeBinding = (ParameterizedTypeBinding) typeBinding;
ReferenceBinding genericType = parameterizedTypeBinding.genericType();
if ((genericType.tagBits & TagBits.ContainsNestedTypeReferences) != 0) {
recordNestedType(classFile, genericType);
}
TypeBinding[] arguments = parameterizedTypeBinding.arguments;
if (arguments != null) {
for (int j = 0, max2 = arguments.length; j < max2; j++) {
TypeBinding argument = arguments[j];
if (argument.isWildcard()) {
WildcardBinding wildcardBinding = (WildcardBinding) argument;
TypeBinding bound = wildcardBinding.bound;
if (bound != null
&& ((bound.tagBits & TagBits.ContainsNestedTypeReferences) != 0)) {
recordNestedType(classFile, bound);
}
ReferenceBinding superclass = wildcardBinding.superclass();
if (superclass != null
&& ((superclass.tagBits & TagBits.ContainsNestedTypeReferences) != 0)) {
recordNestedType(classFile, superclass);
}
ReferenceBinding[] superInterfaces = wildcardBinding.superInterfaces();
if (superInterfaces != null) {
for (int k = 0, max3 = superInterfaces.length; k < max3; k++) {
ReferenceBinding superInterface = superInterfaces[k];
if ((superInterface.tagBits & TagBits.ContainsNestedTypeReferences) != 0) {
recordNestedType(classFile, superInterface);
}
}
}
} else if ((argument.tagBits & TagBits.ContainsNestedTypeReferences) != 0) {
recordNestedType(classFile, argument);
}
}
}
} else if (typeBinding.isTypeVariable()
&& ((typeBinding.tagBits & TagBits.ContainsNestedTypeReferences) != 0)) {
TypeVariableBinding typeVariableBinding = (TypeVariableBinding) typeBinding;
TypeBinding upperBound = typeVariableBinding.upperBound();
if (upperBound != null && ((upperBound.tagBits & TagBits.ContainsNestedTypeReferences) != 0)) {
recordNestedType(classFile, upperBound);
}
TypeBinding[] upperBounds = typeVariableBinding.otherUpperBounds();
if (upperBounds != null) {
for (int k = 0, max3 = upperBounds.length; k < max3; k++) {
TypeBinding otherUpperBound = upperBounds[k];
if ((otherUpperBound.tagBits & TagBits.ContainsNestedTypeReferences) != 0) {
recordNestedType(classFile, otherUpperBound);
}
}
}
} else if (typeBinding.isNestedType()) {
classFile.recordInnerClasses(typeBinding);
}
}