use of org.revapi.java.spi.JavaModelElement in project revapi by revapi.
the class VisibilityChanged method doEnd.
@Override
protected final List<Difference> doEnd() {
CheckBase.ActiveElements<JavaModelElement> elements = popIfActive();
if (elements != null) {
Modifier oldVisibility = getVisibility(elements.oldElement.getDeclaringElement());
Modifier newVisibility = getVisibility(elements.newElement.getDeclaringElement());
// public == 0, private == 3
if (isProblem(getModifierRank(oldVisibility), getModifierRank(newVisibility))) {
return Collections.singletonList(report(elements, oldVisibility, newVisibility));
}
}
return null;
}
use of org.revapi.java.spi.JavaModelElement in project revapi by revapi.
the class FormalTypeParametersChanged method doEnd.
@Nullable
@Override
protected List<Difference> doEnd() {
ActiveElements<JavaModelElement> els = popIfActive();
if (els == null) {
return null;
}
@SuppressWarnings("unchecked") List<TypeParameterElement> added = (List<TypeParameterElement>) els.context[0];
@SuppressWarnings("unchecked") List<TypeParameterElement> removed = (List<TypeParameterElement>) els.context[1];
@SuppressWarnings("unchecked") Map<TypeParameterElement, TypeParameterElement> changed = (Map<TypeParameterElement, TypeParameterElement>) els.context[2];
Parameterizable oldT = (Parameterizable) els.oldElement.getDeclaringElement();
List<Difference> diffs = new ArrayList<>();
if (oldT.getTypeParameters().isEmpty()) {
diffs.add(createDifference(Code.GENERICS_ELEMENT_NOW_PARAMETERIZED, Code.attachmentsFor(els.oldElement, els.newElement)));
}
for (TypeParameterElement e : added) {
diffs.add(createDifferenceWithExplicitParams(Code.GENERICS_FORMAL_TYPE_PARAMETER_ADDED, Code.attachmentsFor(els.oldElement, els.newElement), Util.toHumanReadableString(e)));
}
for (TypeParameterElement e : removed) {
diffs.add(createDifferenceWithExplicitParams(Code.GENERICS_FORMAL_TYPE_PARAMETER_REMOVED, Code.attachmentsFor(els.oldElement, els.newElement), Util.toHumanReadableString(e)));
}
for (Map.Entry<TypeParameterElement, TypeParameterElement> e : changed.entrySet()) {
String oldP = Util.toHumanReadableString(e.getKey());
String newP = Util.toHumanReadableString(e.getValue());
diffs.add(createDifferenceWithExplicitParams(Code.GENERICS_FORMAL_TYPE_PARAMETER_CHANGED, Code.attachmentsFor(els.oldElement, els.newElement, "oldTypeParameter", oldP, "newTypeParameter", newP), oldP, newP));
}
return diffs;
}
use of org.revapi.java.spi.JavaModelElement in project revapi by revapi.
the class MovedInHierarchy method doEnd.
@Nullable
@Override
protected List<Difference> doEnd() {
ActiveElements<JavaModelElement> els = popIfActive();
if (els == null) {
return null;
}
String oldType = Util.toHumanReadableString(els.oldElement.getDeclaringElement().getEnclosingElement().asType());
String newType = Util.toHumanReadableString(els.newElement.getDeclaringElement().getEnclosingElement().asType());
// we know that oldEl.isInherited() != newEl.isInherited(), so it's enough to just check for the old
Code code = els.oldElement.isInherited() ? moveDown : moveUp;
return Collections.singletonList(createDifference(code, Code.attachmentsFor(els.oldElement, els.newElement, "oldClass", oldType, "newClass", newType)));
}
Aggregations