Search in sources :

Example 1 with IClassMetadata

use of dyvilx.tools.compiler.ast.classes.metadata.IClassMetadata 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);
    }
}
Also used : IClassMetadata(dyvilx.tools.compiler.ast.classes.metadata.IClassMetadata) IClass(dyvilx.tools.compiler.ast.classes.IClass) Marker(dyvilx.tools.parsing.marker.Marker)

Aggregations

IClass (dyvilx.tools.compiler.ast.classes.IClass)1 IClassMetadata (dyvilx.tools.compiler.ast.classes.metadata.IClassMetadata)1 Marker (dyvilx.tools.parsing.marker.Marker)1