本文整理了Java中org.eclipse.jdt.internal.compiler.ast.Annotation.nullLocationBitsFromAnnotationValue()
方法的一些代码示例,展示了Annotation.nullLocationBitsFromAnnotationValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotation.nullLocationBitsFromAnnotationValue()
方法的具体详情如下:
包路径:org.eclipse.jdt.internal.compiler.ast.Annotation
类名称:Annotation
方法名:nullLocationBitsFromAnnotationValue
[英]Convert the value() attribute of @NonNullByDefault into a bitvector a la Binding#NullnessDefaultMASK. This method understands value encodings from source and binary types. pre: null annotation analysis is enabled
[中]将@NonNullByDefault的value()属性转换为位向量a la Binding#nullnessdaultmask。此方法理解源类型和二进制类型的值编码。前置:已启用空批注分析
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core
static int getNonNullByDefaultValue(AnnotationBinding annotation) {
ElementValuePair[] elementValuePairs = annotation.getElementValuePairs();
if (elementValuePairs == null || elementValuePairs.length == 0 ) {
// no argument: apply default default
ReferenceBinding annotationType = annotation.getAnnotationType();
if (annotationType == null) return 0;
MethodBinding[] annotationMethods = annotationType.methods();
if (annotationMethods != null && annotationMethods.length == 1) {
Object value = annotationMethods[0].getDefaultValue();
return Annotation.nullLocationBitsFromAnnotationValue(value);
}
return DefaultLocationsForTrueValue; // custom unconfigurable NNBD
} else if (elementValuePairs.length > 0) {
// evaluate the contained EnumConstantSignatures:
int nullness = 0;
for (int i = 0; i < elementValuePairs.length; i++)
nullness |= Annotation.nullLocationBitsFromAnnotationValue(elementValuePairs[i].getValue());
return nullness;
} else {
// empty argument: cancel all defaults from enclosing scopes
return NULL_UNSPECIFIED_BY_DEFAULT;
}
}
代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core
private long determineNonNullByDefaultTagBits(ReferenceBinding annotationType, MemberValuePair valueAttribute) {
long tagBits = 0;
Object value = null;
if (valueAttribute != null) {
if (valueAttribute.compilerElementPair != null)
value = valueAttribute.compilerElementPair.value;
} else { // fetch default value - TODO: cache it?
MethodBinding[] methods = annotationType.methods();
if (methods != null && methods.length == 1)
value = methods[0].getDefaultValue();
else
tagBits |= TagBits.AnnotationNonNullByDefault; // custom unconfigurable NNBD
}
if (value instanceof BooleanConstant) {
// boolean value is used for declaration annotations, signal using the annotation tag bit:
tagBits |= ((BooleanConstant)value).booleanValue() ? TagBits.AnnotationNonNullByDefault : TagBits.AnnotationNullUnspecifiedByDefault;
} else if (value != null) {
// non-boolean value signals type annotations, evaluate from DefaultLocation[] to bitvector a la Binding#NullnessDefaultMASK:
tagBits |= nullLocationBitsFromAnnotationValue(value);
}
return tagBits;
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core
private long determineNonNullByDefaultTagBits(ReferenceBinding annotationType, MemberValuePair valueAttribute) {
long tagBits = 0;
Object value = null;
if (valueAttribute != null) {
if (valueAttribute.compilerElementPair != null)
value = valueAttribute.compilerElementPair.value;
} else { // fetch default value - TODO: cache it?
MethodBinding[] methods = annotationType.methods();
if (methods != null && methods.length == 1)
value = methods[0].getDefaultValue();
else
tagBits |= Binding.DefaultLocationsForTrueValue; // custom unconfigurable NNBD
}
if (value instanceof BooleanConstant) {
// boolean value is used for declaration annotations, signal using the annotation tag bit:
tagBits |= ((BooleanConstant)value).booleanValue() ? Binding.DefaultLocationsForTrueValue : Binding.NULL_UNSPECIFIED_BY_DEFAULT;
} else if (value != null) {
// non-boolean value signals type annotations, evaluate from DefaultLocation[] to bitvector a la Binding#NullnessDefaultMASK:
tagBits |= nullLocationBitsFromAnnotationValue(value);
} else {
int result = BinaryTypeBinding.evaluateTypeQualifierDefault(annotationType);
if(result != 0) {
return result;
}
}
return tagBits;
}
代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core
/** given an application of @NonNullByDefault convert the annotation argument (if any) into a bitvector a la {@link Binding#NullnessDefaultMASK} */
// pre: null annotation analysis is enabled
int getNonNullByDefaultValue(IBinaryAnnotation annotation) {
char[] annotationTypeName = annotation.getTypeName();
char[][] typeName = signature2qualifiedTypeName(annotationTypeName);
IBinaryElementValuePair[] elementValuePairs = annotation.getElementValuePairs();
if (elementValuePairs == null || elementValuePairs.length == 0 ) {
// no argument: apply default default
ReferenceBinding annotationType = this.environment.getType(typeName, this.environment.UnNamedModule); // TODO(SHMOD): null annotations from a module?
if (annotationType == null) return 0;
if (annotationType.isUnresolvedType())
annotationType = ((UnresolvedReferenceBinding) annotationType).resolve(this.environment, false);
MethodBinding[] annotationMethods = annotationType.methods();
if (annotationMethods != null && annotationMethods.length == 1) {
Object value = annotationMethods[0].getDefaultValue();
return Annotation.nullLocationBitsFromAnnotationValue(value);
}
return NONNULL_BY_DEFAULT; // custom unconfigurable NNBD
} else if (elementValuePairs.length > 0) {
// evaluate the contained EnumConstantSignatures:
int nullness = 0;
for (int i = 0; i < elementValuePairs.length; i++)
nullness |= Annotation.nullLocationBitsFromAnnotationValue(elementValuePairs[i].getValue());
return nullness;
} else {
// empty argument: cancel all defaults from enclosing scopes
return NULL_UNSPECIFIED_BY_DEFAULT;
}
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core
/** given an application of @NonNullByDefault convert the annotation argument (if any) into a bitvector a la {@link Binding#NullnessDefaultMASK} */
// pre: null annotation analysis is enabled
int getNonNullByDefaultValue(IBinaryAnnotation annotation) {
char[] annotationTypeName = annotation.getTypeName();
char[][] typeName = signature2qualifiedTypeName(annotationTypeName);
IBinaryElementValuePair[] elementValuePairs = annotation.getElementValuePairs();
if (elementValuePairs == null || elementValuePairs.length == 0 ) {
// no argument: apply default default
ReferenceBinding annotationType = this.environment.getType(typeName);
if (annotationType == null) return 0;
if (annotationType.isUnresolvedType())
annotationType = ((UnresolvedReferenceBinding) annotationType).resolve(this.environment, false);
MethodBinding[] annotationMethods = annotationType.methods();
if (annotationMethods != null && annotationMethods.length == 1) {
Object value = annotationMethods[0].getDefaultValue();
return Annotation.nullLocationBitsFromAnnotationValue(value);
}
return NONNULL_BY_DEFAULT; // custom unconfigurable NNBD
} else if (elementValuePairs.length > 0) {
// evaluate the contained EnumConstantSignatures:
int nullness = 0;
for (int i = 0; i < elementValuePairs.length; i++)
nullness |= Annotation.nullLocationBitsFromAnnotationValue(elementValuePairs[i].getValue());
return nullness;
} else {
// empty argument: cancel all defaults from enclosing scopes
return NULL_UNSPECIFIED_BY_DEFAULT;
}
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/ecj
/** given an application of @NonNullByDefault convert the annotation argument (if any) into a bitvector a la {@link Binding#NullnessDefaultMASK} */
// pre: null annotation analysis is enabled
int getNonNullByDefaultValue(IBinaryAnnotation annotation) {
char[] annotationTypeName = annotation.getTypeName();
char[][] typeName = signature2qualifiedTypeName(annotationTypeName);
IBinaryElementValuePair[] elementValuePairs = annotation.getElementValuePairs();
if (elementValuePairs == null || elementValuePairs.length == 0 ) {
// no argument: apply default default
ReferenceBinding annotationType = this.environment.getType(typeName);
if (annotationType == null) return 0;
if (annotationType.isUnresolvedType())
annotationType = ((UnresolvedReferenceBinding) annotationType).resolve(this.environment, false);
MethodBinding[] annotationMethods = annotationType.methods();
if (annotationMethods != null && annotationMethods.length == 1) {
Object value = annotationMethods[0].getDefaultValue();
return Annotation.nullLocationBitsFromAnnotationValue(value);
}
return NONNULL_BY_DEFAULT; // custom unconfigurable NNBD
} else if (elementValuePairs.length > 0) {
// evaluate the contained EnumConstantSignatures:
int nullness = 0;
for (int i = 0; i < elementValuePairs.length; i++)
nullness |= Annotation.nullLocationBitsFromAnnotationValue(elementValuePairs[i].getValue());
return nullness;
} else {
// empty argument: cancel all defaults from enclosing scopes
return NULL_UNSPECIFIED_BY_DEFAULT;
}
}
代码示例来源:origin: org.eclipse.jdt.core.compiler/ecj
/** given an application of @NonNullByDefault convert the annotation argument (if any) into a bitvector a la {@link Binding#NullnessDefaultMASK} */
// pre: null annotation analysis is enabled
int getNonNullByDefaultValue(IBinaryAnnotation annotation) {
char[] annotationTypeName = annotation.getTypeName();
char[][] typeName = signature2qualifiedTypeName(annotationTypeName);
IBinaryElementValuePair[] elementValuePairs = annotation.getElementValuePairs();
if (elementValuePairs == null || elementValuePairs.length == 0 ) {
// no argument: apply default default
ReferenceBinding annotationType = this.environment.getType(typeName);
if (annotationType == null) return 0;
if (annotationType.isUnresolvedType())
annotationType = ((UnresolvedReferenceBinding) annotationType).resolve(this.environment, false);
MethodBinding[] annotationMethods = annotationType.methods();
if (annotationMethods != null && annotationMethods.length == 1) {
Object value = annotationMethods[0].getDefaultValue();
return Annotation.nullLocationBitsFromAnnotationValue(value);
}
return NONNULL_BY_DEFAULT; // custom unconfigurable NNBD
} else if (elementValuePairs.length > 0) {
// evaluate the contained EnumConstantSignatures:
int nullness = 0;
for (int i = 0; i < elementValuePairs.length; i++)
nullness |= Annotation.nullLocationBitsFromAnnotationValue(elementValuePairs[i].getValue());
return nullness;
} else {
// empty argument: cancel all defaults from enclosing scopes
return NULL_UNSPECIFIED_BY_DEFAULT;
}
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core
if (annotationMethods != null && annotationMethods.length == 1) {
Object value = annotationMethods[0].getDefaultValue();
return Annotation.nullLocationBitsFromAnnotationValue(value);
nullness |= Annotation.nullLocationBitsFromAnnotationValue(elementValuePairs[i].getValue());
return nullness;
} else {
代码示例来源:origin: org.eclipse.jdt.core.compiler/ecj
} else if (value != null) {
tagBits |= nullLocationBitsFromAnnotationValue(value);
代码示例来源:origin: org.eclipse.scout.sdk.deps/ecj
} else if (value != null) {
tagBits |= nullLocationBitsFromAnnotationValue(value);
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core
} else if (value != null) {
tagBits |= nullLocationBitsFromAnnotationValue(value);
内容来源于网络,如有侵权,请联系作者删除!