use of dyvilx.tools.parsing.marker.Marker in project Dyvil by Dyvil.
the class CodeTypeParameter method resolveTypes.
@Override
public void resolveTypes(MarkerList markers, IContext context) {
this.attributes.resolveTypes(markers, context, this);
if (this.lowerBound != null) {
this.lowerBound = this.lowerBound.resolveType(markers, context);
}
this.upperBound = this.upperBound.resolveType(markers, context);
this.upperBounds = getUpperBounds(this.upperBound);
// The first upper bound is meant to be a class bound.
IType type = this.upperBounds[0];
IClass typeClass = type.getTheClass();
if (typeClass != null && !typeClass.isInterface()) {
// If the first type is a class type (not an interface), it becomes the erasure type.
this.erasure = type;
}
// Check if the remaining upper bounds are interfaces
for (int i = 1, count = this.upperBounds.length; i < count; i++) {
type = this.upperBounds[i];
typeClass = type.getTheClass();
if (typeClass != null && !typeClass.isInterface()) {
final Marker marker = Markers.semanticError(type.getPosition(), "type_parameter.bound.class");
marker.addInfo(Markers.getSemantic("class.declaration", Util.classSignatureToString(typeClass)));
markers.add(marker);
}
}
}
use of dyvilx.tools.parsing.marker.Marker in project Dyvil by Dyvil.
the class OperatorElement method checkPosition.
public static void checkPosition(MarkerList markers, SourcePosition position, IOperator operator, byte expectedType) {
if (!operator.isType(expectedType)) {
final Marker marker = Markers.semantic(position, "operator.invalid_position", operator.getName(), typeToString(operator.getType()), typeToString(expectedType));
marker.addInfo(Markers.getSemantic("operator.declaration", operator.toString()));
markers.add(marker);
}
}
use of dyvilx.tools.parsing.marker.Marker in project Dyvil by Dyvil.
the class Deprecation method checkUsageInfo.
private static void checkUsageInfo(IMember member, SourcePosition position, MarkerList markers, Annotation annotation) {
final ArgumentList arguments = annotation.getArguments();
final MarkerLevel markerLevel = AnnotationUtil.getEnumValue(arguments, INF_LEVEL_PARAM, MarkerLevel.class);
if (markerLevel == null || markerLevel == MarkerLevel.IGNORE) {
return;
}
String value = AnnotationUtil.getStringValue(arguments, INF_VALUE_PARAM);
final String description = AnnotationUtil.getStringValue(arguments, INF_DESC_PARAM);
value = replaceMember(member, value);
final Marker marker = Markers.withText(position, markerLevel, value);
assert marker != null;
// Description
if (description != null && !description.isEmpty()) {
marker.addInfo(Markers.getSemantic("experimental.description", description));
}
markers.add(marker);
}
use of dyvilx.tools.parsing.marker.Marker in project Dyvil by Dyvil.
the class CodeConstructor method check.
@Override
public void check(MarkerList markers, IContext context) {
context = context.push(this);
super.check(markers, context);
this.parameters.check(markers, context);
if (this.exceptions != null) {
for (int i = 0; i < this.exceptions.size(); i++) {
final IType exceptionType = this.exceptions.get(i);
exceptionType.check(markers, context);
if (!Types.isSuperType(Types.THROWABLE, exceptionType)) {
final Marker marker = Markers.semanticError(exceptionType.getPosition(), "method.exception.type");
marker.addInfo(Markers.getSemantic("exception.type", exceptionType));
markers.add(marker);
}
}
}
if (this.initializerCall != null) {
this.initializerCall.check(markers, context);
}
if (this.value != null) {
this.value.check(markers, this);
} else if (this.initializerCall == null) {
markers.add(Markers.semanticError(this.position, "constructor.abstract"));
}
if (this.isStatic()) {
markers.add(Markers.semanticError(this.position, "constructor.static", this.name));
}
context.pop();
}
use of dyvilx.tools.parsing.marker.Marker in project Dyvil by Dyvil.
the class CodeAnnotation method check.
@Override
public void check(MarkerList markers, IContext context, ElementType target) {
super.check(markers, context, target);
if (this.type == null || !this.type.isResolved()) {
return;
}
final IClass theClass = this.type.getTheClass();
if (theClass == null) {
return;
}
if (!theClass.isAnnotation()) {
markers.add(Markers.semanticError(this.position, "annotation.type", this.type.getName()));
return;
}
if (target == null) {
return;
}
final IClassMetadata metadata = theClass.getMetadata();
if (!metadata.isTarget(target)) {
final Marker error = Markers.semanticError(this.position, "annotation.target", this.type.getName());
error.addInfo(Markers.getSemantic("annotation.target.element", target));
error.addInfo(Markers.getSemantic("annotation.target.allowed", metadata.getTargets()));
markers.add(error);
}
}
Aggregations