Search in sources :

Example 1 with SupportedAnnotationPackages

use of org.ballerinalang.compiler.plugins.SupportedAnnotationPackages in project ballerina by ballerina-lang.

the class CompilerPluginRunner method handleAnnotationProcesses.

private void handleAnnotationProcesses(CompilerPlugin plugin) {
    // Get the list of packages of annotations that this particular compiler plugin is interested in.
    SupportedAnnotationPackages supportedAnnotationPackages = plugin.getClass().getAnnotation(SupportedAnnotationPackages.class);
    if (supportedAnnotationPackages == null) {
        return;
    }
    String[] annotationPkgs = supportedAnnotationPackages.value();
    if (annotationPkgs.length == 0) {
        return;
    }
    for (String annPackage : annotationPkgs) {
        // Check whether each annotation type definition is available in the AST.
        List<BAnnotationSymbol> annotationSymbols = getAnnotationSymbols(annPackage);
        annotationSymbols.forEach(annSymbol -> {
            DefinitionID definitionID = new DefinitionID(annSymbol.pkgID.name.value, annSymbol.name.value);
            List<CompilerPlugin> processorList = processorMap.computeIfAbsent(definitionID, k -> new ArrayList<>());
            processorList.add(plugin);
        });
    }
}
Also used : CompilerPlugin(org.ballerinalang.compiler.plugins.CompilerPlugin) SupportedAnnotationPackages(org.ballerinalang.compiler.plugins.SupportedAnnotationPackages) BAnnotationSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BAnnotationSymbol)

Aggregations

CompilerPlugin (org.ballerinalang.compiler.plugins.CompilerPlugin)1 SupportedAnnotationPackages (org.ballerinalang.compiler.plugins.SupportedAnnotationPackages)1 BAnnotationSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BAnnotationSymbol)1