Search in sources :

Example 11 with BLangPackage

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

the class HtmlDocTest method testFunctionsWithStructBindings.

@Test(description = "One function with a struct bindings in a package should be grouped together shown in the " + "constructs")
public void testFunctionsWithStructBindings() throws Exception {
    BLangPackage bLangPackage = createPackage("package x.y; " + "public function <Message m>hello(){} " + "public struct Message { string message; int id;}");
    Page page = generatePage(bLangPackage);
    Assert.assertEquals(page.constructs.size(), 1);
    Assert.assertEquals(page.constructs.get(0).name, "Message");
    Assert.assertEquals(page.constructs.get(0).children.get(0).name, "hello");
}
Also used : BLangPackage(org.wso2.ballerinalang.compiler.tree.BLangPackage) Page(org.ballerinalang.docgen.model.Page) Test(org.testng.annotations.Test)

Example 12 with BLangPackage

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

the class HtmlDocTest method testConnectors.

@Test(description = "Connectors in a package should be shown in the constructs", enabled = false)
public void testConnectors() throws Exception {
    BLangPackage bLangPackage = createPackage("package x.y; " + "public connector HttpClient (string uri, int n){}" + "public connector Http2Client (string uri, int n){}");
    Page page = generatePage(bLangPackage);
    Assert.assertEquals(page.constructs.size(), 2);
    Assert.assertEquals(page.constructs.get(0).name, "HttpClient");
    Assert.assertEquals(page.constructs.get(1).name, "Http2Client");
}
Also used : BLangPackage(org.wso2.ballerinalang.compiler.tree.BLangPackage) Page(org.ballerinalang.docgen.model.Page) Test(org.testng.annotations.Test)

Example 13 with BLangPackage

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

the class HtmlDocTest method testStructs.

@Test(description = "Structs in a package should be shown in the constructs")
public void testStructs() throws Exception {
    BLangPackage bLangPackage = createPackage("package x.y; public struct Message {}");
    Page page = generatePage(bLangPackage);
    Assert.assertEquals(page.constructs.size(), 1);
    Assert.assertEquals(page.constructs.get(0).name, "Message");
}
Also used : BLangPackage(org.wso2.ballerinalang.compiler.tree.BLangPackage) Page(org.ballerinalang.docgen.model.Page) Test(org.testng.annotations.Test)

Example 14 with BLangPackage

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

the class HtmlDocTest method testEnums.

@Test(description = "Enums in a package should be shown in the constructs")
public void testEnums() throws Exception {
    BLangPackage bLangPackage = createPackage("package x.y; " + "public enum Direction {IN,OUT}" + "public enum Money {USD,LKR}");
    Page page = generatePage(bLangPackage);
    Assert.assertEquals(page.constructs.size(), 2);
    Assert.assertEquals(page.constructs.get(0).name, "Direction");
    Assert.assertTrue(page.constructs.get(0) instanceof EnumDoc, "Invalid documentable type.");
    Assert.assertEquals(((EnumDoc) page.constructs.get(0)).enumerators.get(0).toString(), "IN", "Invalid enum val");
    Assert.assertEquals(((EnumDoc) page.constructs.get(0)).enumerators.get(1).toString(), "OUT", "Invalid enum val");
    Assert.assertEquals(page.constructs.get(1).name, "Money");
}
Also used : EnumDoc(org.ballerinalang.docgen.model.EnumDoc) BLangPackage(org.wso2.ballerinalang.compiler.tree.BLangPackage) Page(org.ballerinalang.docgen.model.Page) Test(org.testng.annotations.Test)

Example 15 with BLangPackage

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

the class WorkspaceUtils method getBallerinaPackage.

private static BLangPackage getBallerinaPackage(String fileName, CompilerContext context) {
    Compiler compiler = Compiler.getInstance(context);
    BLangPackage balPkg = null;
    try {
        balPkg = compiler.compile(fileName);
    } catch (Exception ex) {
        BDiagnostic catastrophic = new BDiagnostic();
        catastrophic.msg = "Failed in the runtime parse/analyze. " + ex.getMessage();
    }
    return balPkg;
}
Also used : Compiler(org.wso2.ballerinalang.compiler.Compiler) BLangPackage(org.wso2.ballerinalang.compiler.tree.BLangPackage) BDiagnostic(org.wso2.ballerinalang.compiler.util.diagnotic.BDiagnostic)

Aggregations

BLangPackage (org.wso2.ballerinalang.compiler.tree.BLangPackage)78 Test (org.testng.annotations.Test)29 ArrayList (java.util.ArrayList)28 CompilerContext (org.wso2.ballerinalang.compiler.util.CompilerContext)19 Page (org.ballerinalang.docgen.model.Page)18 BLangFunction (org.wso2.ballerinalang.compiler.tree.BLangFunction)16 SymbolEnv (org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)15 DiagnosticPos (org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos)15 BLangNode (org.wso2.ballerinalang.compiler.tree.BLangNode)14 IOException (java.io.IOException)13 List (java.util.List)13 Path (java.nio.file.Path)12 Compiler (org.wso2.ballerinalang.compiler.Compiler)12 BLangStruct (org.wso2.ballerinalang.compiler.tree.BLangStruct)12 BLangService (org.wso2.ballerinalang.compiler.tree.BLangService)11 TopLevelNode (org.ballerinalang.model.tree.TopLevelNode)10 BLangConnector (org.wso2.ballerinalang.compiler.tree.BLangConnector)10 BPackageSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BPackageSymbol)9 BLangAction (org.wso2.ballerinalang.compiler.tree.BLangAction)9 BLangEnum (org.wso2.ballerinalang.compiler.tree.BLangEnum)9