本文整理汇总了Java中org.eclipse.jdt.internal.compiler.lookup.TypeIds.T_ConfiguredAnnotationNullable方法的典型用法代码示例。如果您正苦于以下问题:Java TypeIds.T_ConfiguredAnnotationNullable方法的具体用法?Java TypeIds.T_ConfiguredAnnotationNullable怎么用?Java TypeIds.T_ConfiguredAnnotationNullable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.compiler.lookup.TypeIds
的用法示例。
在下文中一共展示了TypeIds.T_ConfiguredAnnotationNullable方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findAnnotation
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; //导入方法依赖的package包/类
/** Retrieve the null annotation that has been translated to the given nullTagBits. */
public Annotation findAnnotation(long nullTagBits) {
if (this.annotations != null) {
Annotation[] innerAnnotations = this.annotations[this.annotations.length-1];
if (innerAnnotations != null) {
int annId = nullTagBits == TagBits.AnnotationNonNull ? TypeIds.T_ConfiguredAnnotationNonNull : TypeIds.T_ConfiguredAnnotationNullable;
for (int i = 0; i < innerAnnotations.length; i++) {
if (innerAnnotations[i] != null
&& innerAnnotations[i].resolvedType != null
&& innerAnnotations[i].resolvedType.id == annId)
return innerAnnotations[i];
}
}
}
return null;
}
示例2: illegalAnnotationForBaseType
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; //导入方法依赖的package包/类
public void illegalAnnotationForBaseType(TypeReference type, Annotation[] annotations, long nullAnnotationTagBit)
{
int typeId = (nullAnnotationTagBit == TagBits.AnnotationNullable)
? TypeIds.T_ConfiguredAnnotationNullable : TypeIds.T_ConfiguredAnnotationNonNull;
char[][] annotationNames = (nullAnnotationTagBit == TagBits.AnnotationNonNull)
? this.options.nonNullAnnotationName
: this.options.nullableAnnotationName;
String[] args = new String[] { new String(annotationNames[annotationNames.length-1]), new String(type.getLastToken()) };
Annotation annotation = findAnnotation(annotations, typeId);
int start = annotation != null ? annotation.sourceStart : type.sourceStart;
int end = annotation != null ? annotation.sourceEnd : type.sourceEnd;
this.handle(IProblem.IllegalAnnotationForBaseType,
args,
args,
start,
end);
}
示例3: mergeParameterNullAnnotations
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; //导入方法依赖的package包/类
private void mergeParameterNullAnnotations(BlockScope currentScope) {
LookupEnvironment env = currentScope.environment();
TypeBinding[] ourParameters = this.binding.parameters;
TypeBinding[] descParameters = this.descriptor.parameters;
int len = Math.min(ourParameters.length, descParameters.length);
for (int i = 0; i < len; i++) {
long ourTagBits = ourParameters[i].tagBits & TagBits.AnnotationNullMASK;
long descTagBits = descParameters[i].tagBits & TagBits.AnnotationNullMASK;
if (ourTagBits == 0L) {
if (descTagBits != 0L && !ourParameters[i].isBaseType()) {
AnnotationBinding [] annotations = descParameters[i].getTypeAnnotations();
for (int j = 0, length = annotations.length; j < length; j++) {
AnnotationBinding annotation = annotations[j];
if (annotation != null) {
switch (annotation.getAnnotationType().id) {
case TypeIds.T_ConfiguredAnnotationNullable :
case TypeIds.T_ConfiguredAnnotationNonNull :
ourParameters[i] = env.createAnnotatedType(ourParameters[i], new AnnotationBinding [] { annotation });
break;
}
}
}
}
} else if (ourTagBits != descTagBits) {
if (ourTagBits == TagBits.AnnotationNonNull) { // requested @NonNull not provided
char[][] inheritedAnnotationName = null;
if (descTagBits == TagBits.AnnotationNullable)
inheritedAnnotationName = env.getNullableAnnotationName();
currentScope.problemReporter().illegalRedefinitionToNonNullParameter(this.arguments[i], this.descriptor.declaringClass, inheritedAnnotationName);
}
}
}
}
示例4: excludeDueToAnnotation
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; //导入方法依赖的package包/类
/**
* Returns true if a private member should not be warned as unused if
* annotated with a non-standard annotation.
* https://bugs.eclipse.org/365437
* https://bugs.eclipse.org/376590
*/
private boolean excludeDueToAnnotation(Annotation[] annotations, int problemId) {
int annotationsLen = 0;
if (annotations != null) {
annotationsLen = annotations.length;
} else {
return false;
}
if (annotationsLen == 0) return false;
for (int i = 0; i < annotationsLen; i++) {
TypeBinding resolvedType = annotations[i].resolvedType;
if (resolvedType != null) {
switch (resolvedType.id) {
case TypeIds.T_JavaLangSuppressWarnings:
case TypeIds.T_JavaLangDeprecated:
case TypeIds.T_JavaLangSafeVarargs:
case TypeIds.T_ConfiguredAnnotationNonNull:
case TypeIds.T_ConfiguredAnnotationNullable:
case TypeIds.T_ConfiguredAnnotationNonNullByDefault:
break;
case TypeIds.T_JavaxInjectInject:
case TypeIds.T_ComGoogleInjectInject:
if (problemId != IProblem.UnusedPrivateField)
return true; // @Inject on method/ctor does constitute a relevant use, just on fields it doesn't
break;
default:
// non-standard annotation found, don't warn
return true;
}
}
}
return false;
}
示例5: illegalRedefinitionToNonNullParameter
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; //导入方法依赖的package包/类
public void illegalRedefinitionToNonNullParameter(Argument argument, ReferenceBinding declaringClass, char[][] inheritedAnnotationName) {
int sourceStart = argument.type.sourceStart;
if (argument.annotations != null) {
for (int i=0; i<argument.annotations.length; i++) {
Annotation annotation = argument.annotations[i];
if ( annotation.resolvedType.id == TypeIds.T_ConfiguredAnnotationNullable
|| annotation.resolvedType.id == TypeIds.T_ConfiguredAnnotationNonNull)
{
sourceStart = annotation.sourceStart;
break;
}
}
}
if (inheritedAnnotationName == null) {
this.handle(
IProblem.IllegalDefinitionToNonNullParameter,
new String[] { new String(argument.name), new String(declaringClass.readableName()) },
new String[] { new String(argument.name), new String(declaringClass.shortReadableName()) },
sourceStart,
argument.type.sourceEnd);
} else {
this.handle(
IProblem.IllegalRedefinitionToNonNullParameter,
new String[] { new String(argument.name), new String(declaringClass.readableName()), CharOperation.toString(inheritedAnnotationName)},
new String[] { new String(argument.name), new String(declaringClass.shortReadableName()), new String(inheritedAnnotationName[inheritedAnnotationName.length-1])},
sourceStart,
argument.type.sourceEnd);
}
}
示例6: excludeDueToAnnotation
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; //导入方法依赖的package包/类
/**
* Returns true if a private member should not be warned as unused if
* annotated with a non-standard annotation.
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=365437
*/
private boolean excludeDueToAnnotation(Annotation[] annotations) {
int annotationsLen = 0;
if (annotations != null) {
annotationsLen = annotations.length;
} else {
return false;
}
if (annotationsLen == 0) return false;
for (int i = 0; i < annotationsLen; i++) {
TypeBinding resolvedType = annotations[i].resolvedType;
if (resolvedType != null) {
switch (resolvedType.id) {
case TypeIds.T_JavaLangSuppressWarnings:
case TypeIds.T_JavaLangDeprecated:
case TypeIds.T_JavaLangSafeVarargs:
case TypeIds.T_ConfiguredAnnotationNonNull:
case TypeIds.T_ConfiguredAnnotationNullable:
case TypeIds.T_ConfiguredAnnotationNonNullByDefault:
break;
default:
// non-standard annotation found, don't warn
return true;
}
}
}
return false;
}
示例7: illegalAnnotationForBaseType
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; //导入方法依赖的package包/类
public void illegalAnnotationForBaseType(TypeReference type, Annotation[] annotations, char[] annotationName, long nullAnnotationTagBit)
{
int typeId = (nullAnnotationTagBit == TagBits.AnnotationNullable)
? TypeIds.T_ConfiguredAnnotationNullable : TypeIds.T_ConfiguredAnnotationNonNull;
String[] args = new String[] { new String(annotationName), new String(type.getLastToken()) };
Annotation annotation = findAnnotation(annotations, typeId);
int start = annotation != null ? annotation.sourceStart : type.sourceStart;
this.handle(IProblem.IllegalAnnotationForBaseType,
args,
args,
start,
type.sourceEnd);
}