Search in sources :

Example 1 with BLangDeprecatedNode

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

the class BLangPackageBuilder method createDeprecatedNode.

public void createDeprecatedNode(DiagnosticPos pos, Set<Whitespace> ws, String content) {
    BLangDeprecatedNode deprecatedNode = (BLangDeprecatedNode) TreeBuilder.createDeprecatedNode();
    deprecatedNode.pos = pos;
    deprecatedNode.addWS(ws);
    deprecatedNode.documentationText = content;
    deprecatedAttachmentStack.push(deprecatedNode);
}
Also used : BLangDeprecatedNode(org.wso2.ballerinalang.compiler.tree.BLangDeprecatedNode)

Example 2 with BLangDeprecatedNode

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

the class DocumentationTest method testDeprecatedTransformer.

@Test(description = "Test doc deprecated Transformer.")
public void testDeprecatedTransformer() {
    CompileResult compileResult = BCompileUtil.compile("test-src/documentation/deprecated_transformer.bal");
    Assert.assertEquals(0, compileResult.getWarnCount());
    PackageNode packageNode = compileResult.getAST();
    List<BLangDeprecatedNode> dNodes = ((BLangTransformer) packageNode.getTransformers().get(0)).deprecatedAttachments;
    BLangDeprecatedNode dNode = dNodes.get(0);
    Assert.assertNotNull(dNode);
    Assert.assertEquals(dNode.documentationText, "\n" + "  This Transformer is deprecated use\n" + "  `transformer <Person p, Employee e> Bar(any defaultAddress) { e.name = p.firstName; }\n" + "  ` instead.\n");
    List<BLangDocumentation> docNodes = ((BLangTransformer) packageNode.getTransformers().get(0)).docAttachments;
    BLangDocumentation docNode = docNodes.get(0);
    Assert.assertNotNull(docNode);
    Assert.assertEquals(docNode.documentationText, "\n Transformer Foo Person -> Employee\n ");
    Assert.assertEquals(docNode.getAttributes().size(), 3);
    Assert.assertEquals(docNode.getAttributes().get(0).documentationField.getValue(), "p");
    Assert.assertEquals(docNode.getAttributes().get(0).documentationText, " input struct Person source used for transformation\n ");
    Assert.assertEquals(docNode.getAttributes().get(1).documentationField.getValue(), "e");
    Assert.assertEquals(docNode.getAttributes().get(1).documentationText, " output struct Employee struct which Person transformed to\n ");
    Assert.assertEquals(docNode.getAttributes().get(2).documentationField.getValue(), "defaultAddress");
    Assert.assertEquals(docNode.getAttributes().get(2).documentationText, " address which serves Eg: `POSTCODE 112`\n");
}
Also used : BLangTransformer(org.wso2.ballerinalang.compiler.tree.BLangTransformer) BLangDocumentation(org.wso2.ballerinalang.compiler.tree.BLangDocumentation) CompileResult(org.ballerinalang.launcher.util.CompileResult) BLangDeprecatedNode(org.wso2.ballerinalang.compiler.tree.BLangDeprecatedNode) PackageNode(org.ballerinalang.model.tree.PackageNode) Test(org.testng.annotations.Test)

Example 3 with BLangDeprecatedNode

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

the class DocumentationTest method testDeprecated.

@Test(description = "Test doc deprecated.", enabled = false)
public void testDeprecated() {
    CompileResult compileResult = BCompileUtil.compile("test-src/documentation/deprecated.bal");
    Assert.assertEquals(compileResult.getWarnCount(), 0);
    PackageNode packageNode = compileResult.getAST();
    List<BLangDeprecatedNode> dNodes = ((BLangFunction) packageNode.getFunctions().get(0)).deprecatedAttachments;
    BLangDeprecatedNode dNode = dNodes.get(0);
    Assert.assertNotNull(dNode);
    Assert.assertEquals(dNode.documentationText, "\n" + "  This function is deprecated use `openFile(string accessMode){}` instead.\n");
    dNodes = ((BLangStruct) packageNode.getStructs().get(0)).deprecatedAttachments;
    dNode = dNodes.get(0);
    Assert.assertNotNull(dNode);
    Assert.assertEquals(dNode.documentationText, "\n" + "  This Struct is deprecated use `File2` instead.\n");
    dNodes = ((BLangEnum) packageNode.getEnums().get(0)).deprecatedAttachments;
    dNode = dNodes.get(0);
    Assert.assertNotNull(dNode);
    Assert.assertEquals(dNode.documentationText, "\n" + "  This Enum is deprecated use `Enum2` instead.\n");
    dNodes = ((BLangEnum) packageNode.getEnums().get(0)).deprecatedAttachments;
    dNode = dNodes.get(0);
    Assert.assertNotNull(dNode);
    Assert.assertEquals(dNode.documentationText, "\n" + "  This Enum is deprecated use `Enum2` instead.\n");
    dNodes = ((BLangVariable) packageNode.getGlobalVariables().get(0)).deprecatedAttachments;
    dNode = dNodes.get(0);
    Assert.assertNotNull(dNode);
    Assert.assertEquals(dNode.documentationText, "use ```const string testConst = " + "\"TestConstantDocumentation\";``` instead");
    dNodes = ((BLangConnector) packageNode.getConnectors().get(0)).deprecatedAttachments;
    dNode = dNodes.get(0);
    Assert.assertNotNull(dNode);
    Assert.assertEquals(dNode.documentationText, "\n" + "  This Connector is deprecated use `Connector(string url2){}` instead.\n");
    dNodes = ((BLangConnector) packageNode.getConnectors().get(0)).getActions().get(0).deprecatedAttachments;
    dNode = dNodes.get(0);
    Assert.assertNotNull(dNode);
    Assert.assertEquals(dNode.documentationText, "\n" + "      This action is deprecated use `Connector.test(string url2){}` instead.\n" + "    ");
    dNodes = ((BLangService) packageNode.getServices().get(0)).deprecatedAttachments;
    dNode = dNodes.get(0);
    Assert.assertNotNull(dNode);
    Assert.assertEquals(dNode.documentationText, "\n" + "  This Service is deprecated use `PizzaHutService{}` instead.\n");
    dNodes = ((BLangService) packageNode.getServices().get(0)).getResources().get(0).deprecatedAttachments;
    dNode = dNodes.get(0);
    Assert.assertNotNull(dNode);
    Assert.assertEquals(dNode.documentationText, "This Resource is deprecated use `PizzaHutService.orderFromPizza()` instead.");
}
Also used : BLangFunction(org.wso2.ballerinalang.compiler.tree.BLangFunction) CompileResult(org.ballerinalang.launcher.util.CompileResult) BLangDeprecatedNode(org.wso2.ballerinalang.compiler.tree.BLangDeprecatedNode) PackageNode(org.ballerinalang.model.tree.PackageNode) Test(org.testng.annotations.Test)

Example 4 with BLangDeprecatedNode

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

the class DocumentationTest method testNestedInlineDeprecated.

@Test(description = "Test doc nested inline inside deprecated tag.")
public void testNestedInlineDeprecated() {
    CompileResult compileResult = BCompileUtil.compile("test-src/documentation/nested_inline_deprecated.bal");
    Assert.assertEquals(0, compileResult.getWarnCount());
    PackageNode packageNode = compileResult.getAST();
    BLangVariable constant = (BLangVariable) packageNode.getGlobalVariables().get(0);
    List<BLangDeprecatedNode> docNodes = constant.deprecatedAttachments;
    BLangDeprecatedNode dNode = docNodes.get(0);
    Assert.assertNotNull(dNode);
    Assert.assertEquals(dNode.documentationText, "\n" + "  Example of a string templates:\n" + "  ``` This starts ends triple backtick  ``string s = string `hello {{name}}`;`` " + "ends triple backtick```\n" + "\n" + "  Example for an xml literal:\n" + "    ``xml x = xml `<{{tagName}}>hello</{{tagName}}>`;``\n");
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) BLangDeprecatedNode(org.wso2.ballerinalang.compiler.tree.BLangDeprecatedNode) PackageNode(org.ballerinalang.model.tree.PackageNode) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable) Test(org.testng.annotations.Test)

Aggregations

BLangDeprecatedNode (org.wso2.ballerinalang.compiler.tree.BLangDeprecatedNode)4 CompileResult (org.ballerinalang.launcher.util.CompileResult)3 PackageNode (org.ballerinalang.model.tree.PackageNode)3 Test (org.testng.annotations.Test)3 BLangDocumentation (org.wso2.ballerinalang.compiler.tree.BLangDocumentation)1 BLangFunction (org.wso2.ballerinalang.compiler.tree.BLangFunction)1 BLangTransformer (org.wso2.ballerinalang.compiler.tree.BLangTransformer)1 BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)1