use of org.revapi.java.model.AnnotationElement in project revapi by revapi.
the class JavaElementDifferenceAnalyzer method beginAnalysis.
@Override
public void beginAnalysis(@Nullable Element oldElement, @Nullable Element newElement) {
Timing.LOG.trace("Beginning analysis of {} and {}.", oldElement, newElement);
Check.Type elementsType = getCheckType(oldElement, newElement);
Collection<Check> possibleChecks = nonExistenceMode ? descendingChecksByTypes.getOrDefault(elementsType, emptySet()) : checksByInterest.get(elementsType);
if (conforms(oldElement, newElement, TypeElement.class)) {
checkTypeStack.push(CheckType.CLASS);
checksStack.push(possibleChecks);
lastAnnotationResults = null;
for (Check c : possibleChecks) {
Stats.of(c.getClass().getName()).start();
c.visitClass(oldElement == null ? null : (TypeElement) oldElement, newElement == null ? null : (TypeElement) newElement);
Stats.of(c.getClass().getName()).end(oldElement, newElement);
}
} else if (conforms(oldElement, newElement, AnnotationElement.class)) {
// treat them a bit differently
if (lastAnnotationResults == null) {
lastAnnotationResults = new ArrayList<>(4);
}
// Annotations are handled differently and this would lead to the stack corruption and missed problems!!!
for (Check c : possibleChecks) {
Stats.of(c.getClass().getName()).start();
List<Difference> cps = c.visitAnnotation(oldElement == null ? null : (AnnotationElement) oldElement, newElement == null ? null : (AnnotationElement) newElement);
if (cps != null) {
lastAnnotationResults.addAll(cps);
}
Stats.of(c.getClass().getName()).end(oldElement, newElement);
}
} else if (conforms(oldElement, newElement, FieldElement.class)) {
doRestrictedCheck((FieldElement) oldElement, (FieldElement) newElement, CheckType.FIELD, possibleChecks);
} else if (conforms(oldElement, newElement, MethodElement.class)) {
doRestrictedCheck((MethodElement) oldElement, (MethodElement) newElement, CheckType.METHOD, possibleChecks);
} else if (conforms(oldElement, newElement, MethodParameterElement.class)) {
doRestrictedCheck((MethodParameterElement) oldElement, (MethodParameterElement) newElement, CheckType.METHOD_PARAMETER, possibleChecks);
}
if (!nonExistenceMode && (oldElement == null || newElement == null)) {
nonExistenceMode = true;
nonExistenceOldRoot = oldElement;
nonExistenceNewRoot = newElement;
}
}
Aggregations