Search in sources :

Example 1 with BLangConnector

use of org.wso2.ballerinalang.compiler.tree.BLangConnector in project ballerina by ballerina-lang.

the class Generator method createDocForNode.

/**
 * Create documentation for connectors.
 * @param connectorNode ballerina connector node.
 * @return documentation for connectors.
 */
public static ConnectorDoc createDocForNode(BLangConnector connectorNode) {
    String connectorName = connectorNode.getName().value;
    List<Variable> parameters = new ArrayList<>();
    List<Documentable> actions = new ArrayList<>();
    // Iterate through the connector parameters
    if (connectorNode.getParameters().size() > 0) {
        for (BLangVariable param : connectorNode.getParameters()) {
            String dataType = type(param);
            String desc = paramAnnotation(connectorNode, param);
            Variable variable = new Variable(param.getName().value, dataType, desc);
            parameters.add(variable);
        }
    }
    // Iterate through the actions of the connectors
    if (connectorNode.getActions().size() > 0) {
        for (BLangAction action : connectorNode.getActions()) {
            actions.add(createDocForNode(action));
        }
    }
    return new ConnectorDoc(connectorName, description(connectorNode), actions, parameters);
}
Also used : BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable) Variable(org.ballerinalang.docgen.model.Variable) Documentable(org.ballerinalang.docgen.model.Documentable) ArrayList(java.util.ArrayList) ConnectorDoc(org.ballerinalang.docgen.model.ConnectorDoc) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable) BLangAction(org.wso2.ballerinalang.compiler.tree.BLangAction)

Example 2 with BLangConnector

use of org.wso2.ballerinalang.compiler.tree.BLangConnector in project ballerina by ballerina-lang.

the class SignatureTreeVisitor method visit.

@Override
public void visit(BLangConnector connectorNode) {
    BSymbol connectorSymbol = connectorNode.symbol;
    SymbolEnv connectorEnv = SymbolEnv.createConnectorEnv(connectorNode, connectorSymbol.scope, symbolEnv);
    connectorNode.actions.forEach(action -> this.acceptNode(action, connectorEnv));
}
Also used : BSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol) SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)

Example 3 with BLangConnector

use of org.wso2.ballerinalang.compiler.tree.BLangConnector in project ballerina by ballerina-lang.

the class SymbolEnter method defineConnectorParams.

private void defineConnectorParams(List<BLangConnector> connectors, SymbolEnv pkgEnv) {
    connectors.forEach(connector -> {
        SymbolEnv conEnv = SymbolEnv.createConnectorEnv(connector, connector.symbol.scope, pkgEnv);
        defineConnectorSymbolParams(connector, connector.symbol, conEnv);
    });
}
Also used : SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)

Example 4 with BLangConnector

use of org.wso2.ballerinalang.compiler.tree.BLangConnector in project ballerina by ballerina-lang.

the class SymbolEnter method defineConnectorSymbolParams.

private void defineConnectorSymbolParams(BLangConnector connectorNode, BConnectorSymbol symbol, SymbolEnv connectorEnv) {
    List<BVarSymbol> paramSymbols = connectorNode.params.stream().peek(varNode -> defineNode(varNode, connectorEnv)).map(varNode -> varNode.symbol).collect(Collectors.toList());
    symbol.params = paramSymbols;
    // Create connector type
    List<BType> paramTypes = paramSymbols.stream().map(paramSym -> paramSym.type).collect(Collectors.toList());
    symbol.type = new BConnectorType(paramTypes, symbol);
}
Also used : BInvokableType(org.wso2.ballerinalang.compiler.semantics.model.types.BInvokableType) BLangReturn(org.wso2.ballerinalang.compiler.tree.statements.BLangReturn) BAttachedFunction(org.wso2.ballerinalang.compiler.semantics.model.symbols.BStructSymbol.BAttachedFunction) BLangIdentifier(org.wso2.ballerinalang.compiler.tree.BLangIdentifier) BConnectorType(org.wso2.ballerinalang.compiler.semantics.model.types.BConnectorType) BTypeSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BTypeSymbol) BVarSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol) BLangImportPackage(org.wso2.ballerinalang.compiler.tree.BLangImportPackage) Flag(org.ballerinalang.model.elements.Flag) IdentifierNode(org.ballerinalang.model.tree.IdentifierNode) TopLevelNode(org.ballerinalang.model.tree.TopLevelNode) BLangCompilationUnit(org.wso2.ballerinalang.compiler.tree.BLangCompilationUnit) BAnnotationSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BAnnotationSymbol) Names(org.wso2.ballerinalang.compiler.util.Names) BServiceSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BServiceSymbol) BEnumType(org.wso2.ballerinalang.compiler.semantics.model.types.BEnumType) EnumSet(java.util.EnumSet) BLangAssignment(org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment) BLangDiagnosticLog(org.wso2.ballerinalang.compiler.util.diagnotic.BLangDiagnosticLog) BLangSimpleVarRef(org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef) BXMLNSSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BXMLNSSymbol) BConnectorSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BConnectorSymbol) BStructType(org.wso2.ballerinalang.compiler.semantics.model.types.BStructType) BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression) CompilerPhase(org.ballerinalang.compiler.CompilerPhase) BXMLAttributeSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BXMLAttributeSymbol) BSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol) PackageID(org.ballerinalang.model.elements.PackageID) Set(java.util.Set) BPackageSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BPackageSymbol) BLangXMLNS(org.wso2.ballerinalang.compiler.tree.BLangXMLNS) BLangAnnotAttribute(org.wso2.ballerinalang.compiler.tree.BLangAnnotAttribute) Collectors(java.util.stream.Collectors) BLangTransformer(org.wso2.ballerinalang.compiler.tree.BLangTransformer) BLangNode(org.wso2.ballerinalang.compiler.tree.BLangNode) BLangService(org.wso2.ballerinalang.compiler.tree.BLangService) List(java.util.List) IMPORT(org.ballerinalang.model.tree.NodeKind.IMPORT) Scope(org.wso2.ballerinalang.compiler.semantics.model.Scope) BLangEnum(org.wso2.ballerinalang.compiler.tree.BLangEnum) NodeKind(org.ballerinalang.model.tree.NodeKind) BAnnotationAttributeSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BAnnotationAttributeSymbol) StatementNode(org.ballerinalang.model.tree.statements.StatementNode) BStructSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BStructSymbol) BLangWorker(org.wso2.ballerinalang.compiler.tree.BLangWorker) BLangEndpoint(org.wso2.ballerinalang.compiler.tree.BLangEndpoint) BLangXMLNSStatement(org.wso2.ballerinalang.compiler.tree.statements.BLangXMLNSStatement) BLangInvokableNode(org.wso2.ballerinalang.compiler.tree.BLangInvokableNode) BLangAction(org.wso2.ballerinalang.compiler.tree.BLangAction) BStructField(org.wso2.ballerinalang.compiler.semantics.model.types.BStructType.BStructField) BLangUserDefinedType(org.wso2.ballerinalang.compiler.tree.types.BLangUserDefinedType) BAnnotationType(org.wso2.ballerinalang.compiler.semantics.model.types.BAnnotationType) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable) BLangExpressionStmt(org.wso2.ballerinalang.compiler.tree.statements.BLangExpressionStmt) BLangAnnotation(org.wso2.ballerinalang.compiler.tree.BLangAnnotation) BLangXMLAttribute(org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLAttribute) BLangStatement(org.wso2.ballerinalang.compiler.tree.statements.BLangStatement) BLangNodeVisitor(org.wso2.ballerinalang.compiler.tree.BLangNodeVisitor) PackageLoader(org.wso2.ballerinalang.compiler.PackageLoader) TypeTags(org.wso2.ballerinalang.compiler.util.TypeTags) BServiceType(org.wso2.ballerinalang.compiler.semantics.model.types.BServiceType) Flags(org.wso2.ballerinalang.util.Flags) BLangResource(org.wso2.ballerinalang.compiler.tree.BLangResource) DocTag(org.ballerinalang.model.elements.DocTag) TreeBuilder(org.ballerinalang.model.TreeBuilder) BType(org.wso2.ballerinalang.compiler.semantics.model.types.BType) BInvokableSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol) DiagnosticPos(org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos) XMLConstants(javax.xml.XMLConstants) BLangPackage(org.wso2.ballerinalang.compiler.tree.BLangPackage) SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv) BTransformerSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BTransformerSymbol) BLangObject(org.wso2.ballerinalang.compiler.tree.BLangObject) BLangXMLQName(org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLQName) Symbols(org.wso2.ballerinalang.compiler.semantics.model.symbols.Symbols) BLangFunction(org.wso2.ballerinalang.compiler.tree.BLangFunction) Name(org.wso2.ballerinalang.compiler.util.Name) SymTag(org.wso2.ballerinalang.compiler.semantics.model.symbols.SymTag) DiagnosticCode(org.ballerinalang.util.diagnostic.DiagnosticCode) BLangLiteral(org.wso2.ballerinalang.compiler.tree.expressions.BLangLiteral) BLangEnumerator(org.wso2.ballerinalang.compiler.tree.BLangEnum.BLangEnumerator) BLangInvocation(org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation) BLangConnector(org.wso2.ballerinalang.compiler.tree.BLangConnector) BEndpointVarSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BEndpointVarSymbol) BLangStruct(org.wso2.ballerinalang.compiler.tree.BLangStruct) BLangBlockStmt(org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt) SymbolTable(org.wso2.ballerinalang.compiler.semantics.model.SymbolTable) CompilerContext(org.wso2.ballerinalang.compiler.util.CompilerContext) BType(org.wso2.ballerinalang.compiler.semantics.model.types.BType) BConnectorType(org.wso2.ballerinalang.compiler.semantics.model.types.BConnectorType) BVarSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol)

Example 5 with BLangConnector

use of org.wso2.ballerinalang.compiler.tree.BLangConnector in project ballerina by ballerina-lang.

the class TaintAnalyzer method visit.

public void visit(BLangConnector connectorNode) {
    BSymbol connectorSymbol = connectorNode.symbol;
    SymbolEnv connectorEnv = SymbolEnv.createConnectorEnv(connectorNode, connectorSymbol.scope, env);
    attachTaintTableBasedOnAnnotations(connectorNode);
    connectorNode.varDefs.forEach(var -> var.accept(this));
    analyzeNode(connectorNode.initFunction, connectorEnv);
    analyzeNode(connectorNode.initAction, connectorEnv);
    connectorNode.actions.forEach(action -> analyzeNode(action, connectorEnv));
}
Also used : BSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol) SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)

Aggregations

BLangConnector (org.wso2.ballerinalang.compiler.tree.BLangConnector)12 SymbolEnv (org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)11 BLangAction (org.wso2.ballerinalang.compiler.tree.BLangAction)11 BLangFunction (org.wso2.ballerinalang.compiler.tree.BLangFunction)10 BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)9 BLangEndpoint (org.wso2.ballerinalang.compiler.tree.BLangEndpoint)8 BSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol)7 BLangPackage (org.wso2.ballerinalang.compiler.tree.BLangPackage)7 BLangStruct (org.wso2.ballerinalang.compiler.tree.BLangStruct)7 ArrayList (java.util.ArrayList)6 List (java.util.List)5 BLangAnnotation (org.wso2.ballerinalang.compiler.tree.BLangAnnotation)5 BLangEnum (org.wso2.ballerinalang.compiler.tree.BLangEnum)5 BLangObject (org.wso2.ballerinalang.compiler.tree.BLangObject)5 BLangResource (org.wso2.ballerinalang.compiler.tree.BLangResource)5 BLangService (org.wso2.ballerinalang.compiler.tree.BLangService)5 BLangTransformer (org.wso2.ballerinalang.compiler.tree.BLangTransformer)5 BLangLiteral (org.wso2.ballerinalang.compiler.tree.expressions.BLangLiteral)5 DiagnosticPos (org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos)5 Collectors (java.util.stream.Collectors)4