Search in sources :

Example 1 with SupportEndpointTypes

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

the class CompilerPluginRunner method handleEndpointProcesses.

private void handleEndpointProcesses(CompilerPlugin plugin) {
    // Get the list of endpoint of that this particular compiler plugin is interested in.
    SupportEndpointTypes supportEndpointTypes = plugin.getClass().getAnnotation(SupportEndpointTypes.class);
    if (supportEndpointTypes == null) {
        return;
    }
    final SupportEndpointTypes.EndpointType[] endpointTypes = supportEndpointTypes.value();
    if (endpointTypes.length == 0) {
        return;
    }
    DefinitionID[] definitions = Arrays.stream(endpointTypes).map(endpointType -> new DefinitionID(endpointType.packageName(), endpointType.name())).toArray(DefinitionID[]::new);
    for (DefinitionID definitionID : definitions) {
        if (isValidEndpoints(definitionID, plugin)) {
            List<CompilerPlugin> processorList = endpointProcessorMap.computeIfAbsent(definitionID, k -> new ArrayList<>());
            processorList.add(plugin);
        }
    }
}
Also used : Arrays(java.util.Arrays) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable) BLangAnnotation(org.wso2.ballerinalang.compiler.tree.BLangAnnotation) CompilerPlugin(org.ballerinalang.compiler.plugins.CompilerPlugin) HashMap(java.util.HashMap) BLangNodeVisitor(org.wso2.ballerinalang.compiler.tree.BLangNodeVisitor) ArrayList(java.util.ArrayList) SupportEndpointTypes(org.ballerinalang.compiler.plugins.SupportEndpointTypes) SupportedAnnotationPackages(org.ballerinalang.compiler.plugins.SupportedAnnotationPackages) BLangImportPackage(org.wso2.ballerinalang.compiler.tree.BLangImportPackage) BLangResource(org.wso2.ballerinalang.compiler.tree.BLangResource) PackageCache(org.wso2.ballerinalang.compiler.PackageCache) Map(java.util.Map) BiConsumer(java.util.function.BiConsumer) BAnnotationSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BAnnotationSymbol) BType(org.wso2.ballerinalang.compiler.semantics.model.types.BType) Names(org.wso2.ballerinalang.compiler.util.Names) DiagnosticPos(org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos) BLangPackage(org.wso2.ballerinalang.compiler.tree.BLangPackage) BLangDiagnosticLog(org.wso2.ballerinalang.compiler.util.diagnotic.BLangDiagnosticLog) SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv) CompilerPhase(org.ballerinalang.compiler.CompilerPhase) BLangObject(org.wso2.ballerinalang.compiler.tree.BLangObject) BLangForever(org.wso2.ballerinalang.compiler.tree.statements.BLangForever) BSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol) PackageID(org.ballerinalang.model.elements.PackageID) BPackageSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BPackageSymbol) ServiceLoader(java.util.ServiceLoader) BLangFunction(org.wso2.ballerinalang.compiler.tree.BLangFunction) BLangXMLNS(org.wso2.ballerinalang.compiler.tree.BLangXMLNS) BLangAnnotationAttachment(org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachment) BLangTransformer(org.wso2.ballerinalang.compiler.tree.BLangTransformer) AnnotationAttachmentNode(org.ballerinalang.model.tree.AnnotationAttachmentNode) SymTag(org.wso2.ballerinalang.compiler.semantics.model.symbols.SymTag) BLangNode(org.wso2.ballerinalang.compiler.tree.BLangNode) BLangService(org.wso2.ballerinalang.compiler.tree.BLangService) Objects(java.util.Objects) List(java.util.List) BLangEnum(org.wso2.ballerinalang.compiler.tree.BLangEnum) BLangPackageDeclaration(org.wso2.ballerinalang.compiler.tree.BLangPackageDeclaration) BLangConnector(org.wso2.ballerinalang.compiler.tree.BLangConnector) BLangEndpoint(org.wso2.ballerinalang.compiler.tree.BLangEndpoint) BLangStruct(org.wso2.ballerinalang.compiler.tree.BLangStruct) Collections(java.util.Collections) BLangAction(org.wso2.ballerinalang.compiler.tree.BLangAction) SymbolTable(org.wso2.ballerinalang.compiler.semantics.model.SymbolTable) CompilerContext(org.wso2.ballerinalang.compiler.util.CompilerContext) CompilerPlugin(org.ballerinalang.compiler.plugins.CompilerPlugin) SupportEndpointTypes(org.ballerinalang.compiler.plugins.SupportEndpointTypes)

Aggregations

ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 ServiceLoader (java.util.ServiceLoader)1 BiConsumer (java.util.function.BiConsumer)1 CompilerPhase (org.ballerinalang.compiler.CompilerPhase)1 CompilerPlugin (org.ballerinalang.compiler.plugins.CompilerPlugin)1 SupportEndpointTypes (org.ballerinalang.compiler.plugins.SupportEndpointTypes)1 SupportedAnnotationPackages (org.ballerinalang.compiler.plugins.SupportedAnnotationPackages)1 PackageID (org.ballerinalang.model.elements.PackageID)1 AnnotationAttachmentNode (org.ballerinalang.model.tree.AnnotationAttachmentNode)1 PackageCache (org.wso2.ballerinalang.compiler.PackageCache)1 SymbolEnv (org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)1 SymbolTable (org.wso2.ballerinalang.compiler.semantics.model.SymbolTable)1 BAnnotationSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BAnnotationSymbol)1 BPackageSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BPackageSymbol)1