Search in sources :

Example 6 with PACKAGE

use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.PACKAGE in project ballerina by ballerina-lang.

the class HtmlDocTest method testMultiPackage.

@Test(description = "Multiple packages should be shown even when one page is generated")
public void testMultiPackage() throws Exception {
    List<Link> packages = new ArrayList<>();
    packages.add(new Link(new PackageName("a.b.c", ""), "", false));
    packages.add(new Link(new PackageName("x.y", ""), "", false));
    packages.add(new Link(new PackageName("x.y.z", ""), "", false));
    BLangPackage bLangPackage = createPackage("package x.y;");
    Page page = Generator.generatePage(bLangPackage, packages);
    Assert.assertEquals(page.links.size(), 3);
    Assert.assertFalse(page.links.get(0).active);
    Assert.assertTrue(page.links.get(1).active);
}
Also used : BLangPackage(org.wso2.ballerinalang.compiler.tree.BLangPackage) PackageName(org.ballerinalang.docgen.model.PackageName) ArrayList(java.util.ArrayList) Page(org.ballerinalang.docgen.model.Page) Link(org.ballerinalang.docgen.model.Link) Test(org.testng.annotations.Test)

Example 7 with PACKAGE

use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.PACKAGE in project ballerina by ballerina-lang.

the class HtmlDocTest method testFunctionsWithoutStructBindings.

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

Example 8 with PACKAGE

use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.PACKAGE in project ballerina by ballerina-lang.

the class HtmlDocTest method testAnnotationPropertiesExtracted.

@Test(description = "Annotation properties should be available via construct", enabled = false)
public void testAnnotationPropertiesExtracted() throws Exception {
    BLangPackage bLangPackage = createPackage("package x.y; " + "@Description {value: \"AnnotationDoc to upgrade connection from HTTP to WS in the " + "same base path\"}\n" + "@Field {value:\"upgradePath:Upgrade path for the WebSocket service from " + "HTTP to WS\"}\n" + "@Field {value:\"serviceName:Name of the WebSocket service where the HTTP service should " + "               upgrade to\"}\n" + "public annotation webSocket attach service<> {\n" + "    string upgradePath;\n" + "    string serviceName;\n" + "}");
    AnnotationDoc annotationDoc = Generator.createDocForNode(bLangPackage.getAnnotations().get(0));
    Assert.assertEquals(annotationDoc.name, "webSocket", "Annotation name should be extracted");
    Assert.assertEquals(annotationDoc.description, "AnnotationDoc to upgrade connection from HTTP to WS " + "in the same base path", "Description of the annotation should be extracted");
    // Annotation Fields
    Assert.assertEquals(annotationDoc.attributes.get(0).name, "upgradePath", "Annotation attribute name " + "should be extracted");
    Assert.assertEquals(annotationDoc.attributes.get(0).dataType, "string", "Annotation attribute type " + "should be extracted");
    Assert.assertEquals(annotationDoc.attributes.get(0).description, "Upgrade path for the WebSocket service " + "from HTTP to WS", "Description of the annotation attribute should be extracted");
}
Also used : AnnotationDoc(org.ballerinalang.docgen.model.AnnotationDoc) BLangPackage(org.wso2.ballerinalang.compiler.tree.BLangPackage) Test(org.testng.annotations.Test)

Example 9 with PACKAGE

use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.PACKAGE 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 10 with PACKAGE

use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.PACKAGE 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)

Aggregations

BLangPackage (org.wso2.ballerinalang.compiler.tree.BLangPackage)49 ArrayList (java.util.ArrayList)34 Test (org.testng.annotations.Test)29 Page (org.ballerinalang.docgen.model.Page)18 File (java.io.File)16 CompilerContext (org.wso2.ballerinalang.compiler.util.CompilerContext)16 IOException (java.io.IOException)15 Path (java.nio.file.Path)13 List (java.util.List)13 BLangStruct (org.wso2.ballerinalang.compiler.tree.BLangStruct)11 PackageID (org.ballerinalang.model.elements.PackageID)10 Compiler (org.wso2.ballerinalang.compiler.Compiler)10 BLangFunction (org.wso2.ballerinalang.compiler.tree.BLangFunction)10 CompilerOptions (org.wso2.ballerinalang.compiler.util.CompilerOptions)10 Collectors (java.util.stream.Collectors)9 Arrays (java.util.Arrays)8 CompilerPhase (org.ballerinalang.compiler.CompilerPhase)7 BInvokableSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol)6 BPackageSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BPackageSymbol)6 BLangNode (org.wso2.ballerinalang.compiler.tree.BLangNode)6