Search in sources :

Example 1 with BLangImportPackage

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

the class PositionTreeVisitor method visit.

public void visit(BLangImportPackage importPkgNode) {
    BPackageSymbol pkgSymbol = importPkgNode.symbol;
    SymbolEnv pkgEnv = this.symTable.pkgEnvMap.get(pkgSymbol);
    acceptNode(pkgEnv.node);
}
Also used : BPackageSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BPackageSymbol) SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)

Example 2 with BLangImportPackage

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

the class SymbolEnter method createInitFuncInvocationStmt.

private BLangExpressionStmt createInitFuncInvocationStmt(BLangImportPackage importPackage, BInvokableSymbol initFunctionSymbol) {
    BLangInvocation invocationNode = (BLangInvocation) TreeBuilder.createInvocationNode();
    invocationNode.pos = importPackage.pos;
    invocationNode.addWS(importPackage.getWS());
    BLangIdentifier funcName = (BLangIdentifier) TreeBuilder.createIdentifierNode();
    funcName.value = initFunctionSymbol.name.value;
    invocationNode.name = funcName;
    invocationNode.pkgAlias = importPackage.alias;
    BLangExpressionStmt exprStmt = (BLangExpressionStmt) TreeBuilder.createExpressionStatementNode();
    exprStmt.pos = importPackage.pos;
    exprStmt.addWS(importPackage.getWS());
    exprStmt.expr = invocationNode;
    return exprStmt;
}
Also used : BLangIdentifier(org.wso2.ballerinalang.compiler.tree.BLangIdentifier) BLangInvocation(org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation) BLangExpressionStmt(org.wso2.ballerinalang.compiler.tree.statements.BLangExpressionStmt)

Example 3 with BLangImportPackage

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

the class TaintAnalyzer method visit.

public void visit(BLangImportPackage importPkgNode) {
    BPackageSymbol pkgSymbol = importPkgNode.symbol;
    SymbolEnv pkgEnv = symTable.pkgEnvMap.get(pkgSymbol);
    if (pkgEnv == null) {
        return;
    }
    this.env = pkgEnv;
    pkgEnv.node.accept(this);
}
Also used : BPackageSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BPackageSymbol) SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)

Example 4 with BLangImportPackage

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

the class SemanticAnalyzer method visit.

public void visit(BLangImportPackage importPkgNode) {
    BPackageSymbol pkgSymbol = importPkgNode.symbol;
    SymbolEnv pkgEnv = this.symTable.pkgEnvMap.get(pkgSymbol);
    if (pkgEnv == null) {
        return;
    }
    analyzeDef(pkgEnv.node, pkgEnv);
}
Also used : BPackageSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BPackageSymbol) SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)

Example 5 with BLangImportPackage

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

the class BLangPackageBuilder method addImportPackageDeclaration.

public void addImportPackageDeclaration(DiagnosticPos pos, Set<Whitespace> ws, String orgName, List<String> nameComps, String version, String alias) {
    List<BLangIdentifier> pkgNameComps = new ArrayList<>();
    nameComps.forEach(e -> pkgNameComps.add((BLangIdentifier) this.createIdentifier(e)));
    BLangIdentifier versionNode = (BLangIdentifier) this.createIdentifier(version);
    BLangIdentifier aliasNode = (alias != null && !alias.isEmpty()) ? (BLangIdentifier) this.createIdentifier(alias) : pkgNameComps.get(pkgNameComps.size() - 1);
    BLangImportPackage importDcl = (BLangImportPackage) TreeBuilder.createImportPackageNode();
    importDcl.pos = pos;
    importDcl.addWS(ws);
    importDcl.pkgNameComps = pkgNameComps;
    importDcl.version = versionNode;
    importDcl.orgName = (BLangIdentifier) this.createIdentifier(orgName);
    importDcl.alias = aliasNode;
    this.compUnit.addTopLevelNode(importDcl);
    if (this.imports.contains(importDcl)) {
        this.dlog.warning(pos, DiagnosticCode.REDECLARED_IMPORT_PACKAGE, importDcl.getQualifiedPackageName());
    } else {
        this.imports.add(importDcl);
    }
}
Also used : ArrayList(java.util.ArrayList) BLangImportPackage(org.wso2.ballerinalang.compiler.tree.BLangImportPackage) BLangIdentifier(org.wso2.ballerinalang.compiler.tree.BLangIdentifier)

Aggregations

BPackageSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BPackageSymbol)9 SymbolEnv (org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)8 BLangImportPackage (org.wso2.ballerinalang.compiler.tree.BLangImportPackage)5 BLangIdentifier (org.wso2.ballerinalang.compiler.tree.BLangIdentifier)4 ArrayList (java.util.ArrayList)3 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 IdentifierNode (org.ballerinalang.model.tree.IdentifierNode)2 TopLevelNode (org.ballerinalang.model.tree.TopLevelNode)2 BLangEnum (org.wso2.ballerinalang.compiler.tree.BLangEnum)2 BLangFunction (org.wso2.ballerinalang.compiler.tree.BLangFunction)2 BLangNode (org.wso2.ballerinalang.compiler.tree.BLangNode)2 BLangPackage (org.wso2.ballerinalang.compiler.tree.BLangPackage)2 BLangResource (org.wso2.ballerinalang.compiler.tree.BLangResource)2 BLangService (org.wso2.ballerinalang.compiler.tree.BLangService)2 BLangStruct (org.wso2.ballerinalang.compiler.tree.BLangStruct)2 BLangTransformer (org.wso2.ballerinalang.compiler.tree.BLangTransformer)2 Name (org.wso2.ballerinalang.compiler.util.Name)2 DiagnosticPos (org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos)2 LinkedTreeMap (com.google.gson.internal.LinkedTreeMap)1