本文整理汇总了Java中edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject类的典型用法代码示例。如果您正苦于以下问题:Java AnnotatedObject类的具体用法?Java AnnotatedObject怎么用?Java AnnotatedObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AnnotatedObject类属于edu.umd.cs.findbugs.classfile.analysis包,在下文中一共展示了AnnotatedObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDirectAnnotation
import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //导入依赖的package包/类
/**
* Get the direct annotations (if any) on given AnnotatedObject.
*
* @param m
* an AnnotatedObject
* @return Collection of AnnotationValues representing annotations directly
* applied to this AnnotatedObject
*/
private static Collection<AnnotationValue> getDirectAnnotation(AnnotatedObject m) {
Collection<AnnotationValue> result = getDirectObjectAnnotations().get(m);
if (result != null)
return result;
if (m.getAnnotationDescriptors().isEmpty())
return Collections.<AnnotationValue> emptyList();
result = TypeQualifierResolver.resolveTypeQualifiers(m.getAnnotations());
if (result.size() == 0)
result = Collections.<AnnotationValue> emptyList();
getDirectObjectAnnotations().put(m, result);
return result;
}
示例2: getEffectiveTypeQualifierAnnotation
import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //导入依赖的package包/类
/**
* Get the effective TypeQualifierAnnotation on given AnnotatedObject. Takes
* into account inherited and default (outer scope) annotations. Also takes
* exclusive qualifiers into account.
*
* @param o
* an AnnotatedObject
* @param typeQualifierValue
* a TypeQualifierValue specifying kind of annotation we want to
* look up
* @return the effective TypeQualifierAnnotation, or null if there is no
* effective TypeQualifierAnnotation on this AnnotatedObject
*/
public static TypeQualifierAnnotation getEffectiveTypeQualifierAnnotation(AnnotatedObject o,
TypeQualifierValue typeQualifierValue) {
if (o instanceof XMethod) {
XMethod m = (XMethod) o;
if (m.getName().startsWith("access$")) {
InnerClassAccessMap icam = AnalysisContext.currentAnalysisContext().getInnerClassAccessMap();
try {
InnerClassAccess ica = icam.getInnerClassAccess(m.getClassName(), m.getName());
if (ica != null && ica.isLoad()) {
o = ica.getField();
}
} catch (ClassNotFoundException e) {
AnalysisContext.reportMissingClass(e);
return null;
}
}
}
TypeQualifierAnnotation tqa = computeEffectiveTypeQualifierAnnotation(typeQualifierValue, o);
final AnnotatedObject o2 = o;
if (CHECK_EXCLUSIVE && tqa == null && typeQualifierValue.isExclusiveQualifier()) {
tqa = computeExclusiveQualifier(typeQualifierValue, new ComputeEffectiveTypeQualifierAnnotation() {
public TypeQualifierAnnotation compute(TypeQualifierValue tqv) {
return computeEffectiveTypeQualifierAnnotation(tqv, o2);
}
@Override
public String toString() {
return o2.toString();
}
});
}
return tqa;
}
示例3: getDirectTypeQualifierAnnotation
import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //导入依赖的package包/类
/**
* Get a directly-applied TypeQualifierAnnotation on given AnnotatedObject.
*
* @param o
* an AnnotatedObject
* @param typeQualifierValue
* the kind of TypeQualifierValue we are looking for
* @return directly-applied TypeQualifierAnnotation, or null if there is no
* such annotation on the AnnotatedObject
*/
private static TypeQualifierAnnotation getDirectTypeQualifierAnnotation(AnnotatedObject o,
TypeQualifierValue typeQualifierValue) {
TypeQualifierAnnotation result;
Set<TypeQualifierAnnotation> applications = new HashSet<TypeQualifierAnnotation>();
getDirectApplications(applications, o, o.getElementType());
result = findMatchingTypeQualifierAnnotation(applications, typeQualifierValue);
return result;
}
示例4: getDefaultTypeQualifierAnnotation
import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //导入依赖的package包/类
/**
* Get the default (outer scope) annotation applicable to given
* AnnotatedObject.
*
* @param o
* an AnnotatedObject
* @param typeQualifierValue
* the kind of TypeQualifierValue we are looking for
* @return the applicable default TypeQualifierAnnotation, or null if there
* is no default TypeQualifierAnnotation
*/
private static TypeQualifierAnnotation getDefaultTypeQualifierAnnotation(AnnotatedObject o,
TypeQualifierValue typeQualifierValue, boolean stopAtClassScope) {
if (o.isSynthetic())
return null; // synthetic objects don't get default annotations
ElementType elementType = o.getElementType();
while (true) {
o = o.getContainingScope();
if (o == null)
return null;
if (stopAtClassScope && o instanceof XClass)
return null;
TypeQualifierAnnotation result;
// Check direct applications of the type qualifier
Set<TypeQualifierAnnotation> applications = new HashSet<TypeQualifierAnnotation>();
getDirectApplications(applications, o, elementType);
result = findMatchingTypeQualifierAnnotation(applications, typeQualifierValue);
if (result != null) {
// Great - found an outer scope with a relevant annotation
assert false : "I don't think we should be looking here";
return result;
}
// Check default annotations
result = getDefaultAnnotation(o, typeQualifierValue, elementType);
if (result != null) {
return result;
}
}
}
示例5: getResolvedAnnotation
import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //导入依赖的package包/类
public NullnessAnnotation getResolvedAnnotation(Object o, boolean getMinimal) {
Profiler profiler = Global.getAnalysisCache().getProfiler();
profiler.start(this.getClass());
try {
if (DEBUG) {
System.out.println("getResolvedAnnotation: o=" + o + "...");
}
TypeQualifierAnnotation tqa = null;
if (o instanceof XMethodParameter) {
XMethodParameter param = (XMethodParameter) o;
tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(param.getMethod(),
param.getParameterNumber(), nonnullTypeQualifierValue);
} else if (o instanceof XMethod || o instanceof XField) {
tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation((AnnotatedObject) o,
nonnullTypeQualifierValue);
}
NullnessAnnotation result = toNullnessAnnotation(tqa);
if (DEBUG) {
if (result == null)
System.out.println(" ===> not found");
else
System.out.println(" ===> " + tqa + "/" + result.toString() );
}
return result;
} finally {
profiler.end(this.getClass());
}
}
示例6: getContainingScope
import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //导入依赖的package包/类
public @CheckForNull
AnnotatedObject getContainingScope() {
try {
return Global.getAnalysisCache().getClassAnalysis(XClass.class, getClassDescriptor());
} catch (CheckedAnalysisException e) {
return null;
}
}
示例7: analysisContextContained
import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //导入依赖的package包/类
private boolean analysisContextContained(XClass xclass) {
AnnotatedObject ao = xclass;
do {
if (ao.getAnnotation(AnalysisContextContainedAnnotation) != null)
return true;
ao = ao.getContainingScope();
} while (ao != null);
return false;
}
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:12,代码来源:CheckAnalysisContextContainedAnnotation.java
示例8: getEffectiveTypeQualifierAnnotation
import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //导入依赖的package包/类
/**
* Get the effective TypeQualifierAnnotation on given AnnotatedObject. Takes
* into account inherited and default (outer scope) annotations. Also takes
* exclusive qualifiers into account.
*
* @param o
* an AnnotatedObject
* @param typeQualifierValue
* a TypeQualifierValue specifying kind of annotation we want to
* look up
* @return the effective TypeQualifierAnnotation, or null if there is no
* effective TypeQualifierAnnotation on this AnnotatedObject
*/
public static TypeQualifierAnnotation getEffectiveTypeQualifierAnnotation(AnnotatedObject o,
TypeQualifierValue<?> typeQualifierValue) {
if (o instanceof XMethod) {
XMethod m = (XMethod) o;
if (m.getName().startsWith("access$")) {
InnerClassAccessMap icam = AnalysisContext.currentAnalysisContext().getInnerClassAccessMap();
try {
InnerClassAccess ica = icam.getInnerClassAccess(m.getClassName(), m.getName());
if (ica != null && ica.isLoad()) {
o = ica.getField();
}
} catch (ClassNotFoundException e) {
AnalysisContext.reportMissingClass(e);
return null;
}
}
}
TypeQualifierAnnotation tqa = computeEffectiveTypeQualifierAnnotation(typeQualifierValue, o);
final AnnotatedObject o2 = o;
if (CHECK_EXCLUSIVE && tqa == null && typeQualifierValue.isExclusiveQualifier()) {
tqa = computeExclusiveQualifier(typeQualifierValue, new ComputeEffectiveTypeQualifierAnnotation() {
public TypeQualifierAnnotation compute(TypeQualifierValue<?> tqv) {
return computeEffectiveTypeQualifierAnnotation(tqv, o2);
}
@Override
public String toString() {
return o2.toString();
}
});
}
return tqa;
}
示例9: getDirectTypeQualifierAnnotation
import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //导入依赖的package包/类
/**
* Get a directly-applied TypeQualifierAnnotation on given AnnotatedObject.
*
* @param o
* an AnnotatedObject
* @param typeQualifierValue
* the kind of TypeQualifierValue we are looking for
* @return directly-applied TypeQualifierAnnotation, or null if there is no
* such annotation on the AnnotatedObject
*/
private static TypeQualifierAnnotation getDirectTypeQualifierAnnotation(AnnotatedObject o,
TypeQualifierValue<?> typeQualifierValue) {
TypeQualifierAnnotation result;
Set<TypeQualifierAnnotation> applications = new HashSet<TypeQualifierAnnotation>();
getDirectApplications(applications, o, o.getElementType());
result = findMatchingTypeQualifierAnnotation(applications, typeQualifierValue);
return result;
}
示例10: getDefaultTypeQualifierAnnotation
import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //导入依赖的package包/类
/**
* Get the default (outer scope) annotation applicable to given
* AnnotatedObject.
*
* @param o
* an AnnotatedObject
* @param typeQualifierValue
* the kind of TypeQualifierValue we are looking for
* @return the applicable default TypeQualifierAnnotation, or null if there
* is no default TypeQualifierAnnotation
*/
private static TypeQualifierAnnotation getDefaultTypeQualifierAnnotation(AnnotatedObject o,
TypeQualifierValue<?> typeQualifierValue, boolean stopAtClassScope) {
if (o.isSynthetic())
return null; // synthetic objects don't get default annotations
ElementType elementType = o.getElementType();
while (true) {
o = o.getContainingScope();
if (o == null)
return null;
if (stopAtClassScope && o instanceof XClass)
return null;
TypeQualifierAnnotation result;
// Check direct applications of the type qualifier
Set<TypeQualifierAnnotation> applications = new HashSet<TypeQualifierAnnotation>();
getDirectApplications(applications, o, elementType);
result = findMatchingTypeQualifierAnnotation(applications, typeQualifierValue);
if (result != null) {
// Great - found an outer scope with a relevant annotation
assert false : "I don't think we should be looking here";
return result;
}
// Check default annotations
result = getDefaultAnnotation(o, typeQualifierValue, elementType);
if (result != null) {
return result;
}
}
}
示例11: getDirectAnnotation
import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //导入依赖的package包/类
public @CheckForNull NullnessAnnotation getDirectAnnotation(Object o) {
Profiler profiler = Global.getAnalysisCache().getProfiler();
profiler.start(this.getClass());
try {
if (DEBUG) {
System.out.println("getDirectAnnotation: o=" + o + "...");
}
TypeQualifierAnnotation tqa = null;
if (o instanceof XMethodParameter) {
XMethodParameter param = (XMethodParameter) o;
tqa = TypeQualifierApplications.getDirectTypeQualifierAnnotation(param.getMethod(),
param.getParameterNumber(), nonnullTypeQualifierValue);
} else if (o instanceof XMethod || o instanceof XField) {
tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation((AnnotatedObject) o,
nonnullTypeQualifierValue);
}
NullnessAnnotation result = toNullnessAnnotation(tqa);
if (DEBUG) {
if (result == null)
System.out.println(" ===> not found");
else
System.out.println(" ===> " + tqa + "/" + result.toString() );
}
return result;
} finally {
profiler.end(this.getClass());
}
}
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:33,代码来源:TypeQualifierNullnessAnnotationDatabase.java
示例12: getEffectiveObjectAnnotations
import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //导入依赖的package包/类
private static Map<TypeQualifierValue, Map<AnnotatedObject, TypeQualifierAnnotation>> getEffectiveObjectAnnotations() {
return instance.get().effectiveObjectAnnotations;
}
示例13: getDirectObjectAnnotations
import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //导入依赖的package包/类
private static Map<AnnotatedObject, Collection<AnnotationValue>> getDirectObjectAnnotations() {
return instance.get().directObjectAnnotations;
}
示例14: updateAnnotations
import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //导入依赖的package包/类
public static void updateAnnotations(AnnotatedObject object) {
// TODO: Be smarter. Can we do something other than clear everything?
clearInstance();
}
示例15: getDefaultAnnotation
import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //导入依赖的package包/类
/**
* Look for a default type qualifier annotation.
*
* @param o
* an AnnotatedObject
* @param typeQualifierValue
* a TypeQualifierValue
* @param elementType
* type of element for which we're looking for a default
* annotation
* @return default TypeQualifierAnnotation, or null if none
*/
private static @CheckForNull
TypeQualifierAnnotation getDefaultAnnotation(AnnotatedObject o, TypeQualifierValue typeQualifierValue, ElementType elementType) {
//
// Try to find a default annotation using the standard JSR-305
// default annotation mechanism.
//
TypeQualifierAnnotation result;
Collection<AnnotationValue> values = TypeQualifierResolver.resolveTypeQualifierDefaults(o.getAnnotations(), elementType);
TypeQualifierAnnotation tqa = extractAnnotation(values, typeQualifierValue);
if (tqa != null) {
// System.out.println("Found default annotation of " + tqa +
// " for element " + elementType + " in " + o);
return tqa;
}
//
// Try one of the FindBugs-specific default annotation mechanisms.
//
if ((result = checkFindBugsDefaultAnnotation(FindBugsDefaultAnnotations.DEFAULT_ANNOTATION, o, typeQualifierValue)) != null) {
return result;
}
switch (elementType) {
case FIELD:
result = checkFindBugsDefaultAnnotation(FindBugsDefaultAnnotations.DEFAULT_ANNOTATION_FOR_FIELDS, o,
typeQualifierValue);
break;
case METHOD:
result = checkFindBugsDefaultAnnotation(FindBugsDefaultAnnotations.DEFAULT_ANNOTATION_FOR_METHODS, o,
typeQualifierValue);
break;
case PARAMETER:
result = checkFindBugsDefaultAnnotation(FindBugsDefaultAnnotations.DEFAULT_ANNOTATION_FOR_PARAMETERS, o,
typeQualifierValue);
break;
default:
// ignore
}
return result;
}