Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ public Builder<T> imports(String importStatements) {
if (this.imports == null) {
this.imports = new HashMap<>();
}
String[] importList = importStatements.split(";");
String[] importList = importStatements.split(",");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this be sufficient? Do we have to remove the imports from each property?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have done that in setParameterProperties when adding to imports

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t understand why we’re sacrificing reusability to special-case the new connection builder. Why aren’t these changes applicable to action calls?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for (String importStatement : importList) {
if (importStatement.trim().isEmpty()) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@
import io.ballerina.compiler.api.SemanticModel;
import io.ballerina.compiler.syntax.tree.SyntaxKind;
import io.ballerina.flowmodelgenerator.core.model.Codedata;
import io.ballerina.flowmodelgenerator.core.model.FormBuilder;
import io.ballerina.flowmodelgenerator.core.model.NodeBuilder;
import io.ballerina.flowmodelgenerator.core.model.NodeKind;
import io.ballerina.flowmodelgenerator.core.model.Property;
import io.ballerina.flowmodelgenerator.core.model.SourceBuilder;
import io.ballerina.flowmodelgenerator.core.utils.FlowNodeUtil;
import io.ballerina.flowmodelgenerator.core.utils.ParamUtils;
import io.ballerina.modelgenerator.commons.CommonUtils;
import io.ballerina.modelgenerator.commons.FunctionData;
import io.ballerina.modelgenerator.commons.FunctionDataBuilder;
import io.ballerina.modelgenerator.commons.ModuleInfo;
import io.ballerina.modelgenerator.commons.PackageUtil;
import io.ballerina.modelgenerator.commons.ParameterData;
import io.ballerina.projects.Module;
import io.ballerina.projects.Project;
import org.ballerinalang.langserver.commons.workspace.WorkspaceManager;
Expand Down Expand Up @@ -180,6 +185,67 @@ public void setConcreteTemplateData(TemplateContext context) {
.checkError(true, CHECK_ERROR_DOC, false);
}

protected void setParameterProperties(FunctionData function) {
boolean hasOnlyRestParams = function.parameters().size() == 1;

for (ParameterData paramResult : function.parameters().values()) {
if (paramResult.kind() == ParameterData.Kind.PARAM_FOR_TYPE_INFER) {
buildInferredTypeProperty(this, paramResult, null);
continue;
}

if (paramResult.kind().equals(ParameterData.Kind.INCLUDED_RECORD)) {
continue;
}

String unescapedParamName = ParamUtils.removeLeadingSingleQuote(paramResult.name());
Property.Builder<FormBuilder<NodeBuilder>> customPropBuilder = properties().custom();
String label = paramResult.label();
customPropBuilder
.metadata()
.label(label == null || label.isEmpty() ? unescapedParamName : label)
.description(paramResult.description())
.stepOut()
.codedata()
.kind(paramResult.kind().name())
.originalName(paramResult.name())
.stepOut()
.placeholder(paramResult.placeholder())
.defaultValue(paramResult.defaultValue())
.typeConstraint(paramResult.type())
.typeMembers(paramResult.typeMembers())
.editable()
.defaultable(paramResult.optional());

switch (paramResult.kind()) {
case INCLUDED_RECORD_REST -> {
if (hasOnlyRestParams) {
customPropBuilder.defaultable(false);
}
unescapedParamName = "additionalValues";
customPropBuilder.type(Property.ValueType.MAPPING_EXPRESSION_SET);
}
case REST_PARAMETER -> {
if (hasOnlyRestParams) {
customPropBuilder.defaultable(false);
}
customPropBuilder.type(Property.ValueType.EXPRESSION_SET);
}
default -> {
if (paramResult.type() instanceof List<?>) {
customPropBuilder.type(Property.ValueType.SINGLE_SELECT);
} else {
customPropBuilder.type(Property.ValueType.EXPRESSION);
}
}
}

customPropBuilder
.stepOut()
.addProperty(FlowNodeUtil.getPropertyKey(unescapedParamName));
}
}

@Override
protected NodeKind getFunctionNodeKind() {
return NodeKind.NEW_CONNECTION;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@
"selected": false
}
],
"imports": {
"http": "ballerina/http"
},
"defaultValue": "{token: \"\"}"
},
"httpVersion": {
Expand Down Expand Up @@ -115,9 +112,6 @@
"selected": false
}
],
"imports": {
"http": "ballerina/http"
},
"defaultValue": "\"2.0\""
},
"http1Settings": {
Expand Down Expand Up @@ -172,9 +166,6 @@
"selected": false
}
],
"imports": {
"http": "ballerina/http"
},
"defaultValue": "{}"
},
"timeout": {
Expand Down Expand Up @@ -256,9 +247,6 @@
"selected": false
}
],
"imports": {
"http": "ballerina/http"
},
"defaultValue": "{}"
},
"cache": {
Expand Down Expand Up @@ -286,9 +274,6 @@
"selected": false
}
],
"imports": {
"http": "ballerina/http"
},
"defaultValue": "{}"
},
"compression": {
Expand Down Expand Up @@ -316,9 +301,6 @@
"selected": false
}
],
"imports": {
"http": "ballerina/http"
},
"defaultValue": "\"AUTO\""
},
"circuitBreaker": {
Expand Down Expand Up @@ -346,9 +328,6 @@
"selected": false
}
],
"imports": {
"http": "ballerina/http"
},
"defaultValue": "{}"
},
"retryConfig": {
Expand Down Expand Up @@ -376,9 +355,6 @@
"selected": false
}
],
"imports": {
"http": "ballerina/http"
},
"defaultValue": "{}"
},
"responseLimits": {
Expand Down Expand Up @@ -406,9 +382,6 @@
"selected": false
}
],
"imports": {
"http": "ballerina/http"
},
"defaultValue": "{}"
},
"secureSocket": {
Expand Down Expand Up @@ -436,9 +409,6 @@
"selected": false
}
],
"imports": {
"http": "ballerina/http"
},
"defaultValue": "{}"
},
"proxy": {
Expand Down Expand Up @@ -466,9 +436,6 @@
"selected": false
}
],
"imports": {
"http": "ballerina/http"
},
"defaultValue": "{}"
},
"validation": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,6 @@
"selected": false
}
],
"imports": {
"sql": "ballerina/sql"
},
"defaultValue": "()"
},
"type": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,6 @@
"selected": false
}
],
"imports": {
"sql": "ballerina/sql"
},
Comment on lines -259 to -261
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked the new connection form, and we are getting the following diagnostics when this is removed:

[Trace - 11:12:45 AM] Received response 'expressionEditor/diagnostics - (1599)' in 538ms.
Result: {
    "diagnostics": [
        {
            "range": {
                "start": {
                    "line": 24,
                    "character": 0
                },
                "end": {
                    "line": 24,
                    "character": 18
                }
            },
            "severity": 1,
            "code": "BCE2000",
            "message": "undefined module 'sql'"
        },
        {
            "range": {
                "start": {
                    "line": 24,
                    "character": 0
                },
                "end": {
                    "line": 24,
                    "character": 18
                }
            },
            "severity": 1,
            "code": "BCE2069",
            "message": "unknown type 'ConnectionPool'"
        }
    ]
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you getting this when adding the connectionPool argument to the connection initializer?

import ballerinax/mysql;
import ballerinax/mysql.driver as _;

final mysql:Client mysqlClient = check new (connectionPool = {
    maxOpenConnections: 0,
    maxConnectionLifeTime: 0.0d,
    minIdleConnections: 0
});

"defaultValue": "()"
},
"type": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,6 @@
"selected": false
}
],
"imports": {
"sql": "ballerina/sql"
},
"defaultValue": "()"
},
"type": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,6 @@
"selected": false
}
],
"imports": {
"sql": "ballerina/sql"
},
"defaultValue": "()"
},
"type": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,6 @@
"selected": false
}
],
"imports": {
"sql": "ballerina/sql"
},
"defaultValue": "()"
},
"type": {
Expand Down
Loading
Loading