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);
});
}
}
Aggregations