use of dyvilx.tools.compiler.ast.attribute.Attribute in project Dyvil by Dyvil.
the class ModifierUtil method checkModifiers.
public static void checkModifiers(IMember member, MarkerList markers) {
final AttributeList attributes = member.getAttributes();
final MemberKind memberKind = member.getKind();
final int defaultAccess = memberKind.getDefaultAccess(member);
StringBuilder errorBuilder = null;
for (Attribute modifier : attributes) {
if (!memberKind.isAttributeAllowed(modifier)) {
if (errorBuilder == null) {
errorBuilder = new StringBuilder();
} else {
errorBuilder.append(", ");
}
modifier.toString(errorBuilder);
}
final int visibility = modifier.flags() & Modifiers.VISIBILITY_MODIFIERS;
if (visibility != 0 && visibility == defaultAccess) {
markers.add(Markers.semantic(member.getPosition(), "modifiers.visibility.default", Util.memberNamed(member), ModifierUtil.accessModifiersToString(visibility)));
}
}
if (errorBuilder != null) {
markers.add(Markers.semanticError(member.getPosition(), "modifiers.illegal", Util.memberNamed(member), errorBuilder.toString()));
}
if (!attributes.hasAnyFlag(Modifiers.VISIBILITY_MODIFIERS)) {
// If there is no explicit or implicit visibility modifier already, add the default one
attributes.addFlag(defaultAccess);
}
}
Aggregations