use of org.ballerinalang.composer.service.ballerina.parser.service.model.lang.Function in project ballerina by ballerina-lang.
the class ParserUtils method createNewFunction.
/**
* Create new function.
*
* @param name name of the function
* @param annotations list of annotations
* @param params list of parameters
* @param returnParams list of return params
* @return {Function} function
*/
private static Function createNewFunction(String name, List<AnnotationAttachment> annotations, List<Parameter> params, List<Parameter> returnParams, String receiverType, boolean isPublic, String fileName) {
Function function = new Function();
function.setName(name);
function.setAnnotations(annotations);
function.setParameters(params);
function.setReturnParams(returnParams);
function.setReceiverType(receiverType);
function.setPublic(isPublic);
function.setFileName(fileName);
return function;
}
use of org.ballerinalang.composer.service.ballerina.parser.service.model.lang.Function 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);
}
}
Aggregations