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");
}
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");
}
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");
}
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");
}
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;
}
Aggregations