Search in sources :

Example 1 with Connector

use of org.ballerinalang.composer.service.ballerina.parser.service.model.lang.Connector in project ballerina by ballerina-lang.

the class ParserUtils method removeConstructsOfFile.

/**
 * Remove constructs from given file in given package from given package map.
 *
 * @param pkgName    Name of the package
 * @param fileName   Name of the File
 * @param packageMap Package constructs map
 */
public static void removeConstructsOfFile(String pkgName, String fileName, Map<String, ModelPackage> packageMap) {
    ModelPackage newPkg = new ModelPackage();
    newPkg.setName(pkgName);
    if (packageMap.containsKey(pkgName)) {
        ModelPackage currentPkg = packageMap.get(pkgName);
        currentPkg.getFunctions().forEach((Function func) -> {
            if (!func.getFileName().equals(fileName)) {
                newPkg.addFunctionsItem(func);
            }
        });
        currentPkg.getStructs().forEach((Struct struct) -> {
            if (!struct.getFileName().equals(fileName)) {
                newPkg.addStructsItem(struct);
            }
        });
        currentPkg.getAnnotations().forEach((AnnotationDef annotation) -> {
            if (!annotation.getFileName().equals(fileName)) {
                newPkg.addAnnotationsItem(annotation);
            }
        });
        currentPkg.getConnectors().forEach((Connector connector) -> {
            if (!connector.getFileName().equals(fileName)) {
                newPkg.addConnectorsItem(connector);
            }
        });
        packageMap.remove(pkgName);
        packageMap.put(pkgName, newPkg);
    }
}
Also used : Function(org.ballerinalang.composer.service.ballerina.parser.service.model.lang.Function) BLangFunction(org.wso2.ballerinalang.compiler.tree.BLangFunction) Connector(org.ballerinalang.composer.service.ballerina.parser.service.model.lang.Connector) BLangConnector(org.wso2.ballerinalang.compiler.tree.BLangConnector) ModelPackage(org.ballerinalang.composer.service.ballerina.parser.service.model.lang.ModelPackage) Struct(org.ballerinalang.composer.service.ballerina.parser.service.model.lang.Struct) BLangStruct(org.wso2.ballerinalang.compiler.tree.BLangStruct) AnnotationDef(org.ballerinalang.composer.service.ballerina.parser.service.model.lang.AnnotationDef)

Example 2 with Connector

use of org.ballerinalang.composer.service.ballerina.parser.service.model.lang.Connector in project ballerina by ballerina-lang.

the class ParserUtils method createNewConnector.

/**
 * Create new connector.
 *
 * @param name         name of the connector
 * @param annotations  list of annotation
 * @param actions      list of actions
 * @param params       list of params
 * @param returnParams list of return params
 * @return {Connector} connector
 */
private static Connector createNewConnector(String name, List<AnnotationAttachment> annotations, List<Action> actions, List<Parameter> params, List<Parameter> returnParams, String fileName) {
    Connector connector = new Connector();
    connector.setName(name);
    connector.setActions(actions);
    connector.setParameters(params);
    connector.setAnnotations(annotations);
    connector.setReturnParameters(returnParams);
    connector.setFileName(fileName);
    return connector;
}
Also used : Connector(org.ballerinalang.composer.service.ballerina.parser.service.model.lang.Connector) BLangConnector(org.wso2.ballerinalang.compiler.tree.BLangConnector)

Aggregations

Connector (org.ballerinalang.composer.service.ballerina.parser.service.model.lang.Connector)2 BLangConnector (org.wso2.ballerinalang.compiler.tree.BLangConnector)2 AnnotationDef (org.ballerinalang.composer.service.ballerina.parser.service.model.lang.AnnotationDef)1 Function (org.ballerinalang.composer.service.ballerina.parser.service.model.lang.Function)1 ModelPackage (org.ballerinalang.composer.service.ballerina.parser.service.model.lang.ModelPackage)1 Struct (org.ballerinalang.composer.service.ballerina.parser.service.model.lang.Struct)1 BLangFunction (org.wso2.ballerinalang.compiler.tree.BLangFunction)1 BLangStruct (org.wso2.ballerinalang.compiler.tree.BLangStruct)1