Search in sources :

Example 1 with PackageLoader

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

the class BallerinaDocGenerator method getBuiltInPackage.

private static BLangPackage getBuiltInPackage(CompilerContext context) {
    PackageLoader pkgLoader = PackageLoader.getInstance(context);
    SemanticAnalyzer semAnalyzer = SemanticAnalyzer.getInstance(context);
    CodeAnalyzer codeAnalyzer = CodeAnalyzer.getInstance(context);
    return codeAnalyzer.analyze(semAnalyzer.analyze(pkgLoader.loadAndDefinePackage(Names.BUILTIN_ORG.getValue(), Names.BUILTIN_PACKAGE.getValue())));
}
Also used : CodeAnalyzer(org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer) PackageLoader(org.wso2.ballerinalang.compiler.PackageLoader) SemanticAnalyzer(org.wso2.ballerinalang.compiler.semantics.analyzer.SemanticAnalyzer)

Example 2 with PackageLoader

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

the class LSPackageLoader method getBuiltinPackages.

/**
 * Get the Builtin Package.
 * @return {@link BLangPackage} Builtin BLang package
 */
public static List<BLangPackage> getBuiltinPackages() {
    List<BLangPackage> builtins = new ArrayList<>();
    CompilerContext context = CommonUtil.prepareTempCompilerContext();
    PackageLoader pkgLoader = PackageLoader.getInstance(context);
    SemanticAnalyzer semAnalyzer = SemanticAnalyzer.getInstance(context);
    CodeAnalyzer codeAnalyzer = CodeAnalyzer.getInstance(context);
    BLangPackage builtInPkg = codeAnalyzer.analyze(semAnalyzer.analyze(pkgLoader.loadAndDefinePackage(Names.BUILTIN_ORG.value, Names.BUILTIN_PACKAGE.getValue())));
    builtins.add(builtInPkg);
    return builtins;
}
Also used : CodeAnalyzer(org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer) BLangPackage(org.wso2.ballerinalang.compiler.tree.BLangPackage) PackageLoader(org.wso2.ballerinalang.compiler.PackageLoader) CompilerContext(org.wso2.ballerinalang.compiler.util.CompilerContext) ArrayList(java.util.ArrayList) SemanticAnalyzer(org.wso2.ballerinalang.compiler.semantics.analyzer.SemanticAnalyzer)

Example 3 with PackageLoader

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

the class ParserUtils method loadBuiltInPackage.

/**
 * Loading builtin packages.
 *
 * @param context compiler context
 * @return {BLangPackage} builtIn package
 */
private static BLangPackage loadBuiltInPackage(CompilerContext context) {
    PackageLoader pkgLoader = PackageLoader.getInstance(context);
    SymbolTable symbolTable = SymbolTable.getInstance(context);
    SemanticAnalyzer semAnalyzer = SemanticAnalyzer.getInstance(context);
    CodeAnalyzer codeAnalyzer = CodeAnalyzer.getInstance(context);
    Desugar desugar = Desugar.getInstance(context);
    BLangPackage builtInPkg = desugar.perform(codeAnalyzer.analyze(semAnalyzer.analyze(pkgLoader.loadAndDefinePackage(Names.BUILTIN_ORG.getValue(), Names.BUILTIN_PACKAGE.getValue()))));
    symbolTable.builtInPackageSymbol = builtInPkg.symbol;
    return builtInPkg;
}
Also used : CodeAnalyzer(org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer) LSPackageLoader(org.ballerinalang.langserver.LSPackageLoader) PackageLoader(org.wso2.ballerinalang.compiler.PackageLoader) BLangPackage(org.wso2.ballerinalang.compiler.tree.BLangPackage) SymbolTable(org.wso2.ballerinalang.compiler.semantics.model.SymbolTable) Desugar(org.wso2.ballerinalang.compiler.desugar.Desugar) SemanticAnalyzer(org.wso2.ballerinalang.compiler.semantics.analyzer.SemanticAnalyzer)

Aggregations

PackageLoader (org.wso2.ballerinalang.compiler.PackageLoader)3 CodeAnalyzer (org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer)3 SemanticAnalyzer (org.wso2.ballerinalang.compiler.semantics.analyzer.SemanticAnalyzer)3 BLangPackage (org.wso2.ballerinalang.compiler.tree.BLangPackage)2 ArrayList (java.util.ArrayList)1 LSPackageLoader (org.ballerinalang.langserver.LSPackageLoader)1 Desugar (org.wso2.ballerinalang.compiler.desugar.Desugar)1 SymbolTable (org.wso2.ballerinalang.compiler.semantics.model.SymbolTable)1 CompilerContext (org.wso2.ballerinalang.compiler.util.CompilerContext)1