From dd7d097c366db837cd5d777965761f67117ee6a3 Mon Sep 17 00:00:00 2001 From: Nipuna Fernando Date: Thu, 27 Feb 2025 00:01:56 +0530 Subject: [PATCH 1/5] Introduce property into the expression editor context --- .../ExpressionEditorContext.java | 161 ++++++--- .../services/DiagnosticsRequest.java | 2 +- .../ExpressionEditorCompletionTest.java | 2 +- .../ExpressionEditorDiagnosticsTest.java | 6 +- .../extension/FunctionCallTemplateTest.java | 2 +- .../extension/ImportModuleTest.java | 2 +- .../diagnostics/config/action_call1.json | 141 ++------ .../diagnostics/config/function_call1.json | 89 +---- .../diagnostics/config/function_call2.json | 84 +---- .../diagnostics/config/function_call3.json | 64 +--- .../diagnostics/config/identifiers1.json | 79 ++--- .../diagnostics/config/new_connection1.json | 135 +------ .../diagnostics/config/new_connection2.json | 333 ++---------------- .../diagnostics/config/new_connection3.json | 333 ++---------------- .../diagnostics/config/new_connection4.json | 193 ++-------- .../diagnostics/config/new_connection5.json | 192 ++-------- .../resources/diagnostics/config/single1.json | 120 ++----- .../resources/diagnostics/config/single2.json | 120 ++----- .../resources/diagnostics/config/single3.json | 120 ++----- .../resources/diagnostics/config/single4.json | 120 ++----- .../resources/diagnostics/config/single5.json | 120 ++----- .../resources/diagnostics/config/types1.json | 80 ++--- .../resources/diagnostics/config/types2.json | 80 ++--- .../resources/diagnostics/config/types3.json | 155 ++------ .../resources/diagnostics/config/types4.json | 155 ++------ .../resources/diagnostics/config/types5.json | 155 ++------ .../resources/diagnostics/config/types6.json | 82 ++--- .../resources/diagnostics/config/types7.json | 82 ++--- .../resources/diagnostics/config/types8.json | 82 ++--- .../resources/diagnostics/config/types9.json | 82 ++--- .../diagnostics/config/variable1.json | 79 ++--- .../diagnostics/config/variable2.json | 59 +--- 32 files changed, 744 insertions(+), 2765 deletions(-) diff --git a/flow-model-generator/modules/flow-model-generator-core/src/main/java/io/ballerina/flowmodelgenerator/core/expressioneditor/ExpressionEditorContext.java b/flow-model-generator/modules/flow-model-generator-core/src/main/java/io/ballerina/flowmodelgenerator/core/expressioneditor/ExpressionEditorContext.java index 0bff291cb..1773aa229 100644 --- a/flow-model-generator/modules/flow-model-generator-core/src/main/java/io/ballerina/flowmodelgenerator/core/expressioneditor/ExpressionEditorContext.java +++ b/flow-model-generator/modules/flow-model-generator-core/src/main/java/io/ballerina/flowmodelgenerator/core/expressioneditor/ExpressionEditorContext.java @@ -24,9 +24,7 @@ import io.ballerina.compiler.syntax.tree.ModulePartNode; import io.ballerina.compiler.syntax.tree.SyntaxKind; import io.ballerina.compiler.syntax.tree.SyntaxTree; -import io.ballerina.flowmodelgenerator.core.model.FlowNode; import io.ballerina.flowmodelgenerator.core.model.NodeKind; -import io.ballerina.flowmodelgenerator.core.model.Property; import io.ballerina.flowmodelgenerator.core.model.SourceBuilder; import io.ballerina.modelgenerator.commons.CommonUtils; import io.ballerina.projects.Document; @@ -60,15 +58,13 @@ public class ExpressionEditorContext { private final WorkspaceManagerProxy workspaceManagerProxy; private final String fileUri; private final Info info; - private final FlowNode flowNode; private final Path filePath; private final DocumentContext documentContext; + private final Property property; // State variables private int expressionOffset; private LineRange statementLineRange; - private Property property; - private boolean propertyInitialized; public ExpressionEditorContext(WorkspaceManagerProxy workspaceManagerProxy, String fileUri, Info info, Path filePath) { @@ -76,9 +72,8 @@ public ExpressionEditorContext(WorkspaceManagerProxy workspaceManagerProxy, Stri this.fileUri = fileUri; this.info = info; this.filePath = filePath; - this.flowNode = gson.fromJson(info.node(), FlowNode.class); - this.propertyInitialized = false; this.documentContext = new DocumentContext(workspaceManagerProxy, fileUri, filePath); + this.property = new Property(info.property(), info.codedata()); } public ExpressionEditorContext(WorkspaceManagerProxy workspaceManagerProxy, String fileUri, Path filePath, @@ -87,33 +82,12 @@ public ExpressionEditorContext(WorkspaceManagerProxy workspaceManagerProxy, Stri this.fileUri = fileUri; this.filePath = filePath; this.info = null; - this.flowNode = null; - this.propertyInitialized = false; this.documentContext = new DocumentContext(workspaceManagerProxy, fileUri, filePath, document); - } - - public Property getProperty() { - if (propertyInitialized) { - return property; - } - if (info.property() == null || info.property().isEmpty()) { - this.property = null; - } else if (info.branch() == null || info.branch().isEmpty()) { - this.property = flowNode.getProperty(info.property()).orElse(null); - } else { - this.property = flowNode.getBranch(info.branch()) - .flatMap(branch -> branch.getProperty(info.property())) - .orElse(null); - } - propertyInitialized = true; - return property; + this.property = new Property(null, null); } public boolean isNodeKind(List nodeKinds) { - if (flowNode == null || flowNode.codedata() == null) { - return false; - } - return nodeKinds.contains(flowNode.codedata().node()); + return nodeKinds.contains(property.nodeKind()); } public LinePosition getStartLine() { @@ -137,8 +111,8 @@ public Info info() { // TODO: Check how we can use SourceBuilder in place of this method private Optional getImport() { - String org = flowNode.codedata().org(); - String module = flowNode.codedata().module(); + String org = property.org(); + String module = property.module(); if (org == null || module == null || CommonUtils.isPredefinedLangLib(org, module)) { return Optional.empty(); @@ -190,7 +164,6 @@ public Optional getImport(String importStatement) { */ public LineRange generateStatement() { String prefix = "var __reserved__ = "; - Property property = getProperty(); List textEdits = new ArrayList<>(); if (property != null) { @@ -200,12 +173,10 @@ public LineRange generateStatement() { } // Add the import statements of the dependent types - if (property.codedata() != null) { - String importStatements = property.codedata().importStatements(); - if (importStatements != null && !importStatements.isEmpty()) { - for (String importStmt : importStatements.split(",")) { - getImport(importStmt).ifPresent(textEdits::add); - } + String importStatements = property.importStatements(); + if (importStatements != null && !importStatements.isEmpty()) { + for (String importStmt : importStatements.split(",")) { + getImport(importStmt).ifPresent(textEdits::add); } } } @@ -292,18 +263,122 @@ public WorkspaceManager workspaceManager() { return workspaceManagerProxy.get(fileUri); } + public Property getProperty() { + return property; + } + + public static class Property { + + private final JsonObject property; + private final JsonObject codedata; + private boolean initialized; + + // Property values + private String value; + private String valueType; + private String typeConstraint; + + // Codedata values + private String importStatements; + private String org; + private String module; + private NodeKind nodeKind; + + private static final String VALUE_KEY = "value"; + private static final String VALUE_TYPE_KEY = "valueType"; + private static final String TYPE_CONSTRAINT_KEY = "valueTypeConstraint"; + private static final String CODEDATA_KEY = "codedata"; + private static final String IMPORT_STATEMENTS_KEY = "importStatements"; + private static final String ORG_KEY = "org"; + private static final String MODULE_KEY = "module"; + private static final String NODE_KEY = "node"; + + public Property(JsonObject property, JsonObject codedata) { + this.property = property; + this.codedata = codedata; + this.initialized = false; + } + + private void initialize() { + if (initialized) { + return; + } + if (property == null) { + value = ""; + typeConstraint = "any"; + } else { + value = property.has(VALUE_KEY) ? property.get(VALUE_KEY).getAsString() : ""; + valueType = property.has(VALUE_TYPE_KEY) ? property.get(VALUE_TYPE_KEY).getAsString() : ""; + typeConstraint = + property.has(TYPE_CONSTRAINT_KEY) ? property.get(TYPE_CONSTRAINT_KEY).getAsString() : "any"; + JsonObject propertyCodedata = + property.has(CODEDATA_KEY) ? property.getAsJsonObject(CODEDATA_KEY) : null; + if (propertyCodedata != null) { + importStatements = propertyCodedata.has(IMPORT_STATEMENTS_KEY) + ? propertyCodedata.get(IMPORT_STATEMENTS_KEY).getAsString() : ""; + } + } + + if (codedata == null) { + importStatements = ""; + org = ""; + module = ""; + nodeKind = null; + } else { + org = codedata.has(ORG_KEY) ? codedata.get(ORG_KEY).getAsString() : ""; + module = codedata.has(MODULE_KEY) ? codedata.get(MODULE_KEY).getAsString() : ""; + nodeKind = codedata.has(NODE_KEY) ? NodeKind.valueOf(codedata.get(NODE_KEY).getAsString()) : null; + } + initialized = true; + } + + public String value() { + initialize(); + return value; + } + + public String valueType() { + initialize(); + return valueType; + } + + public String valueTypeConstraint() { + initialize(); + return typeConstraint; + } + + public String importStatements() { + initialize(); + return importStatements; + } + + public String org() { + initialize(); + return org; + } + + public String module() { + initialize(); + return module; + } + + public NodeKind nodeKind() { + initialize(); + return nodeKind; + } + } + /** * Represents the json format of the expression editor context. * * @param expression The modified expression * @param startLine The start line of the node * @param offset The offset of cursor compared to the start of the expression - * @param node The node which contains the expression - * @param branch The branch of the expression if exists + * @param codedata The codedata of the expression * @param property The property of the expression */ - public record Info(String expression, LinePosition startLine, int offset, JsonObject node, - String branch, String property) { + public record Info(String expression, LinePosition startLine, int offset, JsonObject codedata, + JsonObject property) { } /** diff --git a/flow-model-generator/modules/flow-model-generator-core/src/main/java/io/ballerina/flowmodelgenerator/core/expressioneditor/services/DiagnosticsRequest.java b/flow-model-generator/modules/flow-model-generator-core/src/main/java/io/ballerina/flowmodelgenerator/core/expressioneditor/services/DiagnosticsRequest.java index 3f9aadf72..f9a2ee35a 100644 --- a/flow-model-generator/modules/flow-model-generator-core/src/main/java/io/ballerina/flowmodelgenerator/core/expressioneditor/services/DiagnosticsRequest.java +++ b/flow-model-generator/modules/flow-model-generator-core/src/main/java/io/ballerina/flowmodelgenerator/core/expressioneditor/services/DiagnosticsRequest.java @@ -44,7 +44,7 @@ public DiagnosticsRequest(ExpressionEditorContext context) { } public static DiagnosticsRequest from(ExpressionEditorContext context) { - Property property = context.getProperty(); + ExpressionEditorContext.Property property = context.getProperty(); if (property == null) { throw new IllegalArgumentException("Property cannot be null"); } diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/java/io/ballerina/flowmodelgenerator/extension/ExpressionEditorCompletionTest.java b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/java/io/ballerina/flowmodelgenerator/extension/ExpressionEditorCompletionTest.java index 377431db1..bf050c048 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/java/io/ballerina/flowmodelgenerator/extension/ExpressionEditorCompletionTest.java +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/java/io/ballerina/flowmodelgenerator/extension/ExpressionEditorCompletionTest.java @@ -80,7 +80,7 @@ public void testMultipleRequests() throws IOException { ExpressionEditorContext.Info firstContext = testConfig.context(); ExpressionEditorContext.Info info = new ExpressionEditorContext.Info("self.classVar > localVar + self. + 21", firstContext.startLine(), - 32, firstContext.node(), firstContext.branch(), firstContext.property()); + 32, firstContext.codedata(), firstContext.property()); ExpressionEditorCompletionRequest secondRequest = new ExpressionEditorCompletionRequest(sourcePath, info, testConfig.completionContext()); JsonObject secondResponse = getResponse(secondRequest); diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/java/io/ballerina/flowmodelgenerator/extension/ExpressionEditorDiagnosticsTest.java b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/java/io/ballerina/flowmodelgenerator/extension/ExpressionEditorDiagnosticsTest.java index 780ac5913..327f26b73 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/java/io/ballerina/flowmodelgenerator/extension/ExpressionEditorDiagnosticsTest.java +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/java/io/ballerina/flowmodelgenerator/extension/ExpressionEditorDiagnosticsTest.java @@ -86,8 +86,8 @@ public void testMultipleRequests() throws IOException, InterruptedException { }; for (int i = 0; i < expressionSteps.length - 1; i++) { ExpressionEditorContext.Info context = new ExpressionEditorContext.Info(expressionSteps[i], - templateContext.startLine(), templateContext.offset(), templateContext.node(), - templateContext.branch(), templateContext.property()); + templateContext.startLine(), templateContext.offset(), templateContext.codedata(), + templateContext.property()); ExpressionEditorDiagnosticsRequest req = new ExpressionEditorDiagnosticsRequest(sourcePath, context); serviceEndpoint.request(method, req); Thread.sleep(400); @@ -96,7 +96,7 @@ public void testMultipleRequests() throws IOException, InterruptedException { // In the final complete expression, assert that no diagnostics are returned ExpressionEditorContext.Info context = new ExpressionEditorContext.Info("fn({id: 0})", templateContext.startLine(), templateContext.offset(), - templateContext.node(), templateContext.branch(), templateContext.property()); + templateContext.codedata(), templateContext.property()); ExpressionEditorDiagnosticsRequest req = new ExpressionEditorDiagnosticsRequest(sourcePath, context); JsonObject resp = getResponse(req); List diagnostics = gson.fromJson(resp.get("diagnostics").getAsJsonArray(), diagnosticsType); diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/java/io/ballerina/flowmodelgenerator/extension/FunctionCallTemplateTest.java b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/java/io/ballerina/flowmodelgenerator/extension/FunctionCallTemplateTest.java index 50d0c1116..f23f498b4 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/java/io/ballerina/flowmodelgenerator/extension/FunctionCallTemplateTest.java +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/java/io/ballerina/flowmodelgenerator/extension/FunctionCallTemplateTest.java @@ -92,7 +92,7 @@ public void testDiagnostics(Path config) throws IOException { template = template.replace("${1}", " "); } ExpressionEditorContext.Info info = new ExpressionEditorContext.Info(template, startPosition, offset, - variableNode, null, "expression"); + variableNode.get("codedata").getAsJsonObject(), null); ExpressionEditorDiagnosticsRequest diagnosticsRequest = new ExpressionEditorDiagnosticsRequest(sourcePath, info); JsonObject response = getResponse(diagnosticsRequest, "expressionEditor/diagnostics"); diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/java/io/ballerina/flowmodelgenerator/extension/ImportModuleTest.java b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/java/io/ballerina/flowmodelgenerator/extension/ImportModuleTest.java index 99de2ea4d..d9ab22baa 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/java/io/ballerina/flowmodelgenerator/extension/ImportModuleTest.java +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/java/io/ballerina/flowmodelgenerator/extension/ImportModuleTest.java @@ -66,7 +66,7 @@ public void test(Path config) throws IOException { // Send diagnostics request ExpressionEditorContext.Info info = new ExpressionEditorContext.Info(testConfig.expression(), LinePosition.from(1, 0), - 0, variableNode, null, "expression"); + 0, variableNode.get("codedata").getAsJsonObject(), null); ExpressionEditorDiagnosticsRequest diagnosticsRequest = new ExpressionEditorDiagnosticsRequest(sourcePath, info); JsonObject response = getResponse(diagnosticsRequest, "expressionEditor/diagnostics"); diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/action_call1.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/action_call1.json index a25a15e97..0462c9b28 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/action_call1.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/action_call1.json @@ -8,127 +8,28 @@ "offset": 0 }, "offset": 0, - "node": { - "id": "31", + "codedata": { + "node": "REMOTE_ACTION_CALL", + "org": "ballerina", + "module": "http", + "object": "Client", + "symbol": "post", + "id": 591 + }, + "property": { "metadata": { - "label": "post", - "description": "The `Client.post()` function can be used to send HTTP POST requests to HTTP endpoints.\n", - "icon": "https://bcentral-packageicons.azureedge.net/images/ballerina_http_2.12.2.png" - }, - "codedata": { - "node": "REMOTE_ACTION_CALL", - "org": "ballerina", - "module": "http", - "object": "Client", - "symbol": "post", - "id": 591 + "label": "message", + "description": "An HTTP outbound request or any allowed payload" }, - "returning": false, - "properties": { - "connection": { - "metadata": { - "label": "Connection", - "description": "Connection to use" - }, - "valueType": "IDENTIFIER", - "valueTypeConstraint": "http:Client", - "value": "httpClient", - "optional": false, - "editable": false, - "advanced": false - }, - "path": { - "metadata": { - "label": "path", - "description": "Resource path" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "string", - "value": "\"\"", - "placeholder": "\"\"", - "optional": false, - "editable": true, - "advanced": false, - "kind": "REQUIRED" - }, - "message": { - "metadata": { - "label": "message", - "description": "An HTTP outbound request or any allowed payload" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:RequestMessage", - "value": "{}", - "placeholder": "{}", - "optional": false, - "editable": true, - "advanced": false, - "kind": "REQUIRED" - }, - "headers": { - "metadata": { - "label": "headers", - "description": "The entity headers" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "map|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "kind": "DEFAULTABLE" - }, - "mediaType": { - "metadata": { - "label": "mediaType", - "description": "The MIME type header of the request entity" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "string|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "kind": "DEFAULTABLE" - }, - "type": { - "metadata": { - "label": "Variable Type", - "description": "Type of the variable" - }, - "valueType": "TYPE", - "value": "json", - "placeholder": "var", - "optional": false, - "editable": false, - "advanced": false - }, - "variable": { - "metadata": { - "label": "Variable Name", - "description": "Name of the variable" - }, - "valueType": "IDENTIFIER", - "value": "jsonResult", - "optional": false, - "editable": true, - "advanced": false - }, - "checkError": { - "metadata": { - "label": "Check Error", - "description": "Trigger error flow" - }, - "valueType": "FLAG", - "value": true, - "optional": false, - "editable": true, - "advanced": true - } - }, - "flags": 0 - }, - "property": "message" + "valueType": "EXPRESSION", + "valueTypeConstraint": "http:RequestMessage", + "value": "{}", + "placeholder": "{}", + "optional": false, + "editable": true, + "advanced": false, + "kind": "REQUIRED" + } }, "diagnostics": [ { @@ -149,4 +50,4 @@ "message": "undefined symbol 'val'" } ] -} +} \ No newline at end of file diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/function_call1.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/function_call1.json index bdf5f88db..65f634bba 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/function_call1.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/function_call1.json @@ -8,78 +8,27 @@ "offset": 8 }, "offset": 0, - "node": { - "id": "31", + "codedata": { + "node": "FUNCTION_CALL", + "org": "ballerina", + "module": "log", + "symbol": "printInfo", + "version": "2.10.0" + }, + "property": { "metadata": { - "label": "printInfo", - "description": "Prints info logs.\n```ballerina\nlog:printInfo(\"info message\", id = 845315)\n```\n" - }, - "codedata": { - "node": "FUNCTION_CALL", - "org": "ballerina", - "module": "log", - "symbol": "printInfo", - "version": "2.10.0" + "label": "msg", + "description": "The message to be logged" }, - "returning": false, - "properties": { - "msg": { - "metadata": { - "label": "msg", - "description": "The message to be logged" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "string", - "value": "\"\"", - "placeholder": "\"\"", - "optional": false, - "editable": true, - "advanced": false, - "kind": "REQUIRED" - }, - "'error": { - "metadata": { - "label": "'error", - "description": "The error struct to be logged" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "error|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "kind": "DEFAULTABLE" - }, - "stackTrace": { - "metadata": { - "label": "stackTrace", - "description": "The error stack trace to be logged" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "ballerina/lang.error:0.0.0:StackFrame[]|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "kind": "DEFAULTABLE" - }, - "Additional Values": { - "metadata": { - "label": "Additional Values", - "description": "Capture key value pairs" - }, - "valueType": "MAPPING_EXPRESSION_SET", - "valueTypeConstraint": "log:Value", - "placeholder": "{}", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_RECORD_REST" - } - }, - "flags": 0 - }, - "property": "msg" + "valueType": "EXPRESSION", + "valueTypeConstraint": "string", + "value": "\"\"", + "placeholder": "\"\"", + "optional": false, + "editable": true, + "advanced": false, + "kind": "REQUIRED" + } }, "diagnostics": [ { diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/function_call2.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/function_call2.json index df21e8426..aac9154ed 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/function_call2.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/function_call2.json @@ -8,73 +8,27 @@ "offset": 8 }, "offset": 0, - "node": { - "id": "31", + "codedata": { + "node": "FUNCTION_CALL", + "org": "ballerina", + "module": "time", + "symbol": "utcFromCivil", + "version": "2.5.0" + }, + "property": { "metadata": { - "label": "utcFromCivil", - "description": "Converts a given `Civil` value to an `Utc` timestamp.\n```ballerina\ntime:Civil civil = time:utcToCivil(time:utcNow());\ntime:Utc utc = time:utcFromCivil(civil);\n```" - }, - "codedata": { - "node": "FUNCTION_CALL", - "org": "ballerina", - "module": "time", - "symbol": "utcFromCivil", - "version": "2.5.0" + "label": "civilTime", + "description": "`time:Civil` time" }, - "returning": false, - "properties": { - "civilTime": { - "metadata": { - "label": "civilTime", - "description": "`time:Civil` time" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "time:Civil", - "value": "{year: 0, month: 0, day: 0, hour: 0, minute: 0}", - "placeholder": "{year: 0, month: 0, day: 0, hour: 0, minute: 0}", - "optional": false, - "editable": true, - "advanced": false, - "kind": "REQUIRED" - }, - "type": { - "metadata": { - "label": "Variable Type", - "description": "Type of the variable" - }, - "valueType": "TYPE", - "value": "time:Utc", - "placeholder": "var", - "optional": false, - "editable": false, - "advanced": false - }, - "variable": { - "metadata": { - "label": "Variable Name", - "description": "Name of the variable" - }, - "valueType": "IDENTIFIER", - "value": "timeUtc", - "optional": false, - "editable": true, - "advanced": false - }, - "checkError": { - "metadata": { - "label": "Check Error", - "description": "Trigger error flow" - }, - "valueType": "FLAG", - "value": true, - "optional": false, - "editable": true, - "advanced": true - } - }, - "flags": 0 - }, - "property": "civilTime" + "valueType": "EXPRESSION", + "valueTypeConstraint": "time:Civil", + "value": "{year: 0, month: 0, day: 0, hour: 0, minute: 0}", + "placeholder": "{year: 0, month: 0, day: 0, hour: 0, minute: 0}", + "optional": false, + "editable": true, + "advanced": false, + "kind": "REQUIRED" + } }, "diagnostics": [ { diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/function_call3.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/function_call3.json index 3fa3edd04..4a06c7276 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/function_call3.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/function_call3.json @@ -8,57 +8,23 @@ "offset": 8 }, "offset": 0, - "node": { - "id": "31", + "codedata": { + "node": "FUNCTION_CALL", + "symbol": "fn" + }, + "property": { "metadata": { - "label": "fn" - }, - "codedata": { - "node": "FUNCTION_CALL", - "symbol": "fn" - }, - "returning": false, - "properties": { - "rec": { - "metadata": { - "label": "rec" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "MyRecord", - "value": "{id: 0}", - "placeholder": "{id: 0}", - "optional": false, - "editable": true, - "advanced": false, - "kind": "REQUIRED" - }, - "type": { - "metadata": { - "label": "Variable Type", - "description": "Type of the variable" - }, - "valueType": "TYPE", - "value": "int", - "placeholder": "var", - "optional": false, - "editable": true, - "advanced": false - }, - "variable": { - "metadata": { - "label": "Variable Name", - "description": "Name of the variable" - }, - "valueType": "IDENTIFIER", - "value": "intResult", - "optional": false, - "editable": true, - "advanced": false - } + "label": "rec" }, - "flags": 0 - }, - "property": "rec" + "valueType": "EXPRESSION", + "valueTypeConstraint": "MyRecord", + "value": "{id: 0}", + "placeholder": "{id: 0}", + "optional": false, + "editable": true, + "advanced": false, + "kind": "REQUIRED" + } }, "diagnostics": [ { diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/identifiers1.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/identifiers1.json index a607e14d6..033f08469 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/identifiers1.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/identifiers1.json @@ -8,67 +8,32 @@ "offset": 35 }, "offset": 2, - "node": { - "id": "32874", - "metadata": { - "label": "Variable", - "description": "Assign a value to a variable" - }, - "codedata": { - "node": "VARIABLE", - "lineRange": { - "fileName": "new_data.bal", - "startLine": { - "line": 1, - "offset": 4 - }, - "endLine": { - "line": 1, - "offset": 14 - } - }, - "sourceCode": "int i = 12;" - }, - "returning": false, - "properties": { - "expression": { - "metadata": { - "label": "Expression", - "description": "Initialize with value" - }, - "valueType": "EXPRESSION", - "value": "12", - "optional": true, - "editable": true, - "advanced": false + "codedata": { + "node": "VARIABLE", + "lineRange": { + "fileName": "new_data.bal", + "startLine": { + "line": 1, + "offset": 4 }, - "variable": { - "metadata": { - "label": "Name", - "description": "Name of the variable" - }, - "valueType": "IDENTIFIER", - "value": "i", - "optional": false, - "editable": true, - "advanced": false - }, - "type": { - "metadata": { - "label": "Type", - "description": "Type of the variable" - }, - "valueType": "TYPE", - "value": "", - "placeholder": "var", - "optional": false, - "editable": true, - "advanced": false + "endLine": { + "line": 1, + "offset": 14 } }, - "flags": 0 + "sourceCode": "int i = 12;" }, - "property": "variable" + "property": { + "metadata": { + "label": "Name", + "description": "Name of the variable" + }, + "valueType": "IDENTIFIER", + "value": "i", + "optional": false, + "editable": true, + "advanced": false + } }, "diagnostics": [ { diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection1.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection1.json index 4660c57df..d6efb9bae 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection1.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection1.json @@ -8,124 +8,27 @@ "offset": 8 }, "offset": 0, - "node": { - "id": "31", + "codedata": { + "node": "NEW_CONNECTION", + "org": "ballerinax", + "module": "redis", + "object": "Client", + "symbol": "init", + "id": 691 + }, + "property": { "metadata": { - "label": "New Connection", - "description": "Ballerina Redis connector provides the capability to access Redis cache.\nThis connector lets you to perform operations to access and manipulate key-value data stored in a Redis database. \n", - "icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_redis_3.0.2.png" - }, - "codedata": { - "node": "NEW_CONNECTION", - "org": "ballerinax", - "module": "redis", - "object": "Client", - "symbol": "init", - "id": 691 + "label": "connection", + "description": "" }, - "returning": false, - "properties": { - "connection": { - "metadata": { - "label": "connection", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "redis:ConnectionUri|redis:ConnectionParams", - "placeholder": "\"redis://localhost:6379\"", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "connectionPooling": { - "metadata": { - "label": "connectionPooling", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "boolean", - "placeholder": "false", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "isClusterConnection": { - "metadata": { - "label": "isClusterConnection", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "boolean", - "placeholder": "false", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "secureSocket": { - "metadata": { - "label": "secureSocket", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "record {|ballerina/crypto:2.6.2:TrustStore|string cert?; ballerina/crypto:2.6.2:KeyStore|ballerinax/redis:3.0.2:CertKey key?; string[] protocols?; string[] ciphers?; ballerinax/redis:3.0.2:SslVerifyMode verifyMode; boolean startTls;|}", - "placeholder": "{}", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "type": { - "metadata": { - "label": "Variable Type", - "description": "Type of the variable" - }, - "valueType": "TYPE", - "value": "redis:Client", - "placeholder": "var", - "optional": false, - "editable": false, - "advanced": false - }, - "variable": { - "metadata": { - "label": "Connection Name", - "description": "Name of the variable" - }, - "valueType": "IDENTIFIER", - "value": "redisClient", - "optional": false, - "editable": true, - "advanced": false - }, - "scope": { - "metadata": { - "label": "Connection Scope", - "description": "Scope of the connection, Global or Local" - }, - "valueType": "ENUM", - "value": "Global", - "optional": false, - "editable": true, - "advanced": true - }, - "checkError": { - "metadata": { - "label": "Check Error", - "description": "Terminate on error" - }, - "valueType": "FLAG", - "value": true, - "optional": false, - "editable": false, - "advanced": true - } - }, - "flags": 0 - }, - "property": "connection" + "valueType": "EXPRESSION", + "valueTypeConstraint": "redis:ConnectionUri|redis:ConnectionParams", + "placeholder": "\"redis://localhost:6379\"", + "optional": true, + "editable": true, + "advanced": true, + "kind": "INCLUDED_FIELD" + } }, "diagnostics": [ { diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection2.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection2.json index 62b318f7a..9d7ca6739 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection2.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection2.json @@ -8,320 +8,27 @@ "offset": 8 }, "offset": 0, - "node": { - "id": "31", + "codedata": { + "node": "NEW_CONNECTION", + "org": "ballerina", + "module": "http", + "object": "Client", + "symbol": "init", + "id": 589 + }, + "property": { "metadata": { - "label": "New Connection", - "description": "The HTTP client provides the capability for initiating contact with a remote HTTP service. The API it\nprovides includes the functions for the standard HTTP methods forwarding a received request and sending requests\nusing custom HTTP verbs.", - "icon": "https://bcentral-packageicons.azureedge.net/images/ballerina_http_2.12.2.png" - }, - "codedata": { - "node": "NEW_CONNECTION", - "org": "ballerina", - "module": "http", - "object": "Client", - "symbol": "init", - "id": 589 - }, - "returning": false, - "properties": { - "url": { - "metadata": { - "label": "url", - "description": "URL of the target service" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "string", - "value": "\"\"", - "placeholder": "\"\"", - "optional": false, - "editable": true, - "advanced": false, - "kind": "REQUIRED" - }, - "httpVersion": { - "metadata": { - "label": "httpVersion", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "\"2.0\"|\"1.1\"|\"1.0\"", - "placeholder": "\"2.0\"", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "http1Settings": { - "metadata": { - "label": "http1Settings", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "record {|ballerina/http:2.12.2:KeepAlive keepAlive; ballerina/http:2.12.2:Chunking chunking; ballerina/http:2.12.2:ProxyConfig? proxy;|}", - "placeholder": "{}", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "http2Settings": { - "metadata": { - "label": "http2Settings", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "record {|boolean http2PriorKnowledge; int http2InitialWindowSize;|}", - "placeholder": "{}", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "timeout": { - "metadata": { - "label": "timeout", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "decimal", - "placeholder": "0.0d", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "forwarded": { - "metadata": { - "label": "forwarded", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "string", - "placeholder": "\"\"", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "followRedirects": { - "metadata": { - "label": "followRedirects", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:FollowRedirects|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "poolConfig": { - "metadata": { - "label": "poolConfig", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:PoolConfiguration|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "cache": { - "metadata": { - "label": "cache", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "record {|boolean enabled; boolean isShared; int capacity; float evictionFactor; ballerina/http:2.12.2:CachingPolicy policy;|}", - "placeholder": "{}", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "compression": { - "metadata": { - "label": "compression", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "\"AUTO\"|\"ALWAYS\"|\"NEVER\"", - "placeholder": "\"AUTO\"", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "auth": { - "metadata": { - "label": "auth", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:CredentialsConfig|http:BearerTokenConfig|http:JwtIssuerConfig|http:OAuth2ClientCredentialsGrantConfig|http:OAuth2PasswordGrantConfig|http:OAuth2RefreshTokenGrantConfig|http:OAuth2JwtBearerGrantConfig|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "circuitBreaker": { - "metadata": { - "label": "circuitBreaker", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:CircuitBreakerConfig|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "retryConfig": { - "metadata": { - "label": "retryConfig", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:RetryConfig|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "cookieConfig": { - "metadata": { - "label": "cookieConfig", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:CookieConfig|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "responseLimits": { - "metadata": { - "label": "responseLimits", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "record {|int maxStatusLineLength; int maxHeaderSize; int maxEntityBodySize;|}", - "placeholder": "{}", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "proxy": { - "metadata": { - "label": "proxy", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:ProxyConfig|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "validation": { - "metadata": { - "label": "validation", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "boolean", - "placeholder": "false", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "socketConfig": { - "metadata": { - "label": "socketConfig", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "record {|decimal connectTimeOut; int receiveBufferSize; int sendBufferSize; boolean tcpNoDelay; boolean socketReuse; boolean keepAlive;|}", - "placeholder": "{}", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "secureSocket": { - "metadata": { - "label": "secureSocket", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:ClientSecureSocket|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "type": { - "metadata": { - "label": "Variable Type", - "description": "Type of the variable" - }, - "valueType": "TYPE", - "value": "http:Client", - "placeholder": "var", - "optional": false, - "editable": false, - "advanced": false - }, - "variable": { - "metadata": { - "label": "Connection Name", - "description": "Name of the variable" - }, - "valueType": "IDENTIFIER", - "value": "httpClientOut", - "optional": false, - "editable": true, - "advanced": false - }, - "scope": { - "metadata": { - "label": "Connection Scope", - "description": "Scope of the connection, Global or Local" - }, - "valueType": "ENUM", - "value": "Global", - "optional": false, - "editable": true, - "advanced": true - }, - "checkError": { - "metadata": { - "label": "Check Error", - "description": "Terminate on error" - }, - "valueType": "FLAG", - "value": true, - "optional": false, - "editable": false, - "advanced": true - } + "label": "httpVersion", + "description": "" }, - "flags": 0 - }, - "property": "httpVersion" + "valueType": "EXPRESSION", + "valueTypeConstraint": "\"2.0\"|\"1.1\"|\"1.0\"", + "placeholder": "\"2.0\"", + "optional": true, + "editable": true, + "advanced": true, + "kind": "INCLUDED_FIELD" + } }, "diagnostics": [ { @@ -342,4 +49,4 @@ "message": "incompatible types: expected '\"2.0\"|\"1.1\"|\"1.0\"', found 'string'" } ] -} +} \ No newline at end of file diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection3.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection3.json index bb0c0820c..0e80b9e3f 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection3.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection3.json @@ -8,320 +8,27 @@ "offset": 0 }, "offset": 0, - "node": { - "id": "31", + "codedata": { + "node": "NEW_CONNECTION", + "org": "ballerina", + "module": "http", + "object": "Client", + "symbol": "init", + "id": 589 + }, + "property": { "metadata": { - "label": "New Connection", - "description": "The HTTP client provides the capability for initiating contact with a remote HTTP service. The API it\nprovides includes the functions for the standard HTTP methods forwarding a received request and sending requests\nusing custom HTTP verbs.", - "icon": "https://bcentral-packageicons.azureedge.net/images/ballerina_http_2.12.2.png" - }, - "codedata": { - "node": "NEW_CONNECTION", - "org": "ballerina", - "module": "http", - "object": "Client", - "symbol": "init", - "id": 589 - }, - "returning": false, - "properties": { - "url": { - "metadata": { - "label": "url", - "description": "URL of the target service" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "string", - "value": "\"\"", - "placeholder": "\"\"", - "optional": false, - "editable": true, - "advanced": false, - "kind": "REQUIRED" - }, - "httpVersion": { - "metadata": { - "label": "httpVersion", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "\"2.0\"|\"1.1\"|\"1.0\"", - "placeholder": "\"2.0\"", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "http1Settings": { - "metadata": { - "label": "http1Settings", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "record {|ballerina/http:2.12.2:KeepAlive keepAlive; ballerina/http:2.12.2:Chunking chunking; ballerina/http:2.12.2:ProxyConfig? proxy;|}", - "placeholder": "{}", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "http2Settings": { - "metadata": { - "label": "http2Settings", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "record {|boolean http2PriorKnowledge; int http2InitialWindowSize;|}", - "placeholder": "{}", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "timeout": { - "metadata": { - "label": "timeout", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "decimal", - "placeholder": "0.0d", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "forwarded": { - "metadata": { - "label": "forwarded", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "string", - "placeholder": "\"\"", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "followRedirects": { - "metadata": { - "label": "followRedirects", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:FollowRedirects|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "poolConfig": { - "metadata": { - "label": "poolConfig", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:PoolConfiguration|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "cache": { - "metadata": { - "label": "cache", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "record {|boolean enabled; boolean isShared; int capacity; float evictionFactor; ballerina/http:2.12.2:CachingPolicy policy;|}", - "placeholder": "{}", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "compression": { - "metadata": { - "label": "compression", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "\"AUTO\"|\"ALWAYS\"|\"NEVER\"", - "placeholder": "\"AUTO\"", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "auth": { - "metadata": { - "label": "auth", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:CredentialsConfig|http:BearerTokenConfig|http:JwtIssuerConfig|http:OAuth2ClientCredentialsGrantConfig|http:OAuth2PasswordGrantConfig|http:OAuth2RefreshTokenGrantConfig|http:OAuth2JwtBearerGrantConfig|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "circuitBreaker": { - "metadata": { - "label": "circuitBreaker", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:CircuitBreakerConfig|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "retryConfig": { - "metadata": { - "label": "retryConfig", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:RetryConfig|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "cookieConfig": { - "metadata": { - "label": "cookieConfig", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:CookieConfig|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "responseLimits": { - "metadata": { - "label": "responseLimits", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "record {|int maxStatusLineLength; int maxHeaderSize; int maxEntityBodySize;|}", - "placeholder": "{}", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "proxy": { - "metadata": { - "label": "proxy", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:ProxyConfig|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "validation": { - "metadata": { - "label": "validation", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "boolean", - "placeholder": "false", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "socketConfig": { - "metadata": { - "label": "socketConfig", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "record {|decimal connectTimeOut; int receiveBufferSize; int sendBufferSize; boolean tcpNoDelay; boolean socketReuse; boolean keepAlive;|}", - "placeholder": "{}", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "secureSocket": { - "metadata": { - "label": "secureSocket", - "description": "" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:ClientSecureSocket|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "kind": "INCLUDED_FIELD" - }, - "type": { - "metadata": { - "label": "Variable Type", - "description": "Type of the variable" - }, - "valueType": "TYPE", - "value": "http:Client", - "placeholder": "var", - "optional": false, - "editable": false, - "advanced": false - }, - "variable": { - "metadata": { - "label": "Connection Name", - "description": "Name of the variable" - }, - "valueType": "IDENTIFIER", - "value": "httpClientOut", - "optional": false, - "editable": true, - "advanced": false - }, - "scope": { - "metadata": { - "label": "Connection Scope", - "description": "Scope of the connection, Global or Local" - }, - "valueType": "ENUM", - "value": "Global", - "optional": false, - "editable": true, - "advanced": true - }, - "checkError": { - "metadata": { - "label": "Check Error", - "description": "Terminate on error" - }, - "valueType": "FLAG", - "value": true, - "optional": false, - "editable": false, - "advanced": true - } + "label": "httpVersion", + "description": "" }, - "flags": 0 - }, - "property": "httpVersion" + "valueType": "EXPRESSION", + "valueTypeConstraint": "\"2.0\"|\"1.1\"|\"1.0\"", + "placeholder": "\"2.0\"", + "optional": true, + "editable": true, + "advanced": true, + "kind": "INCLUDED_FIELD" + } }, "diagnostics": [ { @@ -342,4 +49,4 @@ "message": "incompatible types: expected '\"2.0\"|\"1.1\"|\"1.0\"', found 'string'" } ] -} +} \ No newline at end of file diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection4.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection4.json index f93be447b..cbdcfafbc 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection4.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection4.json @@ -8,168 +8,43 @@ "offset": 0 }, "offset": 1, - "node": { - "id": "35776", - "metadata": { - "label": "New Connection", - "description": "Represents a Snowflake database client.", - "icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_snowflake_2.0.0.png" - }, - "codedata": { - "node": "NEW_CONNECTION", - "org": "ballerinax", - "module": "snowflake", - "object": "Client", - "symbol": "init", - "version": "2.0.0", - "lineRange": { - "fileName": "connections.bal", - "startLine": { - "line": 4, - "offset": 0 - }, - "endLine": { - "line": 4, - "offset": 64 - } - }, - "sourceCode": "final snowflake:Client snowflakeClient = check new (\"\", \"\", \"\");" - }, - "returning": false, - "properties": { - "scope": { - "metadata": { - "label": "Connection Scope", - "description": "Scope of the connection, Global or Local" - }, - "valueType": "ENUM", - "value": "Global", - "optional": false, - "editable": true, - "advanced": true - }, - "checkError": { - "metadata": { - "label": "Check Error", - "description": "Terminate on error" - }, - "valueType": "FLAG", - "value": true, - "optional": false, - "editable": false, - "advanced": true - }, - "account_identifier": { - "metadata": { - "label": "account_identifier", - "description": "The Snowflake account identifier" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "string", - "value": "\"\"", - "placeholder": "\"\"", - "optional": false, - "editable": true, - "advanced": false, - "codedata": { - "kind": "REQUIRED", - "originalName": "account_identifier" - } - }, - "user": { - "metadata": { - "label": "user", - "description": "The username of the Snowflake account" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "string", - "value": "\"\"", - "placeholder": "\"\"", - "optional": false, - "editable": true, - "advanced": false, - "codedata": { - "kind": "REQUIRED", - "originalName": "user" - } - }, - "password": { - "metadata": { - "label": "password", - "description": "The password of the Snowflake account" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "string", - "value": "\"\"", - "placeholder": "\"\"", - "optional": false, - "editable": true, - "advanced": false, - "codedata": { - "kind": "REQUIRED", - "originalName": "password" - } - }, - "options": { - "metadata": { - "label": "options", - "description": "The Snowflake client properties" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "snowflake:Options|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "DEFAULTABLE", - "originalName": "options" - } - }, - "connectionPool": { - "metadata": { - "label": "connectionPool", - "description": "The `sql:ConnectionPool` to be used for the connection. If there is no\n`connectionPool` provided, the global connection pool (shared by all clients) will be used" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "sql:ConnectionPool|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "DEFAULTABLE", - "originalName": "connectionPool", - "importStatements": "ballerina/sql" - } - }, - "variable": { - "metadata": { - "label": "Connection Name", - "description": "Name of the variable" - }, - "valueType": "IDENTIFIER", - "value": "snowflakeClient", - "optional": false, - "editable": true, - "advanced": false - }, - "type": { - "metadata": { - "label": "Connection Type", - "description": "Type of the variable" - }, - "valueType": "TYPE", - "value": "snowflake:Client", - "placeholder": "var", - "optional": false, - "editable": false, - "advanced": false + "codedata": { + "node": "NEW_CONNECTION", + "org": "ballerinax", + "module": "snowflake", + "object": "Client", + "symbol": "init", + "version": "2.0.0", + "lineRange": { + "fileName": "connections.bal", + "startLine": { + "line": 4, + "offset": 0 + }, + "endLine": { + "line": 4, + "offset": 64 } }, - "flags": 1 + "sourceCode": "final snowflake:Client snowflakeClient = check new (\"\", \"\", \"\");" }, - "property": "connectionPool" + "property": { + "metadata": { + "label": "connectionPool", + "description": "The `sql:ConnectionPool` to be used for the connection. If there is no\n`connectionPool` provided, the global connection pool (shared by all clients) will be used" + }, + "valueType": "EXPRESSION", + "valueTypeConstraint": "sql:ConnectionPool|()", + "placeholder": "()", + "optional": true, + "editable": true, + "advanced": true, + "codedata": { + "kind": "DEFAULTABLE", + "originalName": "connectionPool", + "importStatements": "ballerina/sql" + } + } }, "diagnostics": [] } diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection5.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection5.json index 32a050662..359292fda 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection5.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection5.json @@ -8,168 +8,42 @@ "offset": 0 }, "offset": 1, - "node": { - "id": "35776", - "metadata": { - "label": "New Connection", - "description": "Represents a Snowflake database client.", - "icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_snowflake_2.0.0.png" - }, - "codedata": { - "node": "NEW_CONNECTION", - "org": "ballerinax", - "module": "snowflake", - "object": "Client", - "symbol": "init", - "version": "2.0.0", - "lineRange": { - "fileName": "connections.bal", - "startLine": { - "line": 4, - "offset": 0 - }, - "endLine": { - "line": 4, - "offset": 64 - } - }, - "sourceCode": "final snowflake:Client snowflakeClient = check new (\"\", \"\", \"\");" - }, - "returning": false, - "properties": { - "scope": { - "metadata": { - "label": "Connection Scope", - "description": "Scope of the connection, Global or Local" - }, - "valueType": "ENUM", - "value": "Global", - "optional": false, - "editable": true, - "advanced": true - }, - "checkError": { - "metadata": { - "label": "Check Error", - "description": "Terminate on error" - }, - "valueType": "FLAG", - "value": true, - "optional": false, - "editable": false, - "advanced": true - }, - "account_identifier": { - "metadata": { - "label": "account_identifier", - "description": "The Snowflake account identifier" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "string", - "value": "\"\"", - "placeholder": "\"\"", - "optional": false, - "editable": true, - "advanced": false, - "codedata": { - "kind": "REQUIRED", - "originalName": "account_identifier" - } - }, - "user": { - "metadata": { - "label": "user", - "description": "The username of the Snowflake account" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "string", - "value": "\"\"", - "placeholder": "\"\"", - "optional": false, - "editable": true, - "advanced": false, - "codedata": { - "kind": "REQUIRED", - "originalName": "user" - } - }, - "password": { - "metadata": { - "label": "password", - "description": "The password of the Snowflake account" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "string", - "value": "\"\"", - "placeholder": "\"\"", - "optional": false, - "editable": true, - "advanced": false, - "codedata": { - "kind": "REQUIRED", - "originalName": "password" - } - }, - "options": { - "metadata": { - "label": "options", - "description": "The Snowflake client properties" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "snowflake:Options|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "DEFAULTABLE", - "originalName": "options" - } - }, - "connectionPool": { - "metadata": { - "label": "connectionPool", - "description": "The `sql:ConnectionPool` to be used for the connection. If there is no\n`connectionPool` provided, the global connection pool (shared by all clients) will be used" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "sql:ConnectionPool|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "DEFAULTABLE", - "originalName": "connectionPool", - "importStatements": "ballerina/sql" - } - }, - "variable": { - "metadata": { - "label": "Connection Name", - "description": "Name of the variable" - }, - "valueType": "IDENTIFIER", - "value": "snowflakeClient", - "optional": false, - "editable": true, - "advanced": false - }, - "type": { - "metadata": { - "label": "Connection Type", - "description": "Type of the variable" - }, - "valueType": "TYPE", - "value": "snowflake:Client", - "placeholder": "var", - "optional": false, - "editable": false, - "advanced": false + "codedata": { + "node": "NEW_CONNECTION", + "org": "ballerinax", + "module": "snowflake", + "object": "Client", + "symbol": "init", + "version": "2.0.0", + "lineRange": { + "fileName": "connections.bal", + "startLine": { + "line": 4, + "offset": 0 + }, + "endLine": { + "line": 4, + "offset": 64 } }, - "flags": 1 + "sourceCode": "final snowflake:Client snowflakeClient = check new (\"\", \"\", \"\");" }, - "property": "options" + "property": { + "metadata": { + "label": "options", + "description": "The Snowflake client properties" + }, + "valueType": "EXPRESSION", + "valueTypeConstraint": "snowflake:Options|()", + "placeholder": "()", + "optional": true, + "editable": true, + "advanced": true, + "codedata": { + "kind": "DEFAULTABLE", + "originalName": "options" + } + } }, "diagnostics": [] } diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/single1.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/single1.json index c427d3df2..57addc278 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/single1.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/single1.json @@ -8,105 +8,35 @@ "offset": 8 }, "offset": 0, - "node": { - "id": "47036", - "metadata": { - "label": "If", - "description": "Add conditional branch to the integration flow." - }, - "codedata": { - "node": "IF", - "lineRange": { - "fileName": "if_node.bal", - "startLine": { - "line": 15, - "offset": 8 - }, - "endLine": { - "line": 20, - "offset": 9 - } - }, - "sourceCode": "if flag {\n int a = 1;\n } else {\n int b = 2;\n string c = \"12\";\n }" - }, - "returning": false, - "branches": [ - { - "label": "Then", - "kind": "BLOCK", - "codedata": { - "node": "CONDITIONAL", - "lineRange": { - "fileName": "if_node.bal", - "startLine": { - "line": 15, - "offset": 16 - }, - "endLine": { - "line": 17, - "offset": 9 - } - }, - "sourceCode": "{\n int a = 1;\n }" - }, - "repeatable": "ONE_OR_MORE", - "properties": { - "condition": { - "metadata": { - "label": "Condition", - "description": "Boolean Condition" - }, - "valueType": "EXPRESSION", - "value": "flag ", - "placeholder": "true", - "optional": false, - "editable": true, - "advanced": false - } - }, - "children": [] + "codedata": { + "node": "IF", + "lineRange": { + "fileName": "if_node.bal", + "startLine": { + "line": 15, + "offset": 8 }, - { - "label": "self.classVar > ", - "kind": "BLOCK", - "codedata": { - "node": "CONDITIONAL", - "lineRange": { - "fileName": "if_node.bal", - "startLine": { - "line": 17, - "offset": 15 - }, - "endLine": { - "line": 20, - "offset": 9 - } - }, - "sourceCode": "{\n int b = 2;\n string c = \"12\";\n }" - }, - "repeatable": "ONE_OR_MORE", - "properties": { - "condition": { - "metadata": { - "label": "Condition", - "description": "Boolean Condition" - }, - "valueType": "EXPRESSION", - "value": "self.classVar > ", - "valueTypeConstraint": "boolean", - "placeholder": "true", - "optional": false, - "editable": true, - "advanced": false - } - }, - "children": [] + "endLine": { + "line": 20, + "offset": 9 } - ], - "flags": 0 + }, + "sourceCode": "if flag {\n int a = 1;\n } else {\n int b = 2;\n string c = \"12\";\n }" }, "branch": "self.classVar > ", - "property": "condition" + "property": { + "metadata": { + "label": "Condition", + "description": "Boolean Condition" + }, + "valueType": "EXPRESSION", + "value": "self.classVar > ", + "valueTypeConstraint": "boolean", + "placeholder": "true", + "optional": false, + "editable": true, + "advanced": false + } }, "diagnostics": [ { diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/single2.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/single2.json index 63d7755b5..7508afefa 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/single2.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/single2.json @@ -8,105 +8,35 @@ "offset": 8 }, "offset": 0, - "node": { - "id": "47036", - "metadata": { - "label": "If", - "description": "Add conditional branch to the integration flow." - }, - "codedata": { - "node": "IF", - "lineRange": { - "fileName": "if_node.bal", - "startLine": { - "line": 15, - "offset": 8 - }, - "endLine": { - "line": 20, - "offset": 9 - } - }, - "sourceCode": "if flag {\n int a = 1;\n } else {\n int b = 2;\n string c = \"12\";\n }" - }, - "returning": false, - "branches": [ - { - "label": "Then", - "kind": "BLOCK", - "codedata": { - "node": "CONDITIONAL", - "lineRange": { - "fileName": "if_node.bal", - "startLine": { - "line": 15, - "offset": 16 - }, - "endLine": { - "line": 17, - "offset": 9 - } - }, - "sourceCode": "{\n int a = 1;\n }" - }, - "repeatable": "ONE_OR_MORE", - "properties": { - "condition": { - "metadata": { - "label": "Condition", - "description": "Boolean Condition" - }, - "valueType": "EXPRESSION", - "value": "flag ", - "placeholder": "true", - "optional": false, - "editable": true, - "advanced": false - } - }, - "children": [] + "codedata": { + "node": "IF", + "lineRange": { + "fileName": "if_node.bal", + "startLine": { + "line": 15, + "offset": 8 }, - { - "label": "self.classVar > ", - "kind": "BLOCK", - "codedata": { - "node": "CONDITIONAL", - "lineRange": { - "fileName": "if_node.bal", - "startLine": { - "line": 17, - "offset": 15 - }, - "endLine": { - "line": 20, - "offset": 9 - } - }, - "sourceCode": "{\n int b = 2;\n string c = \"12\";\n }" - }, - "repeatable": "ONE_OR_MORE", - "properties": { - "condition": { - "metadata": { - "label": "Condition", - "description": "Boolean Condition" - }, - "valueType": "EXPRESSION", - "value": "self.classVar > ", - "valueTypeConstraint": "boolean", - "placeholder": "true", - "optional": false, - "editable": true, - "advanced": false - } - }, - "children": [] + "endLine": { + "line": 20, + "offset": 9 } - ], - "flags": 0 + }, + "sourceCode": "if flag {\n int a = 1;\n } else {\n int b = 2;\n string c = \"12\";\n }" }, "branch": "self.classVar > ", - "property": "condition" + "property": { + "metadata": { + "label": "Condition", + "description": "Boolean Condition" + }, + "valueType": "EXPRESSION", + "value": "self.classVar > ", + "valueTypeConstraint": "boolean", + "placeholder": "true", + "optional": false, + "editable": true, + "advanced": false + } }, "diagnostics": [ { diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/single3.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/single3.json index 200b2a6a2..30fffc027 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/single3.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/single3.json @@ -8,105 +8,35 @@ "offset": 8 }, "offset": 0, - "node": { - "id": "47036", - "metadata": { - "label": "If", - "description": "Add conditional branch to the integration flow." - }, - "codedata": { - "node": "IF", - "lineRange": { - "fileName": "if_node.bal", - "startLine": { - "line": 15, - "offset": 8 - }, - "endLine": { - "line": 20, - "offset": 9 - } - }, - "sourceCode": "if flag {\n int a = 1;\n } else {\n int b = 2;\n string c = \"12\";\n }" - }, - "returning": false, - "branches": [ - { - "label": "Then", - "kind": "BLOCK", - "codedata": { - "node": "CONDITIONAL", - "lineRange": { - "fileName": "if_node.bal", - "startLine": { - "line": 15, - "offset": 16 - }, - "endLine": { - "line": 17, - "offset": 9 - } - }, - "sourceCode": "{\n int a = 1;\n }" - }, - "repeatable": "ONE_OR_MORE", - "properties": { - "condition": { - "metadata": { - "label": "Condition", - "description": "Boolean Condition" - }, - "valueType": "EXPRESSION", - "value": "flag ", - "placeholder": "true", - "optional": false, - "editable": true, - "advanced": false - } - }, - "children": [] + "codedata": { + "node": "IF", + "lineRange": { + "fileName": "if_node.bal", + "startLine": { + "line": 15, + "offset": 8 }, - { - "label": "self.classVar > ", - "kind": "BLOCK", - "codedata": { - "node": "CONDITIONAL", - "lineRange": { - "fileName": "if_node.bal", - "startLine": { - "line": 17, - "offset": 15 - }, - "endLine": { - "line": 20, - "offset": 9 - } - }, - "sourceCode": "{\n int b = 2;\n string c = \"12\";\n }" - }, - "repeatable": "ONE_OR_MORE", - "properties": { - "condition": { - "metadata": { - "label": "Condition", - "description": "Boolean Condition" - }, - "valueType": "EXPRESSION", - "value": "self.classVar > ", - "valueTypeConstraint": "boolean", - "placeholder": "true", - "optional": false, - "editable": true, - "advanced": false - } - }, - "children": [] + "endLine": { + "line": 20, + "offset": 9 } - ], - "flags": 0 + }, + "sourceCode": "if flag {\n int a = 1;\n } else {\n int b = 2;\n string c = \"12\";\n }" }, "branch": "self.classVar > ", - "property": "condition" + "property": { + "metadata": { + "label": "Condition", + "description": "Boolean Condition" + }, + "valueType": "EXPRESSION", + "value": "self.classVar > ", + "valueTypeConstraint": "boolean", + "placeholder": "true", + "optional": false, + "editable": true, + "advanced": false + } }, "diagnostics": [ { diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/single4.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/single4.json index 63d7755b5..7508afefa 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/single4.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/single4.json @@ -8,105 +8,35 @@ "offset": 8 }, "offset": 0, - "node": { - "id": "47036", - "metadata": { - "label": "If", - "description": "Add conditional branch to the integration flow." - }, - "codedata": { - "node": "IF", - "lineRange": { - "fileName": "if_node.bal", - "startLine": { - "line": 15, - "offset": 8 - }, - "endLine": { - "line": 20, - "offset": 9 - } - }, - "sourceCode": "if flag {\n int a = 1;\n } else {\n int b = 2;\n string c = \"12\";\n }" - }, - "returning": false, - "branches": [ - { - "label": "Then", - "kind": "BLOCK", - "codedata": { - "node": "CONDITIONAL", - "lineRange": { - "fileName": "if_node.bal", - "startLine": { - "line": 15, - "offset": 16 - }, - "endLine": { - "line": 17, - "offset": 9 - } - }, - "sourceCode": "{\n int a = 1;\n }" - }, - "repeatable": "ONE_OR_MORE", - "properties": { - "condition": { - "metadata": { - "label": "Condition", - "description": "Boolean Condition" - }, - "valueType": "EXPRESSION", - "value": "flag ", - "placeholder": "true", - "optional": false, - "editable": true, - "advanced": false - } - }, - "children": [] + "codedata": { + "node": "IF", + "lineRange": { + "fileName": "if_node.bal", + "startLine": { + "line": 15, + "offset": 8 }, - { - "label": "self.classVar > ", - "kind": "BLOCK", - "codedata": { - "node": "CONDITIONAL", - "lineRange": { - "fileName": "if_node.bal", - "startLine": { - "line": 17, - "offset": 15 - }, - "endLine": { - "line": 20, - "offset": 9 - } - }, - "sourceCode": "{\n int b = 2;\n string c = \"12\";\n }" - }, - "repeatable": "ONE_OR_MORE", - "properties": { - "condition": { - "metadata": { - "label": "Condition", - "description": "Boolean Condition" - }, - "valueType": "EXPRESSION", - "value": "self.classVar > ", - "valueTypeConstraint": "boolean", - "placeholder": "true", - "optional": false, - "editable": true, - "advanced": false - } - }, - "children": [] + "endLine": { + "line": 20, + "offset": 9 } - ], - "flags": 0 + }, + "sourceCode": "if flag {\n int a = 1;\n } else {\n int b = 2;\n string c = \"12\";\n }" }, "branch": "self.classVar > ", - "property": "condition" + "property": { + "metadata": { + "label": "Condition", + "description": "Boolean Condition" + }, + "valueType": "EXPRESSION", + "value": "self.classVar > ", + "valueTypeConstraint": "boolean", + "placeholder": "true", + "optional": false, + "editable": true, + "advanced": false + } }, "diagnostics": [ { diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/single5.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/single5.json index 0f986c7f7..558014464 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/single5.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/single5.json @@ -8,105 +8,35 @@ "offset": 8 }, "offset": 0, - "node": { - "id": "47036", - "metadata": { - "label": "If", - "description": "Add conditional branch to the integration flow." - }, - "codedata": { - "node": "IF", - "lineRange": { - "fileName": "if_node.bal", - "startLine": { - "line": 15, - "offset": 8 - }, - "endLine": { - "line": 20, - "offset": 9 - } - }, - "sourceCode": "if flag {\n int a = 1;\n } else {\n int b = 2;\n string c = \"12\";\n }" - }, - "returning": false, - "branches": [ - { - "label": "Then", - "kind": "BLOCK", - "codedata": { - "node": "CONDITIONAL", - "lineRange": { - "fileName": "if_node.bal", - "startLine": { - "line": 15, - "offset": 16 - }, - "endLine": { - "line": 17, - "offset": 9 - } - }, - "sourceCode": "{\n int a = 1;\n }" - }, - "repeatable": "ONE_OR_MORE", - "properties": { - "condition": { - "metadata": { - "label": "Condition", - "description": "Boolean Condition" - }, - "valueType": "EXPRESSION", - "value": "flag ", - "placeholder": "true", - "optional": false, - "editable": true, - "advanced": false - } - }, - "children": [] + "codedata": { + "node": "IF", + "lineRange": { + "fileName": "if_node.bal", + "startLine": { + "line": 15, + "offset": 8 }, - { - "label": "self.classVar > ", - "kind": "BLOCK", - "codedata": { - "node": "CONDITIONAL", - "lineRange": { - "fileName": "if_node.bal", - "startLine": { - "line": 17, - "offset": 15 - }, - "endLine": { - "line": 20, - "offset": 9 - } - }, - "sourceCode": "{\n int b = 2;\n string c = \"12\";\n }" - }, - "repeatable": "ONE_OR_MORE", - "properties": { - "condition": { - "metadata": { - "label": "Condition", - "description": "Boolean Condition" - }, - "valueType": "EXPRESSION", - "value": "self.classVar > ", - "valueTypeConstraint": "boolean", - "placeholder": "true", - "optional": false, - "editable": true, - "advanced": false - } - }, - "children": [] + "endLine": { + "line": 20, + "offset": 9 } - ], - "flags": 0 + }, + "sourceCode": "if flag {\n int a = 1;\n } else {\n int b = 2;\n string c = \"12\";\n }" }, "branch": "self.classVar > ", - "property": "condition" + "property": { + "metadata": { + "label": "Condition", + "description": "Boolean Condition" + }, + "valueType": "EXPRESSION", + "value": "self.classVar > ", + "valueTypeConstraint": "boolean", + "placeholder": "true", + "optional": false, + "editable": true, + "advanced": false + } }, "diagnostics": [ { diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types1.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types1.json index fa43e9a45..b6d2dccd3 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types1.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types1.json @@ -8,67 +8,33 @@ "offset": 0 }, "offset": 2, - "node": { - "id": "32874", - "metadata": { - "label": "Variable", - "description": "Assign a value to a variable" - }, - "codedata": { - "node": "VARIABLE", - "lineRange": { - "fileName": "new_data.bal", - "startLine": { - "line": 1, - "offset": 4 - }, - "endLine": { - "line": 1, - "offset": 14 - } - }, - "sourceCode": "int i = 12;" - }, - "returning": false, - "properties": { - "expression": { - "metadata": { - "label": "Expression", - "description": "Initialize with value" - }, - "valueType": "EXPRESSION", - "value": "12", - "optional": true, - "editable": true, - "advanced": false + "codedata": { + "node": "VARIABLE", + "lineRange": { + "fileName": "new_data.bal", + "startLine": { + "line": 1, + "offset": 4 }, - "variable": { - "metadata": { - "label": "Name", - "description": "Name of the variable" - }, - "valueType": "IDENTIFIER", - "value": "i", - "optional": false, - "editable": true, - "advanced": false - }, - "type": { - "metadata": { - "label": "Type", - "description": "Type of the variable" - }, - "valueType": "TYPE", - "value": "", - "placeholder": "var", - "optional": false, - "editable": true, - "advanced": false + "endLine": { + "line": 1, + "offset": 14 } }, - "flags": 0 + "sourceCode": "int i = 12;" }, - "property": "type" + "property": { + "metadata": { + "label": "Type", + "description": "Type of the variable" + }, + "valueType": "TYPE", + "value": "", + "placeholder": "var", + "optional": false, + "editable": true, + "advanced": false + } }, "diagnostics": [ { diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types2.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types2.json index 188ab750a..2616168c9 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types2.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types2.json @@ -8,67 +8,33 @@ "offset": 0 }, "offset": 4, - "node": { - "id": "32874", - "metadata": { - "label": "Variable", - "description": "Assign a value to a variable" - }, - "codedata": { - "node": "VARIABLE", - "lineRange": { - "fileName": "new_data.bal", - "startLine": { - "line": 1, - "offset": 4 - }, - "endLine": { - "line": 1, - "offset": 14 - } - }, - "sourceCode": "int i = 12;" - }, - "returning": false, - "properties": { - "expression": { - "metadata": { - "label": "Expression", - "description": "Initialize with value" - }, - "valueType": "EXPRESSION", - "value": "12", - "optional": true, - "editable": true, - "advanced": false - }, - "variable": { - "metadata": { - "label": "Name", - "description": "Name of the variable" - }, - "valueType": "IDENTIFIER", - "value": "i", - "optional": false, - "editable": true, - "advanced": false + "codedata": { + "node": "VARIABLE", + "lineRange": { + "fileName": "new_data.bal", + "startLine": { + "line": 1, + "offset": 4 }, - "type": { - "metadata": { - "label": "Type", - "description": "Type of the variable" - }, - "valueType": "TYPE", - "value": "", - "placeholder": "var", - "optional": false, - "editable": true, - "advanced": false + "endLine": { + "line": 1, + "offset": 14 } }, - "flags": 0 + "sourceCode": "int i = 12;" }, - "property": "type" + "property": { + "metadata": { + "label": "Type", + "description": "Type of the variable" + }, + "valueType": "TYPE", + "value": "", + "placeholder": "var", + "optional": false, + "editable": true, + "advanced": false + } }, "diagnostics": [ { diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types3.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types3.json index 885c7a994..ed3dbc2e5 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types3.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types3.json @@ -8,133 +8,42 @@ "offset": 0 }, "offset": 2, - "node": { - "id": "37865", - "metadata": { - "label": "get", - "description": "The `Client.get()` function can be used to send HTTP GET requests to HTTP endpoints.\n", - "icon": "https://bcentral-packageicons.azureedge.net/images/ballerina_http_2.13.2.png" - }, - "codedata": { - "node": "REMOTE_ACTION_CALL", - "org": "ballerina", - "module": "http", - "object": "Client", - "symbol": "get", - "version": "2.13.2", - "lineRange": { - "fileName": "sample.bal", - "startLine": { - "line": 6, - "offset": 4 - }, - "endLine": { - "line": 6, - "offset": 45 - } - }, - "sourceCode": "json val = check httpClient->get(\"/foo\");" - }, - "returning": false, - "properties": { - "connection": { - "metadata": { - "label": "Connection", - "description": "Connection to use" - }, - "valueType": "EXPRESSION", - "value": "httpClient", - "optional": false, - "editable": false, - "advanced": false - }, - "path": { - "metadata": { - "label": "path", - "description": "Request path" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "string", - "value": "\"/foo\"", - "placeholder": "\"\"", - "optional": false, - "editable": true, - "advanced": false, - "codedata": { - "kind": "REQUIRED", - "originalName": "path" - } - }, - "headers": { - "metadata": { - "label": "headers", - "description": "The entity headers" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "map|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "DEFAULTABLE", - "originalName": "headers" - } + "codedata": { + "node": "REMOTE_ACTION_CALL", + "org": "ballerina", + "module": "http", + "object": "Client", + "symbol": "get", + "version": "2.13.2", + "lineRange": { + "fileName": "sample.bal", + "startLine": { + "line": 6, + "offset": 4 }, - "targetType": { - "metadata": { - "label": "targetType", - "description": "HTTP response, `anydata` or stream of HTTP SSE, which is expected to be returned after data binding" - }, - "valueType": "TYPE", - "valueTypeConstraint": "anydata", - "placeholder": "json", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "PARAM_FOR_TYPE_INFER", - "originalName": "targetType" - } - }, - "checkError": { - "metadata": { - "label": "Check Error", - "description": "Trigger error flow" - }, - "valueType": "FLAG", - "value": true, - "optional": false, - "editable": true, - "advanced": true - }, - "variable": { - "metadata": { - "label": "Variable Name", - "description": "Name of the variable" - }, - "valueType": "IDENTIFIER", - "value": "val", - "optional": false, - "editable": true, - "advanced": false - }, - "type": { - "metadata": { - "label": "Variable Type", - "description": "Type of the variable" - }, - "valueType": "TYPE", - "value": "json", - "placeholder": "var", - "optional": false, - "editable": true, - "advanced": false + "endLine": { + "line": 6, + "offset": 45 } }, - "flags": 1 + "sourceCode": "json val = check httpClient->get(\"/foo\");" }, - "property": "targetType" + "property": { + "metadata": { + "label": "targetType", + "description": "HTTP response, `anydata` or stream of HTTP SSE, which is expected to be returned after data binding" + }, + "valueType": "TYPE", + "valueTypeConstraint": "anydata", + "placeholder": "json", + "optional": true, + "editable": true, + "advanced": true, + "codedata": { + "kind": "PARAM_FOR_TYPE_INFER", + "originalName": "targetType" + } + } }, "diagnostics": [ { diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types4.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types4.json index e29b705b9..d72acb43d 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types4.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types4.json @@ -8,133 +8,42 @@ "offset": 0 }, "offset": 2, - "node": { - "id": "37865", - "metadata": { - "label": "get", - "description": "The `Client.get()` function can be used to send HTTP GET requests to HTTP endpoints.\n", - "icon": "https://bcentral-packageicons.azureedge.net/images/ballerina_http_2.13.2.png" - }, - "codedata": { - "node": "REMOTE_ACTION_CALL", - "org": "ballerina", - "module": "http", - "object": "Client", - "symbol": "get", - "version": "2.13.2", - "lineRange": { - "fileName": "sample.bal", - "startLine": { - "line": 6, - "offset": 4 - }, - "endLine": { - "line": 6, - "offset": 45 - } - }, - "sourceCode": "json val = check httpClient->get(\"/foo\");" - }, - "returning": false, - "properties": { - "connection": { - "metadata": { - "label": "Connection", - "description": "Connection to use" - }, - "valueType": "EXPRESSION", - "value": "httpClient", - "optional": false, - "editable": false, - "advanced": false - }, - "path": { - "metadata": { - "label": "path", - "description": "Request path" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "string", - "value": "\"/foo\"", - "placeholder": "\"\"", - "optional": false, - "editable": true, - "advanced": false, - "codedata": { - "kind": "REQUIRED", - "originalName": "path" - } - }, - "headers": { - "metadata": { - "label": "headers", - "description": "The entity headers" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "map|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "DEFAULTABLE", - "originalName": "headers" - } + "codedata": { + "node": "REMOTE_ACTION_CALL", + "org": "ballerina", + "module": "http", + "object": "Client", + "symbol": "get", + "version": "2.13.2", + "lineRange": { + "fileName": "sample.bal", + "startLine": { + "line": 6, + "offset": 4 }, - "targetType": { - "metadata": { - "label": "targetType", - "description": "HTTP response, `anydata` or stream of HTTP SSE, which is expected to be returned after data binding" - }, - "valueType": "TYPE", - "valueTypeConstraint": "anydata", - "placeholder": "json", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "PARAM_FOR_TYPE_INFER", - "originalName": "targetType" - } - }, - "checkError": { - "metadata": { - "label": "Check Error", - "description": "Trigger error flow" - }, - "valueType": "FLAG", - "value": true, - "optional": false, - "editable": true, - "advanced": true - }, - "variable": { - "metadata": { - "label": "Variable Name", - "description": "Name of the variable" - }, - "valueType": "IDENTIFIER", - "value": "val", - "optional": false, - "editable": true, - "advanced": false - }, - "type": { - "metadata": { - "label": "Variable Type", - "description": "Type of the variable" - }, - "valueType": "TYPE", - "value": "json", - "placeholder": "var", - "optional": false, - "editable": true, - "advanced": false + "endLine": { + "line": 6, + "offset": 45 } }, - "flags": 1 + "sourceCode": "json val = check httpClient->get(\"/foo\");" }, - "property": "targetType" + "property": { + "metadata": { + "label": "targetType", + "description": "HTTP response, `anydata` or stream of HTTP SSE, which is expected to be returned after data binding" + }, + "valueType": "TYPE", + "valueTypeConstraint": "anydata", + "placeholder": "json", + "optional": true, + "editable": true, + "advanced": true, + "codedata": { + "kind": "PARAM_FOR_TYPE_INFER", + "originalName": "targetType" + } + } }, "diagnostics": [] } diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types5.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types5.json index 1ac3f8f13..08ad46cbd 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types5.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types5.json @@ -8,133 +8,42 @@ "offset": 0 }, "offset": 2, - "node": { - "id": "37865", - "metadata": { - "label": "get", - "description": "The `Client.get()` function can be used to send HTTP GET requests to HTTP endpoints.\n", - "icon": "https://bcentral-packageicons.azureedge.net/images/ballerina_http_2.13.2.png" - }, - "codedata": { - "node": "REMOTE_ACTION_CALL", - "org": "ballerina", - "module": "http", - "object": "Client", - "symbol": "get", - "version": "2.13.2", - "lineRange": { - "fileName": "sample.bal", - "startLine": { - "line": 6, - "offset": 4 - }, - "endLine": { - "line": 6, - "offset": 45 - } - }, - "sourceCode": "json val = check httpClient->get(\"/foo\");" - }, - "returning": false, - "properties": { - "connection": { - "metadata": { - "label": "Connection", - "description": "Connection to use" - }, - "valueType": "EXPRESSION", - "value": "httpClient", - "optional": false, - "editable": false, - "advanced": false - }, - "path": { - "metadata": { - "label": "path", - "description": "Request path" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "string", - "value": "\"/foo\"", - "placeholder": "\"\"", - "optional": false, - "editable": true, - "advanced": false, - "codedata": { - "kind": "REQUIRED", - "originalName": "path" - } - }, - "headers": { - "metadata": { - "label": "headers", - "description": "The entity headers" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "map|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "DEFAULTABLE", - "originalName": "headers" - } + "codedata": { + "node": "REMOTE_ACTION_CALL", + "org": "ballerina", + "module": "http", + "object": "Client", + "symbol": "get", + "version": "2.13.2", + "lineRange": { + "fileName": "sample.bal", + "startLine": { + "line": 6, + "offset": 4 }, - "targetType": { - "metadata": { - "label": "targetType", - "description": "HTTP response, `anydata` or stream of HTTP SSE, which is expected to be returned after data binding" - }, - "valueType": "TYPE", - "valueTypeConstraint": "anydata", - "placeholder": "json", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "PARAM_FOR_TYPE_INFER", - "originalName": "targetType" - } - }, - "checkError": { - "metadata": { - "label": "Check Error", - "description": "Trigger error flow" - }, - "valueType": "FLAG", - "value": true, - "optional": false, - "editable": true, - "advanced": true - }, - "variable": { - "metadata": { - "label": "Variable Name", - "description": "Name of the variable" - }, - "valueType": "IDENTIFIER", - "value": "val", - "optional": false, - "editable": true, - "advanced": false - }, - "type": { - "metadata": { - "label": "Variable Type", - "description": "Type of the variable" - }, - "valueType": "TYPE", - "value": "json", - "placeholder": "var", - "optional": false, - "editable": true, - "advanced": false + "endLine": { + "line": 6, + "offset": 45 } }, - "flags": 1 + "sourceCode": "json val = check httpClient->get(\"/foo\");" }, - "property": "targetType" + "property": { + "metadata": { + "label": "targetType", + "description": "HTTP response, `anydata` or stream of HTTP SSE, which is expected to be returned after data binding" + }, + "valueType": "TYPE", + "valueTypeConstraint": "anydata", + "placeholder": "json", + "optional": true, + "editable": true, + "advanced": true, + "codedata": { + "kind": "PARAM_FOR_TYPE_INFER", + "originalName": "targetType" + } + } }, "diagnostics": [ { diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types6.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types6.json index 623347b9e..7e4ff8cbc 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types6.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types6.json @@ -8,67 +8,33 @@ "offset": 0 }, "offset": 2, - "node": { - "id": "33757", - "metadata": { - "label": "Config", - "description": "Create a configurable variable" - }, - "codedata": { - "node": "CONFIG_VARIABLE", - "lineRange": { - "fileName": "sample.bal", - "startLine": { - "line": 2, - "offset": 0 - }, - "endLine": { - "line": 2, - "offset": 29 - } - } - }, - "returning": false, - "properties": { - "type": { - "metadata": { - "label": "Variable Type", - "description": "Type of the variable" - }, - "valueType": "TYPE", - "value": "int", - "valueTypeConstraint": "anydata", - "placeholder": "var", - "optional": false, - "editable": true, - "advanced": false + "codedata": { + "node": "CONFIG_VARIABLE", + "lineRange": { + "fileName": "sample.bal", + "startLine": { + "line": 2, + "offset": 0 }, - "variable": { - "metadata": { - "label": "Variable Name", - "description": "Name of the variable" - }, - "valueType": "IDENTIFIER", - "value": "port", - "optional": false, - "editable": true, - "advanced": false - }, - "defaultable": { - "metadata": { - "label": "Default value", - "description": "Default value for the config, if empty your need to provide a value at runtime" - }, - "valueType": "EXPRESSION", - "value": "8080", - "optional": true, - "editable": true, - "advanced": false + "endLine": { + "line": 2, + "offset": 29 } - }, - "flags": 0 + } }, - "property": "type" + "property": { + "metadata": { + "label": "Variable Type", + "description": "Type of the variable" + }, + "valueType": "TYPE", + "value": "int", + "valueTypeConstraint": "anydata", + "placeholder": "var", + "optional": false, + "editable": true, + "advanced": false + } }, "diagnostics": [] } diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types7.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types7.json index b275de55f..aedfa99d4 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types7.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types7.json @@ -8,67 +8,33 @@ "offset": 0 }, "offset": 2, - "node": { - "id": "33757", - "metadata": { - "label": "Config", - "description": "Create a configurable variable" - }, - "codedata": { - "node": "CONFIG_VARIABLE", - "lineRange": { - "fileName": "sample.bal", - "startLine": { - "line": 2, - "offset": 0 - }, - "endLine": { - "line": 2, - "offset": 29 - } - } - }, - "returning": false, - "properties": { - "type": { - "metadata": { - "label": "Variable Type", - "description": "Type of the variable" - }, - "valueType": "TYPE", - "value": "int", - "valueTypeConstraint": "anydata", - "placeholder": "var", - "optional": false, - "editable": true, - "advanced": false - }, - "variable": { - "metadata": { - "label": "Variable Name", - "description": "Name of the variable" - }, - "valueType": "IDENTIFIER", - "value": "port", - "optional": false, - "editable": true, - "advanced": false + "codedata": { + "node": "CONFIG_VARIABLE", + "lineRange": { + "fileName": "sample.bal", + "startLine": { + "line": 2, + "offset": 0 }, - "defaultable": { - "metadata": { - "label": "Default value", - "description": "Default value for the config, if empty your need to provide a value at runtime" - }, - "valueType": "EXPRESSION", - "value": "8080", - "optional": true, - "editable": true, - "advanced": false + "endLine": { + "line": 2, + "offset": 29 } - }, - "flags": 0 + } }, - "property": "type" + "property": { + "metadata": { + "label": "Variable Type", + "description": "Type of the variable" + }, + "valueType": "TYPE", + "value": "int", + "valueTypeConstraint": "anydata", + "placeholder": "var", + "optional": false, + "editable": true, + "advanced": false + } }, "diagnostics": [ { diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types8.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types8.json index 8303a9458..53691224a 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types8.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types8.json @@ -8,68 +8,34 @@ "offset": 0 }, "offset": 2, - "node": { - "id": "32874", - "metadata": { - "label": "Variable", - "description": "Assign a value to a variable" - }, - "codedata": { - "node": "VARIABLE", - "lineRange": { - "fileName": "new_data.bal", - "startLine": { - "line": 1, - "offset": 4 - }, - "endLine": { - "line": 1, - "offset": 14 - } - }, - "sourceCode": "int i = 12;" - }, - "returning": false, - "properties": { - "expression": { - "metadata": { - "label": "Expression", - "description": "Initialize with value" - }, - "valueType": "EXPRESSION", - "value": "12", - "optional": true, - "editable": true, - "advanced": false + "codedata": { + "node": "VARIABLE", + "lineRange": { + "fileName": "new_data.bal", + "startLine": { + "line": 1, + "offset": 4 }, - "variable": { - "metadata": { - "label": "Name", - "description": "Name of the variable" - }, - "valueType": "IDENTIFIER", - "value": "i", - "optional": false, - "editable": true, - "advanced": false - }, - "type": { - "metadata": { - "label": "Type", - "description": "Type of the variable" - }, - "valueType": "TYPE", - "value": "", - "valueTypeConstraint": "string", - "placeholder": "var", - "optional": false, - "editable": true, - "advanced": false + "endLine": { + "line": 1, + "offset": 14 } }, - "flags": 0 + "sourceCode": "int i = 12;" }, - "property": "type" + "property": { + "metadata": { + "label": "Type", + "description": "Type of the variable" + }, + "valueType": "TYPE", + "value": "", + "valueTypeConstraint": "string", + "placeholder": "var", + "optional": false, + "editable": true, + "advanced": false + } }, "diagnostics": [] } diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types9.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types9.json index ab143b66e..0a13ec5bb 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types9.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/types9.json @@ -8,68 +8,34 @@ "offset": 0 }, "offset": 2, - "node": { - "id": "32874", - "metadata": { - "label": "Variable", - "description": "Assign a value to a variable" - }, - "codedata": { - "node": "VARIABLE", - "lineRange": { - "fileName": "new_data.bal", - "startLine": { - "line": 1, - "offset": 4 - }, - "endLine": { - "line": 1, - "offset": 14 - } - }, - "sourceCode": "int i = 12;" - }, - "returning": false, - "properties": { - "expression": { - "metadata": { - "label": "Expression", - "description": "Initialize with value" - }, - "valueType": "EXPRESSION", - "value": "12", - "optional": true, - "editable": true, - "advanced": false - }, - "variable": { - "metadata": { - "label": "Name", - "description": "Name of the variable" - }, - "valueType": "IDENTIFIER", - "value": "i", - "optional": false, - "editable": true, - "advanced": false + "codedata": { + "node": "VARIABLE", + "lineRange": { + "fileName": "new_data.bal", + "startLine": { + "line": 1, + "offset": 4 }, - "type": { - "metadata": { - "label": "Type", - "description": "Type of the variable" - }, - "valueType": "TYPE", - "value": "", - "valueTypeConstraint": "string", - "placeholder": "var", - "optional": false, - "editable": true, - "advanced": false + "endLine": { + "line": 1, + "offset": 14 } }, - "flags": 0 + "sourceCode": "int i = 12;" }, - "property": "type" + "property": { + "metadata": { + "label": "Type", + "description": "Type of the variable" + }, + "valueType": "TYPE", + "value": "", + "valueTypeConstraint": "string", + "placeholder": "var", + "optional": false, + "editable": true, + "advanced": false + } }, "diagnostics": [ { diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/variable1.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/variable1.json index 6111a9784..9b84b0e59 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/variable1.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/variable1.json @@ -8,67 +8,32 @@ "offset": 0 }, "offset": 2, - "node": { - "id": "32874", - "metadata": { - "label": "Variable", - "description": "Assign a value to a variable" - }, - "codedata": { - "node": "VARIABLE", - "lineRange": { - "fileName": "new_data.bal", - "startLine": { - "line": 1, - "offset": 4 - }, - "endLine": { - "line": 1, - "offset": 14 - } - }, - "sourceCode": "int i = 12;" - }, - "returning": false, - "properties": { - "expression": { - "metadata": { - "label": "Expression", - "description": "Initialize with value" - }, - "valueType": "EXPRESSION", - "value": "12", - "optional": true, - "editable": true, - "advanced": false + "codedata": { + "node": "VARIABLE", + "lineRange": { + "fileName": "new_data.bal", + "startLine": { + "line": 1, + "offset": 4 }, - "variable": { - "metadata": { - "label": "Name", - "description": "Name of the variable" - }, - "valueType": "IDENTIFIER", - "value": "i", - "optional": false, - "editable": true, - "advanced": false - }, - "type": { - "metadata": { - "label": "Type", - "description": "Type of the variable" - }, - "valueType": "TYPE", - "value": "", - "placeholder": "var", - "optional": false, - "editable": true, - "advanced": false + "endLine": { + "line": 1, + "offset": 14 } }, - "flags": 0 + "sourceCode": "int i = 12;" }, - "property": "expression" + "property": { + "metadata": { + "label": "Expression", + "description": "Initialize with value" + }, + "valueType": "EXPRESSION", + "value": "12", + "optional": true, + "editable": true, + "advanced": false + } }, "diagnostics": [] } diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/variable2.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/variable2.json index 8d5e7abec..5751cdf32 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/variable2.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/variable2.json @@ -8,55 +8,20 @@ "offset": 24 }, "offset": 0, - "node": { - "id": "31", + "codedata": { + "node": "VARIABLE" + }, + "property": { "metadata": { - "label": "Variable", - "description": "New variable with type" - }, - "codedata": { - "node": "VARIABLE" + "label": "Expression", + "description": "Initialize with value" }, - "returning": false, - "properties": { - "variable": { - "metadata": { - "label": "Name", - "description": "Name of the variable" - }, - "valueType": "IDENTIFIER", - "value": "var1", - "optional": false, - "editable": true, - "advanced": false - }, - "type": { - "metadata": { - "label": "Type", - "description": "Type of the variable" - }, - "valueType": "TYPE", - "value": "var", - "placeholder": "var", - "optional": false, - "editable": true, - "advanced": false - }, - "expression": { - "metadata": { - "label": "Expression", - "description": "Initialize with value" - }, - "valueType": "EXPRESSION", - "value": "text", - "optional": true, - "editable": true, - "advanced": false - } - }, - "flags": 0 - }, - "property": "expression" + "valueType": "EXPRESSION", + "value": "text", + "optional": true, + "editable": true, + "advanced": false + } }, "diagnostics": [] } From 38f0e9863de55d0634bf9b0c7ab54fb821fc2715 Mon Sep 17 00:00:00 2001 From: Nipuna Fernando Date: Thu, 27 Feb 2025 00:16:22 +0530 Subject: [PATCH 2/5] Update the completion test cases --- .../ExpressionEditorContext.java | 3 +- .../resources/completions/config/config.json | 180 ++------- .../resources/completions/config/proj1.json | 6 +- .../resources/completions/config/proj2.json | 6 +- .../resources/completions/config/proj3.json | 134 +++---- .../resources/completions/config/proj4.json | 193 ++-------- .../resources/completions/config/proj5.json | 110 ++---- .../resources/completions/config/proj6.json | 355 ++---------------- .../resources/completions/config/proj7.json | 144 ++----- .../resources/completions/config/proj8.json | 81 ++-- 10 files changed, 230 insertions(+), 982 deletions(-) diff --git a/flow-model-generator/modules/flow-model-generator-core/src/main/java/io/ballerina/flowmodelgenerator/core/expressioneditor/ExpressionEditorContext.java b/flow-model-generator/modules/flow-model-generator-core/src/main/java/io/ballerina/flowmodelgenerator/core/expressioneditor/ExpressionEditorContext.java index 1773aa229..6bc1b75e4 100644 --- a/flow-model-generator/modules/flow-model-generator-core/src/main/java/io/ballerina/flowmodelgenerator/core/expressioneditor/ExpressionEditorContext.java +++ b/flow-model-generator/modules/flow-model-generator-core/src/main/java/io/ballerina/flowmodelgenerator/core/expressioneditor/ExpressionEditorContext.java @@ -87,7 +87,8 @@ public ExpressionEditorContext(WorkspaceManagerProxy workspaceManagerProxy, Stri } public boolean isNodeKind(List nodeKinds) { - return nodeKinds.contains(property.nodeKind()); + NodeKind nodeKind = property.nodeKind(); + return nodeKind != null && nodeKinds.contains(nodeKind); } public LinePosition getStartLine() { diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/config.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/config.json index 7c4b8e257..b87ebd11c 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/config.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/config.json @@ -3,162 +3,36 @@ "filePath": "source.bal", "context": { "expression": "self.classVar > local + 21", - "branch": "self.classVar > l", - "property": "condition", - "startLine": { - "line": 13, - "offset": 8 - }, - "offset": 22, - "node": { - "id": "45021", + "property": { "metadata": { - "label": "If", - "description": "Add conditional branch to the integration flow." + "label": "Condition", + "description": "Boolean Condition" }, - "codedata": { - "node": "IF", - "lineRange": { - "fileName": "test.bal", - "startLine": { - "line": 13, - "offset": 8 - }, - "endLine": { - "line": 17, - "offset": 9 - } + "valueType": "EXPRESSION", + "value": "(moduleVar > 11) ", + "optional": false, + "editable": true + }, + "codedata": { + "node": "IF", + "lineRange": { + "fileName": "test.bal", + "startLine": { + "line": 13, + "offset": 8 }, - "sourceCode": "if (moduleVar > 11) {\n int i = 32;\n } else if self.classVar > l {\n\n }" - }, - "returning": false, - "branches": [ - { - "label": "Then", - "kind": "BLOCK", - "codedata": { - "node": "CONDITIONAL", - "lineRange": { - "fileName": "test.bal", - "startLine": { - "line": 13, - "offset": 28 - }, - "endLine": { - "line": 15, - "offset": 9 - } - }, - "sourceCode": "{\n int i = 32;\n }" - }, - "repeatable": "ONE_OR_MORE", - "properties": { - "condition": { - "metadata": { - "label": "Condition", - "description": "Boolean Condition" - }, - "valueType": "EXPRESSION", - "value": "(moduleVar > 11) ", - "optional": false, - "editable": true - } - }, - "children": [ - { - "id": "46027", - "metadata": { - "label": "New Variable", - "description": "New variable 'i' with type 'int'" - }, - "codedata": { - "node": "NEW_DATA", - "lineRange": { - "fileName": "test.bal", - "startLine": { - "line": 14, - "offset": 12 - }, - "endLine": { - "line": 14, - "offset": 23 - } - }, - "sourceCode": "int i = 32;" - }, - "returning": false, - "properties": { - "expression": { - "metadata": { - "label": "Expression", - "description": "Expression" - }, - "valueType": "EXPRESSION", - "value": "32", - "optional": false, - "editable": true - }, - "variable": { - "metadata": { - "label": "Data variable", - "description": "Name of the variable" - }, - "valueType": "IDENTIFIER", - "value": "i", - "optional": false, - "editable": true - }, - "type": { - "metadata": { - "label": "Data type", - "description": "Type of the variable" - }, - "valueType": "TYPE", - "value": "int", - "optional": false, - "editable": true - } - }, - "flags": 0 - } - ] - }, - { - "label": "self.classVar > l", - "kind": "BLOCK", - "codedata": { - "node": "CONDITIONAL", - "lineRange": { - "fileName": "test.bal", - "startLine": { - "line": 15, - "offset": 36 - }, - "endLine": { - "line": 17, - "offset": 9 - } - }, - "sourceCode": "{\n\n }" - }, - "repeatable": "ONE_OR_MORE", - "properties": { - "condition": { - "metadata": { - "label": "Condition", - "description": "Boolean Condition" - }, - "valueType": "EXPRESSION", - "value": "self.classVar > l ", - "optional": false, - "editable": true - } - }, - "children": [] + "endLine": { + "line": 17, + "offset": 9 } - ], - "flags": 0 - } + }, + "sourceCode": "if (moduleVar > 11) {\n int i = 32;\n } else if self.classVar > l {\n\n }" + }, + "startLine": { + "line": 13, + "offset": 8 + }, + "offset": 22 }, "completionContext": { "triggerKind": "Invoked" @@ -636,4 +510,4 @@ "insertTextFormat": "Snippet" } ] -} +} \ No newline at end of file diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj1.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj1.json index 9caf06800..2f61dcb25 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj1.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj1.json @@ -8,7 +8,7 @@ "offset": 4 }, "offset": 2, - "node": {} + "property": {} }, "completionContext": { "triggerKind": "Invoked" @@ -71,7 +71,7 @@ "label": "error", "kind": "Event", "detail": "Error", - "sortText": "AL", + "sortText": "P", "insertText": "error", "insertTextFormat": "Snippet" }, @@ -535,7 +535,7 @@ "value": "**Package:** _nipunaf/proj:0.1.0_ \n \nPerforms a safe division operation.\n\nThis function divides the given numerator by the denominator and returns the result.\nIf the denominator is zero, it returns an error indicating a division by zero.\n \n**Params** \n- `float` a: The numerator of type `float`. \n- `float` b: The denominator of type `float`.\n\n# Returns\n- `float` - The result of the division if the denominator is not zero.\n- `error` - An error indicating division by zero if the denominator is zero.\n \n \n**Return** `float|error` \n- The result of the division or an error. \n \n" } }, - "sortText": "AC", + "sortText": "G", "filterText": "safeDivide", "insertText": "safeDivide(${1})", "insertTextFormat": "Snippet", diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj2.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj2.json index e5c6b07cb..cc572d04d 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj2.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj2.json @@ -8,7 +8,7 @@ "offset": 33 }, "offset": 2, - "node": {} + "property": {} }, "completionContext": { "triggerKind": "Invoked" @@ -71,7 +71,7 @@ "label": "error", "kind": "Event", "detail": "Error", - "sortText": "AL", + "sortText": "P", "insertText": "error", "insertTextFormat": "Snippet" }, @@ -543,7 +543,7 @@ "value": "**Package:** _nipunaf/proj:0.1.0_ \n \nPerforms a safe division operation.\n\nThis function divides the given numerator by the denominator and returns the result.\nIf the denominator is zero, it returns an error indicating a division by zero.\n \n**Params** \n- `float` a: The numerator of type `float`. \n- `float` b: The denominator of type `float`.\n\n# Returns\n- `float` - The result of the division if the denominator is not zero.\n- `error` - An error indicating division by zero if the denominator is zero.\n \n \n**Return** `float|error` \n- The result of the division or an error. \n \n" } }, - "sortText": "AC", + "sortText": "G", "filterText": "safeDivide", "insertText": "safeDivide(${1})", "insertTextFormat": "Snippet", diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj3.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj3.json index 492acf768..61861936e 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj3.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj3.json @@ -7,8 +7,7 @@ "line": 33, "offset": 4 }, - "offset": 1, - "node": {} + "offset": 1 }, "completionContext": { "triggerKind": "Invoked" @@ -18,7 +17,7 @@ "label": "decimal", "kind": "TypeParameter", "detail": "Decimal", - "sortText": "P", + "sortText": "BN", "insertText": "decimal", "insertTextFormat": "Snippet" }, @@ -26,7 +25,7 @@ "label": "error", "kind": "Event", "detail": "Error", - "sortText": "N", + "sortText": "BL", "insertText": "error", "insertTextFormat": "Snippet" }, @@ -34,7 +33,7 @@ "label": "object", "kind": "Unit", "detail": "type", - "sortText": "R", + "sortText": "ARR", "insertText": "object", "insertTextFormat": "Snippet" }, @@ -42,7 +41,7 @@ "label": "transaction", "kind": "Unit", "detail": "type", - "sortText": "R", + "sortText": "ARR", "insertText": "transaction", "insertTextFormat": "Snippet" }, @@ -50,7 +49,7 @@ "label": "xml", "kind": "TypeParameter", "detail": "Xml", - "sortText": "P", + "sortText": "BN", "insertText": "xml", "insertTextFormat": "Snippet" }, @@ -58,7 +57,7 @@ "label": "table", "kind": "Unit", "detail": "type", - "sortText": "R", + "sortText": "ARR", "insertText": "table", "insertTextFormat": "Snippet" }, @@ -66,7 +65,7 @@ "label": "map", "kind": "Unit", "detail": "type", - "sortText": "R", + "sortText": "ARR", "insertText": "map", "insertTextFormat": "Snippet" }, @@ -74,7 +73,7 @@ "label": "stream", "kind": "Unit", "detail": "type", - "sortText": "R", + "sortText": "ARR", "insertText": "stream", "insertTextFormat": "Snippet" }, @@ -82,7 +81,7 @@ "label": "boolean", "kind": "TypeParameter", "detail": "Boolean", - "sortText": "P", + "sortText": "BN", "insertText": "boolean", "insertTextFormat": "Snippet" }, @@ -90,7 +89,7 @@ "label": "future", "kind": "TypeParameter", "detail": "Future", - "sortText": "P", + "sortText": "BN", "insertText": "future", "insertTextFormat": "Snippet" }, @@ -98,7 +97,7 @@ "label": "int", "kind": "TypeParameter", "detail": "Int", - "sortText": "P", + "sortText": "BN", "insertText": "int", "insertTextFormat": "Snippet" }, @@ -106,7 +105,7 @@ "label": "float", "kind": "TypeParameter", "detail": "Float", - "sortText": "P", + "sortText": "BN", "insertText": "float", "insertTextFormat": "Snippet" }, @@ -114,7 +113,7 @@ "label": "function", "kind": "TypeParameter", "detail": "Function", - "sortText": "P", + "sortText": "BN", "insertText": "function", "insertTextFormat": "Snippet" }, @@ -122,7 +121,7 @@ "label": "string", "kind": "TypeParameter", "detail": "String", - "sortText": "P", + "sortText": "BN", "insertText": "string", "insertTextFormat": "Snippet" }, @@ -130,7 +129,7 @@ "label": "typedesc", "kind": "TypeParameter", "detail": "Typedesc", - "sortText": "P", + "sortText": "BN", "insertText": "typedesc", "insertTextFormat": "Snippet" }, @@ -138,7 +137,7 @@ "label": "service", "kind": "Keyword", "detail": "Keyword", - "sortText": "S", + "sortText": "AUQ", "filterText": "service", "insertText": "service", "insertTextFormat": "Snippet" @@ -147,7 +146,7 @@ "label": "new", "kind": "Keyword", "detail": "Keyword", - "sortText": "S", + "sortText": "AUQ", "filterText": "new", "insertText": "new ", "insertTextFormat": "Snippet" @@ -156,7 +155,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "S", + "sortText": "AUQ", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -165,7 +164,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "S", + "sortText": "AUQ", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -174,7 +173,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "S", + "sortText": "AUQ", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -183,7 +182,7 @@ "label": "let", "kind": "Keyword", "detail": "Keyword", - "sortText": "S", + "sortText": "AUQ", "filterText": "let", "insertText": "let", "insertTextFormat": "Snippet" @@ -192,7 +191,7 @@ "label": "typeof", "kind": "Keyword", "detail": "Keyword", - "sortText": "S", + "sortText": "AUQ", "filterText": "typeof", "insertText": "typeof ", "insertTextFormat": "Snippet" @@ -201,7 +200,7 @@ "label": "trap", "kind": "Keyword", "detail": "Keyword", - "sortText": "S", + "sortText": "AUQ", "filterText": "trap", "insertText": "trap", "insertTextFormat": "Snippet" @@ -210,7 +209,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "S", + "sortText": "AUQ", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -219,7 +218,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "S", + "sortText": "AUQ", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -228,7 +227,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "S", + "sortText": "AUQ", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -237,7 +236,7 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "S", + "sortText": "AUQ", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" @@ -246,7 +245,7 @@ "label": "check", "kind": "Keyword", "detail": "Keyword", - "sortText": "S", + "sortText": "AUQ", "filterText": "check", "insertText": "check ", "insertTextFormat": "Snippet" @@ -255,7 +254,7 @@ "label": "checkpanic", "kind": "Keyword", "detail": "Keyword", - "sortText": "S", + "sortText": "AUQ", "filterText": "checkpanic", "insertText": "checkpanic ", "insertTextFormat": "Snippet" @@ -264,7 +263,7 @@ "label": "is", "kind": "Keyword", "detail": "Keyword", - "sortText": "S", + "sortText": "AUQ", "filterText": "is", "insertText": "is", "insertTextFormat": "Snippet" @@ -273,7 +272,7 @@ "label": "error constructor", "kind": "Snippet", "detail": "Snippet", - "sortText": "R", + "sortText": "ATP", "filterText": "error", "insertText": "error(\"${1}\")", "insertTextFormat": "Snippet" @@ -282,7 +281,7 @@ "label": "object constructor", "kind": "Snippet", "detail": "Snippet", - "sortText": "R", + "sortText": "ATP", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -291,7 +290,7 @@ "label": "base16", "kind": "Snippet", "detail": "Snippet", - "sortText": "R", + "sortText": "ATP", "filterText": "base16", "insertText": "base16 `${1}`", "insertTextFormat": "Snippet" @@ -300,7 +299,7 @@ "label": "base64", "kind": "Snippet", "detail": "Snippet", - "sortText": "R", + "sortText": "ATP", "filterText": "base64", "insertText": "base64 `${1}`", "insertTextFormat": "Snippet" @@ -309,7 +308,7 @@ "label": "from", "kind": "Keyword", "detail": "Keyword", - "sortText": "S", + "sortText": "AUQ", "filterText": "from", "insertText": "from ", "insertTextFormat": "Snippet" @@ -318,7 +317,7 @@ "label": "re ``", "kind": "Snippet", "detail": "Snippet", - "sortText": "R", + "sortText": "ATP", "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" @@ -327,7 +326,7 @@ "label": "string ``", "kind": "Snippet", "detail": "Snippet", - "sortText": "R", + "sortText": "ATP", "filterText": "string ``", "insertText": "string `${1}`", "insertTextFormat": "Snippet" @@ -336,7 +335,7 @@ "label": "xml ``", "kind": "Snippet", "detail": "Snippet", - "sortText": "R", + "sortText": "ATP", "filterText": "xml ``", "insertText": "xml `${1}`", "insertTextFormat": "Snippet" @@ -345,7 +344,7 @@ "label": "Address", "kind": "Struct", "detail": "Record", - "sortText": "O", + "sortText": "BM", "insertText": "Address", "insertTextFormat": "Snippet" }, @@ -353,7 +352,7 @@ "label": "Admission", "kind": "Struct", "detail": "Record", - "sortText": "O", + "sortText": "BM", "insertText": "Admission", "insertTextFormat": "Snippet" }, @@ -361,7 +360,7 @@ "label": "Employee", "kind": "Struct", "detail": "Record", - "sortText": "O", + "sortText": "BM", "insertText": "Employee", "insertTextFormat": "Snippet" }, @@ -369,7 +368,7 @@ "label": "Location", "kind": "Struct", "detail": "Record", - "sortText": "O", + "sortText": "BM", "insertText": "Location", "insertTextFormat": "Snippet" }, @@ -377,7 +376,7 @@ "label": "MyOk", "kind": "Struct", "detail": "Record", - "sortText": "O", + "sortText": "BM", "insertText": "MyOk", "insertTextFormat": "Snippet" }, @@ -385,7 +384,7 @@ "label": "Person", "kind": "Struct", "detail": "Record", - "sortText": "O", + "sortText": "BM", "insertText": "Person", "insertTextFormat": "Snippet" }, @@ -396,7 +395,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "O", + "sortText": "BM", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -404,7 +403,7 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "P", + "sortText": "BN", "insertText": "Thread", "insertTextFormat": "Snippet" }, @@ -418,7 +417,7 @@ "value": "**Package:** _nipunaf/proj:0.1.0_ \n \nAdds two integers and returns the result.\n\n```\nint result = add(5, 3);\n// result will be 8\n``` \n**Params** \n- `int` a: The first integer to be added \n- `int` b: The second integer to be added\n \n \n**Return** `int` \n- The sum of the two integers \n \n# Example \n \n" } }, - "sortText": "E", + "sortText": "AACC", "filterText": "add", "insertText": "add(${1})", "insertTextFormat": "Snippet", @@ -437,7 +436,7 @@ "value": "**Package:** _nipunaf/proj:0.1.0_ \n \n \n**Params** \n- `string` name \n \n**Return** `string` \n \n" } }, - "sortText": "E", + "sortText": "AACC", "filterText": "greet", "insertText": "greet(${1})", "insertTextFormat": "Snippet", @@ -456,7 +455,7 @@ "value": "**Package:** _nipunaf/proj:0.1.0_ \n \n \n" } }, - "sortText": "ZB", + "sortText": "AAZZ", "filterText": "main", "insertText": "main()", "insertTextFormat": "Snippet" @@ -465,7 +464,7 @@ "label": "numbers", "kind": "Variable", "detail": "int[]", - "sortText": "D", + "sortText": "AABB", "insertText": "numbers", "insertTextFormat": "Snippet" }, @@ -479,7 +478,7 @@ "value": "**Package:** _nipunaf/proj:0.1.0_ \n \nComputes the prefix sum of an array of integers.\n\nThe prefix sum of an array is a new array where each element at index `i` is the sum of the elements\nfrom the start of the array up to index `i`.\n \n**Params** \n- `int[]` numbers: The array of integers for which the prefix sum is to be computed. \n \n**Return** `int[]` \n- An array of integers representing the prefix sum of the input array. \n \n" } }, - "sortText": "E", + "sortText": "AACC", "filterText": "prefixSum", "insertText": "prefixSum(${1})", "insertTextFormat": "Snippet", @@ -498,7 +497,7 @@ "value": "**Package:** _nipunaf/proj:0.1.0_ \n \nPerforms a safe division operation.\n\nThis function divides the given numerator by the denominator and returns the result.\nIf the denominator is zero, it returns an error indicating a division by zero.\n \n**Params** \n- `float` a: The numerator of type `float`. \n- `float` b: The denominator of type `float`.\n\n# Returns\n- `float` - The result of the division if the denominator is not zero.\n- `error` - An error indicating division by zero if the denominator is zero.\n \n \n**Return** `float|error` \n- The result of the division or an error. \n \n" } }, - "sortText": "E", + "sortText": "AACC", "filterText": "safeDivide", "insertText": "safeDivide(${1})", "insertTextFormat": "Snippet", @@ -517,7 +516,7 @@ "value": "**Package:** _nipunaf/proj:0.1.0_ \n \n \n**Params** \n- `int[]` numbers \n \n**Return** `int` \n \n" } }, - "sortText": "E", + "sortText": "AACC", "filterText": "sum", "insertText": "sum(${1})", "insertTextFormat": "Snippet", @@ -536,7 +535,7 @@ "value": "**Package:** _nipunaf/proj:0.1.0_ \n \n \n**Params** \n- `Person` person \n- `Admission` admission \n \n**Return** `Employee` \n \n" } }, - "sortText": "E", + "sortText": "AACC", "filterText": "transform", "insertText": "transform(${1})", "insertTextFormat": "Snippet", @@ -549,7 +548,7 @@ "label": "readonly", "kind": "TypeParameter", "detail": "Readonly", - "sortText": "P", + "sortText": "BN", "insertText": "readonly", "insertTextFormat": "Snippet" }, @@ -557,7 +556,7 @@ "label": "handle", "kind": "TypeParameter", "detail": "Handle", - "sortText": "P", + "sortText": "BN", "insertText": "handle", "insertTextFormat": "Snippet" }, @@ -565,7 +564,7 @@ "label": "never", "kind": "TypeParameter", "detail": "Never", - "sortText": "P", + "sortText": "BN", "insertText": "never", "insertTextFormat": "Snippet" }, @@ -573,7 +572,7 @@ "label": "json", "kind": "TypeParameter", "detail": "Json", - "sortText": "P", + "sortText": "BN", "insertText": "json", "insertTextFormat": "Snippet" }, @@ -581,7 +580,7 @@ "label": "anydata", "kind": "TypeParameter", "detail": "Anydata", - "sortText": "P", + "sortText": "BN", "insertText": "anydata", "insertTextFormat": "Snippet" }, @@ -589,7 +588,7 @@ "label": "any", "kind": "TypeParameter", "detail": "Any", - "sortText": "P", + "sortText": "BN", "insertText": "any", "insertTextFormat": "Snippet" }, @@ -597,9 +596,18 @@ "label": "byte", "kind": "TypeParameter", "detail": "Byte", - "sortText": "P", + "sortText": "BN", "insertText": "byte", "insertTextFormat": "Snippet" + }, + { + "label": "...prefixSum(int[] numbers)", + "kind": "Function", + "detail": "int[]", + "sortText": "AAD", + "filterText": "prefixSum", + "insertText": "...prefixSum(${1})", + "insertTextFormat": "Snippet" } ] } diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj4.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj4.json index 3e4457cd9..dbc54dd9b 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj4.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj4.json @@ -8,168 +8,43 @@ "offset": 0 }, "offset": 1, - "node": { - "id": "35776", - "metadata": { - "label": "New Connection", - "description": "Represents a Snowflake database client.", - "icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_snowflake_2.0.0.png" - }, - "codedata": { - "node": "NEW_CONNECTION", - "org": "ballerinax", - "module": "snowflake", - "object": "Client", - "symbol": "init", - "version": "2.0.0", - "lineRange": { - "fileName": "connections.bal", - "startLine": { - "line": 4, - "offset": 0 - }, - "endLine": { - "line": 4, - "offset": 64 - } - }, - "sourceCode": "final snowflake:Client snowflakeClient = check new (\"\", \"\", \"\");" - }, - "returning": false, - "properties": { - "scope": { - "metadata": { - "label": "Connection Scope", - "description": "Scope of the connection, Global or Local" - }, - "valueType": "ENUM", - "value": "Global", - "optional": false, - "editable": true, - "advanced": true - }, - "checkError": { - "metadata": { - "label": "Check Error", - "description": "Terminate on error" - }, - "valueType": "FLAG", - "value": true, - "optional": false, - "editable": false, - "advanced": true - }, - "account_identifier": { - "metadata": { - "label": "account_identifier", - "description": "The Snowflake account identifier" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "string", - "value": "\"\"", - "placeholder": "\"\"", - "optional": false, - "editable": true, - "advanced": false, - "codedata": { - "kind": "REQUIRED", - "originalName": "account_identifier" - } - }, - "user": { - "metadata": { - "label": "user", - "description": "The username of the Snowflake account" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "string", - "value": "\"\"", - "placeholder": "\"\"", - "optional": false, - "editable": true, - "advanced": false, - "codedata": { - "kind": "REQUIRED", - "originalName": "user" - } - }, - "password": { - "metadata": { - "label": "password", - "description": "The password of the Snowflake account" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "string", - "value": "\"\"", - "placeholder": "\"\"", - "optional": false, - "editable": true, - "advanced": false, - "codedata": { - "kind": "REQUIRED", - "originalName": "password" - } - }, - "options": { - "metadata": { - "label": "options", - "description": "The Snowflake client properties" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "snowflake:Options|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "DEFAULTABLE", - "originalName": "options" - } - }, - "connectionPool": { - "metadata": { - "label": "connectionPool", - "description": "The `sql:ConnectionPool` to be used for the connection. If there is no\n`connectionPool` provided, the global connection pool (shared by all clients) will be used" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "sql:ConnectionPool|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "DEFAULTABLE", - "originalName": "connectionPool", - "importStatements": "ballerina/sql" - } - }, - "variable": { - "metadata": { - "label": "Connection Name", - "description": "Name of the variable" - }, - "valueType": "IDENTIFIER", - "value": "snowflakeClient", - "optional": false, - "editable": true, - "advanced": false - }, - "type": { - "metadata": { - "label": "Connection Type", - "description": "Type of the variable" - }, - "valueType": "TYPE", - "value": "snowflake:Client", - "placeholder": "var", - "optional": false, - "editable": false, - "advanced": false + "codedata": { + "node": "NEW_CONNECTION", + "org": "ballerinax", + "module": "snowflake", + "object": "Client", + "symbol": "init", + "version": "2.0.0", + "lineRange": { + "fileName": "connections.bal", + "startLine": { + "line": 4, + "offset": 0 + }, + "endLine": { + "line": 4, + "offset": 64 } }, - "flags": 1 + "sourceCode": "final snowflake:Client snowflakeClient = check new (\"\", \"\", \"\");" }, - "property": "connectionPool" + "property": { + "metadata": { + "label": "connectionPool", + "description": "The `sql:ConnectionPool` to be used for the connection. If there is no\n`connectionPool` provided, the global connection pool (shared by all clients) will be used" + }, + "valueType": "EXPRESSION", + "valueTypeConstraint": "sql:ConnectionPool|()", + "placeholder": "()", + "optional": true, + "editable": true, + "advanced": true, + "codedata": { + "kind": "DEFAULTABLE", + "originalName": "connectionPool", + "importStatements": "ballerina/sql" + } + } }, "completionContext": { "triggerKind": "Invoked" diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj5.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj5.json index 8fc899b4a..ede6d38ae 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj5.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj5.json @@ -8,96 +8,32 @@ "offset": 0 }, "offset": 1, - "node": { - "id": "31", + "codedata": { + "node": "REMOTE_ACTION_CALL", + "org": "ballerinax", + "module": "snowflake", + "object": "Client", + "symbol": "query", + "id": 1181 + }, + "property": { "metadata": { - "label": "query", - "description": "Executes the query, which may return multiple results.\nWhen processing the stream, make sure to consume all fetched data or close the stream.\n", - "icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_snowflake_2.0.0.png" + "label": "sqlQuery", + "description": "The SQL query such as `` `SELECT * from Album WHERE name=${albumName}` ``" }, + "valueType": "EXPRESSION", + "valueTypeConstraint": "sql:ParameterizedQuery", + "value": "object {}", + "placeholder": "object {}", + "optional": false, + "editable": true, + "advanced": false, "codedata": { - "node": "REMOTE_ACTION_CALL", - "org": "ballerinax", - "module": "snowflake", - "object": "Client", - "symbol": "query", - "id": 1181 - }, - "returning": false, - "properties": { - "connection": { - "metadata": { - "label": "Connection", - "description": "Connection to use" - }, - "valueType": "IDENTIFIER", - "valueTypeConstraint": "snowflake:Client", - "value": "snowflakeCl", - "optional": false, - "editable": false, - "advanced": false - }, - "sqlQuery": { - "metadata": { - "label": "sqlQuery", - "description": "The SQL query such as `` `SELECT * from Album WHERE name=${albumName}` ``" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "sql:ParameterizedQuery", - "value": "object {}", - "placeholder": "object {}", - "optional": false, - "editable": true, - "advanced": false, - "codedata": { - "kind": "REQUIRED", - "originalName": "sqlQuery", - "importStatements": "ballerina/sql" - } - }, - "rowType": { - "metadata": { - "label": "rowType", - "description": "The `typedesc` of the record to which the result needs to be returned" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "record {|anydata...;|}", - "placeholder": "<>", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "DEFAULTABLE", - "originalName": "rowType" - } - }, - "type": { - "metadata": { - "label": "Variable Type", - "description": "Type of the variable" - }, - "valueType": "TYPE", - "value": "stream", - "placeholder": "var", - "optional": false, - "editable": false, - "advanced": false - }, - "variable": { - "metadata": { - "label": "Variable Name", - "description": "Name of the variable" - }, - "valueType": "IDENTIFIER", - "value": "streamRowtypeBallerinaSql1130Error", - "optional": false, - "editable": true, - "advanced": false - } - }, - "flags": 0 - }, - "property": "sqlQuery" + "kind": "REQUIRED", + "originalName": "sqlQuery", + "importStatements": "ballerina/sql" + } + } }, "completionContext": { "triggerKind": "Invoked" diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj6.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj6.json index 832cf318b..26fcc8aa9 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj6.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj6.json @@ -8,340 +8,31 @@ "offset": 0 }, "offset": 1, - "node": { - "id": "31", + "codedata": { + "node": "NEW_CONNECTION", + "org": "ballerinax", + "module": "docusign.dsadmin", + "object": "Client", + "symbol": "init", + "id": 1569 + }, + "property": { "metadata": { - "label": "New Connection", - "description": "An API for an organization administrator to manage organizations, accounts and users", - "icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_docusign.dsadmin_2.0.0.png" + "label": "auth", + "description": "Configurations related to client authentication" }, + "valueType": "EXPRESSION", + "valueTypeConstraint": "http:BearerTokenConfig|dsadmin:OAuth2RefreshTokenGrantConfig", + "placeholder": "{token: \"\"}", + "optional": false, + "editable": true, + "advanced": false, "codedata": { - "node": "NEW_CONNECTION", - "org": "ballerinax", - "module": "docusign.dsadmin", - "object": "Client", - "symbol": "init", - "id": 1569 - }, - "returning": false, - "properties": { - "serviceUrl": { - "metadata": { - "label": "serviceUrl", - "description": "URL of the target service " - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "string", - "value": "\"\"", - "placeholder": "\"\"", - "optional": false, - "editable": true, - "advanced": false, - "codedata": { - "kind": "REQUIRED", - "originalName": "serviceUrl" - } - }, - "auth": { - "metadata": { - "label": "auth", - "description": "Configurations related to client authentication" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:BearerTokenConfig|dsadmin:OAuth2RefreshTokenGrantConfig", - "placeholder": "{token: \"\"}", - "optional": false, - "editable": true, - "advanced": false, - "codedata": { - "kind": "INCLUDED_FIELD", - "originalName": "auth", - "importStatements": "ballerina/http" - } - }, - "httpVersion": { - "metadata": { - "label": "httpVersion", - "description": "The HTTP version understood by the client" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:HttpVersion", - "placeholder": "http:HTTP_2_0", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "INCLUDED_FIELD", - "originalName": "httpVersion", - "importStatements": "ballerina/http" - } - }, - "http1Settings": { - "metadata": { - "label": "http1Settings", - "description": "Configurations related to HTTP/1.x protocol" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "docusign.dsadmin:ClientHttp1Settings", - "placeholder": "{}", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "INCLUDED_FIELD", - "originalName": "http1Settings" - } - }, - "http2Settings": { - "metadata": { - "label": "http2Settings", - "description": "Configurations related to HTTP/2 protocol" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:ClientHttp2Settings", - "placeholder": "{}", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "INCLUDED_FIELD", - "originalName": "http2Settings", - "importStatements": "ballerina/http" - } - }, - "timeout": { - "metadata": { - "label": "timeout", - "description": "The maximum time to wait (in seconds) for a response before closing the connection" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "decimal", - "placeholder": "60", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "INCLUDED_FIELD", - "originalName": "timeout" - } - }, - "forwarded": { - "metadata": { - "label": "forwarded", - "description": "The choice of setting `forwarded`/`x-forwarded` header" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "string", - "placeholder": "\"disable\"", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "INCLUDED_FIELD", - "originalName": "forwarded" - } - }, - "poolConfig": { - "metadata": { - "label": "poolConfig", - "description": "Configurations associated with request pooling" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:PoolConfiguration", - "placeholder": "{}", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "INCLUDED_FIELD", - "originalName": "poolConfig", - "importStatements": "ballerina/http" - } - }, - "cache": { - "metadata": { - "label": "cache", - "description": "HTTP caching related configurations" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:CacheConfig", - "placeholder": "{}", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "INCLUDED_FIELD", - "originalName": "cache", - "importStatements": "ballerina/http" - } - }, - "compression": { - "metadata": { - "label": "compression", - "description": "Specifies the way of handling compression (`accept-encoding`) header" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:Compression", - "placeholder": "http:COMPRESSION_AUTO", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "INCLUDED_FIELD", - "originalName": "compression", - "importStatements": "ballerina/http" - } - }, - "circuitBreaker": { - "metadata": { - "label": "circuitBreaker", - "description": "Configurations associated with the behaviour of the Circuit Breaker" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:CircuitBreakerConfig", - "placeholder": "{}", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "INCLUDED_FIELD", - "originalName": "circuitBreaker", - "importStatements": "ballerina/http" - } - }, - "retryConfig": { - "metadata": { - "label": "retryConfig", - "description": "Configurations associated with retrying" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:RetryConfig", - "placeholder": "{}", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "INCLUDED_FIELD", - "originalName": "retryConfig", - "importStatements": "ballerina/http" - } - }, - "responseLimits": { - "metadata": { - "label": "responseLimits", - "description": "Configurations associated with inbound response size limits" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:ResponseLimitConfigs", - "placeholder": "{}", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "INCLUDED_FIELD", - "originalName": "responseLimits", - "importStatements": "ballerina/http" - } - }, - "secureSocket": { - "metadata": { - "label": "secureSocket", - "description": "SSL/TLS-related options" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:ClientSecureSocket", - "placeholder": "{}", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "INCLUDED_FIELD", - "originalName": "secureSocket", - "importStatements": "ballerina/http" - } - }, - "proxy": { - "metadata": { - "label": "proxy", - "description": "Proxy server related options" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "http:ProxyConfig", - "placeholder": "{}", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "INCLUDED_FIELD", - "originalName": "proxy", - "importStatements": "ballerina/http" - } - }, - "validation": { - "metadata": { - "label": "validation", - "description": "Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "boolean", - "placeholder": "true", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "INCLUDED_FIELD", - "originalName": "validation" - } - }, - "type": { - "metadata": { - "label": "Variable Type", - "description": "Type of the variable" - }, - "valueType": "TYPE", - "value": "dsadmin:Client", - "placeholder": "var", - "optional": false, - "editable": false, - "advanced": false - }, - "variable": { - "metadata": { - "label": "Connection Name", - "description": "Name of the variable" - }, - "valueType": "IDENTIFIER", - "value": "dsadminClient", - "optional": false, - "editable": true, - "advanced": false - }, - "scope": { - "metadata": { - "label": "Connection Scope", - "description": "Scope of the connection, Global or Local" - }, - "valueType": "ENUM", - "value": "Global", - "optional": false, - "editable": true, - "advanced": true - }, - "checkError": { - "metadata": { - "label": "Check Error", - "description": "Terminate on error" - }, - "valueType": "FLAG", - "value": true, - "optional": false, - "editable": false, - "advanced": true - } - }, - "flags": 0 - }, - "property": "auth" + "kind": "INCLUDED_FIELD", + "originalName": "auth", + "importStatements": "ballerina/http" + } + } }, "completionContext": { "triggerKind": "Invoked" @@ -463,4 +154,4 @@ "insertTextFormat": "Snippet" } ] -} +} \ No newline at end of file diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj7.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj7.json index 478e44877..edd96e081 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj7.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj7.json @@ -8,132 +8,30 @@ "offset": 0 }, "offset": 0, - "node": { - "id": "31", + "codedata": { + "node": "RESOURCE_ACTION_CALL", + "org": "ballerinax", + "module": "docusign.dsadmin", + "object": "Client", + "symbol": "get", + "id": 1577 + }, + "property": { "metadata": { - "label": "get", - "description": "Returns the list of groups in an account.\n", - "icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_docusign.dsadmin_2.0.0.png" + "label": "take", + "description": "Page size of the response. The default value is 20." }, + "valueType": "EXPRESSION", + "valueTypeConstraint": "lang.int:Signed32|()", + "placeholder": "()", + "optional": true, + "editable": true, + "advanced": true, "codedata": { - "node": "RESOURCE_ACTION_CALL", - "org": "ballerinax", - "module": "docusign.dsadmin", - "object": "Client", - "symbol": "get", - "id": 1577 - }, - "returning": false, - "properties": { - "connection": { - "metadata": { - "label": "Connection", - "description": "Connection to use" - }, - "valueType": "IDENTIFIER", - "valueTypeConstraint": "docusign.dsadmin:Client", - "value": "dsAdminClient", - "optional": false, - "editable": false, - "advanced": false - }, - "resourcePath": { - "metadata": { - "label": "Resource Path", - "description": "Resource Path" - }, - "valueType": "EXPRESSION", - "value": "/v2/organizations/[\"\"]/accounts/[\"\"]/groups", - "optional": false, - "editable": true, - "advanced": false - }, - "start": { - "metadata": { - "label": "start", - "description": "Index of first item to include in the response. The default value is 0." - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "lang.int:Signed32|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "DEFAULTABLE", - "originalName": "'start" - } - }, - "take": { - "metadata": { - "label": "take", - "description": "Page size of the response. The default value is 20." - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "lang.int:Signed32|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "DEFAULTABLE", - "originalName": "take" - } - }, - "end": { - "metadata": { - "label": "end", - "description": "Index of the last item to include in the response. Ignored if `take` parameter is specified." - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "lang.int:Signed32|()", - "placeholder": "()", - "optional": true, - "editable": true, - "advanced": true, - "codedata": { - "kind": "DEFAULTABLE", - "originalName": "end" - } - }, - "type": { - "metadata": { - "label": "Variable Type", - "description": "Type of the variable" - }, - "valueType": "TYPE", - "value": "docusign.dsadmin:MemberGroupsResponse", - "placeholder": "var", - "optional": false, - "editable": false, - "advanced": false - }, - "variable": { - "metadata": { - "label": "Variable Name", - "description": "Name of the variable" - }, - "valueType": "IDENTIFIER", - "value": "docusignDsadminMembergroupsresponse", - "optional": false, - "editable": true, - "advanced": false - }, - "checkError": { - "metadata": { - "label": "Check Error", - "description": "Trigger error flow" - }, - "valueType": "FLAG", - "value": true, - "optional": false, - "editable": true, - "advanced": true - } - }, - "flags": 0 - }, - "property": "take" + "kind": "DEFAULTABLE", + "originalName": "take" + } + } }, "completionContext": { "triggerKind": "Invoked" diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj8.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj8.json index 0f09be57c..059579209 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj8.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj8.json @@ -8,68 +8,33 @@ "offset": 4 }, "offset": 1, - "node": { - "id": "32874", - "metadata": { - "label": "Variable", - "description": "Assign a value to a variable" - }, - "codedata": { - "node": "VARIABLE", - "lineRange": { - "fileName": "new_data.bal", - "startLine": { - "line": 1, - "offset": 4 - }, - "endLine": { - "line": 1, - "offset": 14 - } - }, - "sourceCode": "int i = 12;" - }, - "returning": false, - "properties": { - "expression": { - "metadata": { - "label": "Expression", - "description": "Initialize with value" - }, - "valueType": "EXPRESSION", - "valueTypeConstraint": "Location", - "value": "", - "optional": true, - "editable": true, - "advanced": false + "codedata": { + "node": "VARIABLE", + "lineRange": { + "fileName": "new_data.bal", + "startLine": { + "line": 1, + "offset": 4 }, - "variable": { - "metadata": { - "label": "Name", - "description": "Name of the variable" - }, - "valueType": "IDENTIFIER", - "value": "i", - "optional": false, - "editable": true, - "advanced": false - }, - "type": { - "metadata": { - "label": "Type", - "description": "Type of the variable" - }, - "valueType": "TYPE", - "value": "", - "placeholder": "var", - "optional": false, - "editable": true, - "advanced": false + "endLine": { + "line": 1, + "offset": 14 } }, - "flags": 0 + "sourceCode": "int i = 12;" }, - "property": "expression" + "property": { + "metadata": { + "label": "Expression", + "description": "Initialize with value" + }, + "valueType": "EXPRESSION", + "valueTypeConstraint": "Location", + "value": "", + "optional": true, + "editable": true, + "advanced": false + } }, "completionContext": { "triggerKind": "Invoked" From cc8c6c150f143fd8734f6affa4cbdf49fced7d27 Mon Sep 17 00:00:00 2001 From: Nipuna Fernando Date: Thu, 27 Feb 2025 00:25:03 +0530 Subject: [PATCH 3/5] Update the import module tests --- .../flowmodelgenerator/extension/ExpressionEditorService.java | 3 +-- .../flowmodelgenerator/extension/ImportModuleTest.java | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/main/java/io/ballerina/flowmodelgenerator/extension/ExpressionEditorService.java b/flow-model-generator/modules/flow-model-generator-ls-extension/src/main/java/io/ballerina/flowmodelgenerator/extension/ExpressionEditorService.java index 1a8365d05..6da0bae96 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/main/java/io/ballerina/flowmodelgenerator/extension/ExpressionEditorService.java +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/main/java/io/ballerina/flowmodelgenerator/extension/ExpressionEditorService.java @@ -147,8 +147,7 @@ public CompletableFuture, CompletionList>> completio } @JsonRequest - public CompletableFuture diagnostics( - ExpressionEditorDiagnosticsRequest request) { + public CompletableFuture diagnostics(ExpressionEditorDiagnosticsRequest request) { String fileUri = CommonUtils.getExprUri(request.filePath()); return Debouncer.getInstance().debounce(DiagnosticsRequest.from( new ExpressionEditorContext( diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/java/io/ballerina/flowmodelgenerator/extension/ImportModuleTest.java b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/java/io/ballerina/flowmodelgenerator/extension/ImportModuleTest.java index d9ab22baa..467e65c74 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/java/io/ballerina/flowmodelgenerator/extension/ImportModuleTest.java +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/java/io/ballerina/flowmodelgenerator/extension/ImportModuleTest.java @@ -66,7 +66,8 @@ public void test(Path config) throws IOException { // Send diagnostics request ExpressionEditorContext.Info info = new ExpressionEditorContext.Info(testConfig.expression(), LinePosition.from(1, 0), - 0, variableNode.get("codedata").getAsJsonObject(), null); + 0, variableNode.get("codedata").getAsJsonObject(), + variableNode.getAsJsonObject("properties").getAsJsonObject("expression")); ExpressionEditorDiagnosticsRequest diagnosticsRequest = new ExpressionEditorDiagnosticsRequest(sourcePath, info); JsonObject response = getResponse(diagnosticsRequest, "expressionEditor/diagnostics"); From 0645b46f9aaa8cbdaf9cd3c1171e2080b1fa0b5f Mon Sep 17 00:00:00 2001 From: Nipuna Fernando Date: Thu, 27 Feb 2025 11:56:46 +0530 Subject: [PATCH 4/5] Account the line offset introduced by imports --- .../ExpressionEditorContext.java | 39 ++++++++++--- .../resources/completions/config/proj4.json | 36 +++++++++++- .../diagnostics/config/action_call1.json | 6 +- .../diagnostics/config/function_call1.json | 4 +- .../diagnostics/config/function_call2.json | 4 +- .../diagnostics/config/function_call3.json | 4 +- .../diagnostics/config/new_connection6.json | 37 +++++++++++++ .../diagnostics/config/new_connection7.json | 55 +++++++++++++++++++ .../resources/diagnostics/source/empty.bal | 0 9 files changed, 168 insertions(+), 17 deletions(-) create mode 100644 flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection6.json create mode 100644 flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection7.json create mode 100644 flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/source/empty.bal diff --git a/flow-model-generator/modules/flow-model-generator-core/src/main/java/io/ballerina/flowmodelgenerator/core/expressioneditor/ExpressionEditorContext.java b/flow-model-generator/modules/flow-model-generator-core/src/main/java/io/ballerina/flowmodelgenerator/core/expressioneditor/ExpressionEditorContext.java index 6bc1b75e4..d5e3c74ce 100644 --- a/flow-model-generator/modules/flow-model-generator-core/src/main/java/io/ballerina/flowmodelgenerator/core/expressioneditor/ExpressionEditorContext.java +++ b/flow-model-generator/modules/flow-model-generator-core/src/main/java/io/ballerina/flowmodelgenerator/core/expressioneditor/ExpressionEditorContext.java @@ -18,7 +18,6 @@ package io.ballerina.flowmodelgenerator.core.expressioneditor; -import com.google.gson.Gson; import com.google.gson.JsonObject; import io.ballerina.compiler.syntax.tree.ImportDeclarationNode; import io.ballerina.compiler.syntax.tree.ModulePartNode; @@ -54,7 +53,6 @@ */ public class ExpressionEditorContext { - private static final Gson gson = new Gson(); private final WorkspaceManagerProxy workspaceManagerProxy; private final String fileUri; private final Info info; @@ -151,7 +149,7 @@ public Optional getImport(String importStatement) { .name(importStatement) .endOfStatement() .build(false); - TextEdit textEdit = TextEdit.from(TextRange.from(0, 0), stmt); + TextEdit textEdit = TextEdit.from(TextRange.from(0, 0), stmt + System.lineSeparator()); return Optional.of(textEdit); } return Optional.empty(); @@ -166,6 +164,7 @@ public Optional getImport(String importStatement) { public LineRange generateStatement() { String prefix = "var __reserved__ = "; List textEdits = new ArrayList<>(); + int lineOffset = 0; if (property != null) { // Append the type if exists @@ -177,7 +176,11 @@ public LineRange generateStatement() { String importStatements = property.importStatements(); if (importStatements != null && !importStatements.isEmpty()) { for (String importStmt : importStatements.split(",")) { - getImport(importStmt).ifPresent(textEdits::add); + Optional textEdit = getImport(importStmt); + if (textEdit.isPresent()) { + textEdits.add(textEdit.get()); + lineOffset++; + } } } } @@ -185,12 +188,17 @@ public LineRange generateStatement() { // Add the import statement for the node type if (isNodeKind(List.of(NodeKind.NEW_CONNECTION, NodeKind.FUNCTION_CALL, NodeKind.REMOTE_ACTION_CALL, NodeKind.RESOURCE_ACTION_CALL))) { - getImport().ifPresent(textEdits::add); + Optional textEdit = getImport(); + if (textEdit.isPresent()) { + textEdits.add(textEdit.get()); + lineOffset++; + } } // Get the text position of the start line TextDocument textDocument = documentContext.document().textDocument(); - int textPosition = textDocument.textPositionFrom(info.startLine()); + LinePosition cursorStartLine = info.startLine(); + int textPosition = textDocument.textPositionFrom(cursorStartLine); // Generate the statement and apply the text edits String statement = String.format("%s%s;%n", prefix, info.expression()); @@ -199,7 +207,7 @@ public LineRange generateStatement() { applyTextEdits(textEdits); // Return the line range of the generated statement - LinePosition startLine = info.startLine(); + LinePosition startLine = LinePosition.from(cursorStartLine.line() + lineOffset, cursorStartLine.offset()); LinePosition endLineRange = LinePosition.from(startLine.line(), startLine.offset() + statement.length()); this.statementLineRange = LineRange.from(filePath.toString(), startLine, endLineRange); @@ -268,6 +276,23 @@ public Property getProperty() { return property; } + /** + * Represents a property with associated code data in the expression editor context. + * + *

+ * This is a temporary abstraction of the {@link io.ballerina.flowmodelgenerator.core.model.Property} and + * {@link io.ballerina.flowmodelgenerator.core.model.Codedata} until the source code is properly refactored to use + * these structures. The class provides the minimum public methods required to build the context and follows the CoR + * pattern to support fallback mechanisms for property derivation. + *

+ *

+ * The property encapsulates various attributes such as value, value type, type constraints, import statements, + * organization, module, and node kind. These values are lazily initialized when first accessed through the getter + * methods. + *

+ * + * @since 2.0.0 + */ public static class Property { private final JsonObject property; diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj4.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj4.json index dbc54dd9b..c9ad38543 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj4.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/completions/config/proj4.json @@ -49,5 +49,39 @@ "completionContext": { "triggerKind": "Invoked" }, - "completions": [] + "completions": [ + { + "label": "readonly", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "readonly", + "insertText": "readonly ", + "insertTextFormat": "Snippet" + }, + { + "label": "maxOpenConnections", + "kind": "Field", + "detail": "sql:ConnectionPool.maxOpenConnections", + "sortText": "K", + "insertText": "maxOpenConnections: ${1:0}", + "insertTextFormat": "Snippet" + }, + { + "label": "maxConnectionLifeTime", + "kind": "Field", + "detail": "sql:ConnectionPool.maxConnectionLifeTime", + "sortText": "K", + "insertText": "maxConnectionLifeTime: ${1:0}", + "insertTextFormat": "Snippet" + }, + { + "label": "minIdleConnections", + "kind": "Field", + "detail": "sql:ConnectionPool.minIdleConnections", + "sortText": "K", + "insertText": "minIdleConnections: ${1:0}", + "insertTextFormat": "Snippet" + } + ] } diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/action_call1.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/action_call1.json index 0462c9b28..e4514bc2d 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/action_call1.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/action_call1.json @@ -35,11 +35,11 @@ { "range": { "start": { - "line": 2, + "line": 3, "character": 35 }, "end": { - "line": 2, + "line": 3, "character": 38 } }, @@ -50,4 +50,4 @@ "message": "undefined symbol 'val'" } ] -} \ No newline at end of file +} diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/function_call1.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/function_call1.json index 65f634bba..f65905c48 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/function_call1.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/function_call1.json @@ -34,11 +34,11 @@ { "range": { "start": { - "line": 13, + "line": 14, "character": 30 }, "end": { - "line": 13, + "line": 14, "character": 32 } }, diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/function_call2.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/function_call2.json index aac9154ed..b88ef3eb3 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/function_call2.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/function_call2.json @@ -34,11 +34,11 @@ { "range": { "start": { - "line": 13, + "line": 14, "character": 34 }, "end": { - "line": 13, + "line": 14, "character": 36 } }, diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/function_call3.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/function_call3.json index 4a06c7276..875441fe2 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/function_call3.json +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/function_call3.json @@ -30,11 +30,11 @@ { "range": { "start": { - "line": 13, + "line": 14, "character": 32 }, "end": { - "line": 13, + "line": 14, "character": 34 } }, diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection6.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection6.json new file mode 100644 index 000000000..353330975 --- /dev/null +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection6.json @@ -0,0 +1,37 @@ +{ + "description": "", + "filePath": "empty.bal", + "context": { + "expression": "\"\"", + "startLine": { + "line": 0, + "offset": 0 + }, + "offset": 1, + "codedata": { + "node": "NEW_CONNECTION", + "org": "ballerina", + "module": "grpc", + "object": "Client", + "symbol": "init", + "id": 154 + }, + "property": { + "metadata": { + "label": "url", + "description": "The server URL" + }, + "valueType": "EXPRESSION", + "valueTypeConstraint": "string", + "placeholder": "\"\"", + "optional": false, + "editable": true, + "advanced": false, + "codedata": { + "kind": "REQUIRED", + "originalName": "url" + } + } + }, + "diagnostics": [] +} diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection7.json b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection7.json new file mode 100644 index 000000000..c2219a03a --- /dev/null +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/config/new_connection7.json @@ -0,0 +1,55 @@ +{ + "description": "", + "filePath": "empty.bal", + "context": { + "expression": "{}", + "startLine": { + "line": 0, + "offset": 0 + }, + "offset": 1, + "codedata": { + "node": "NEW_CONNECTION", + "org": "ballerina", + "module": "grpc", + "object": "Client", + "symbol": "init", + "id": 154 + }, + "property": { + "metadata": { + "label": "url", + "description": "The server URL" + }, + "valueType": "EXPRESSION", + "valueTypeConstraint": "string", + "placeholder": "\"\"", + "optional": false, + "editable": true, + "advanced": false, + "codedata": { + "kind": "REQUIRED", + "originalName": "url" + } + } + }, + "diagnostics": [ + { + "range": { + "start": { + "line": 1, + "character": 22 + }, + "end": { + "line": 1, + "character": 24 + } + }, + "severity": "Error", + "code": { + "left": "BCE2508" + }, + "message": "a type compatible with mapping constructor expressions not found in type 'string'" + } + ] +} diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/source/empty.bal b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/diagnostics/source/empty.bal new file mode 100644 index 000000000..e69de29bb From 68fab3e356a752ca6182479e1c90f589a31fae33 Mon Sep 17 00:00:00 2001 From: Nipuna Fernando Date: Thu, 27 Feb 2025 12:38:47 +0530 Subject: [PATCH 5/5] Fix teh test case in function call template --- .../flowmodelgenerator/extension/FunctionCallTemplateTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/java/io/ballerina/flowmodelgenerator/extension/FunctionCallTemplateTest.java b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/java/io/ballerina/flowmodelgenerator/extension/FunctionCallTemplateTest.java index f23f498b4..6cfd848aa 100644 --- a/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/java/io/ballerina/flowmodelgenerator/extension/FunctionCallTemplateTest.java +++ b/flow-model-generator/modules/flow-model-generator-ls-extension/src/test/java/io/ballerina/flowmodelgenerator/extension/FunctionCallTemplateTest.java @@ -92,7 +92,8 @@ public void testDiagnostics(Path config) throws IOException { template = template.replace("${1}", " "); } ExpressionEditorContext.Info info = new ExpressionEditorContext.Info(template, startPosition, offset, - variableNode.get("codedata").getAsJsonObject(), null); + variableNode.get("codedata").getAsJsonObject(), + variableNode.getAsJsonObject("properties").getAsJsonObject("expression")); ExpressionEditorDiagnosticsRequest diagnosticsRequest = new ExpressionEditorDiagnosticsRequest(sourcePath, info); JsonObject response = getResponse(diagnosticsRequest, "expressionEditor/diagnostics");