Add default value support#660
Conversation
fef853b to
5af4344
Compare
|
@samithkavishke Your fix should fix this issue as well. |
5af4344 to
6ca0841
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds support for extracting and preserving default values for enum types in FTP service configurations. The changes implement a mechanism to parse enum member values from source code and correctly propagate them through the type system.
Changes:
- Added enum member value extraction logic that parses syntax trees to retrieve actual enum values (e.g.,
FTP = "ftp"returns"ftp") - Created a public API in CommonUtils for extracting default values from symbols
- Updated the Type model to handle enum default values in record fields
- Updated FTP package version from 2.14.1 to 2.16.0
- Updated test resource files with new package version icons
Reviewed changes
Copilot reviewed 13 out of 15 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| model-generator-commons/src/main/java/io/ballerina/modelgenerator/commons/FunctionDataBuilder.java | Added extractEnumMemberValue method and enhanced getDefaultValue to resolve enum values from source |
| model-generator-commons/src/main/java/io/ballerina/modelgenerator/commons/CommonUtils.java | Added public extractDefaultValue API that delegates to FunctionDataBuilder |
| misc/diagram-util/src/main/java/org/ballerinalang/diagramutil/connector/models/connector/Type.java | Enhanced type system to extract and mark enum default values in record fields |
| misc/diagram-util/src/main/java/module-info.java | Added dependency on model-generator-commons module |
| misc/diagram-util/build.gradle | Added implementation dependency on model-generator-commons project |
| flow-model-generator/modules/flow-model-index-generator/src/main/resources/packages.json | Updated FTP package version to 2.16.0 |
| flow-model-generator/modules/flow-model-generator-ls-extension/src/main/java/io/ballerina/flowmodelgenerator/extension/TypesManagerService.java | Updated API call to pass packageName parameter |
| service-model-generator/modules/service-model-generator-ls-extension/src/main/resources/service-index.sqlite | Updated SQLite database with new service configurations |
| architecture-model-generator test resources | Updated icon URLs for tcp, rabbitmq, kafka packages to reflect new versions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...iagram-util/src/main/java/org/ballerinalang/diagramutil/connector/models/connector/Type.java
Show resolved
Hide resolved
model-generator-commons/src/main/java/io/ballerina/modelgenerator/commons/CommonUtils.java
Outdated
Show resolved
Hide resolved
...iagram-util/src/main/java/org/ballerinalang/diagramutil/connector/models/connector/Type.java
Outdated
Show resolved
Hide resolved
...generator-commons/src/main/java/io/ballerina/modelgenerator/commons/FunctionDataBuilder.java
Outdated
Show resolved
Hide resolved
model-generator-commons/src/main/java/io/ballerina/modelgenerator/commons/CommonUtils.java
Outdated
Show resolved
Hide resolved
...generator-commons/src/main/java/io/ballerina/modelgenerator/commons/FunctionDataBuilder.java
Outdated
Show resolved
Hide resolved
6ca0841 to
af98691
Compare
3ed6e7b to
a58554f
Compare
The base branch was changed.
02f9e27 to
ce1d83d
Compare
e68edb9 to
8e7484a
Compare
...r-ls-extension/src/test/java/io/ballerina/flowmodelgenerator/extension/NodeTemplateTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 101 out of 103 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...generator-commons/src/main/java/io/ballerina/modelgenerator/commons/FunctionDataBuilder.java
Outdated
Show resolved
Hide resolved
2d5c8a3 to
2eb528f
Compare
5181925 to
d386b5e
Compare
...-model-generator-core/src/main/java/io/ballerina/flowmodelgenerator/core/model/Property.java
Outdated
Show resolved
Hide resolved
...-model-generator-core/src/main/java/io/ballerina/flowmodelgenerator/core/model/Property.java
Outdated
Show resolved
Hide resolved
...iagram-util/src/main/java/org/ballerinalang/diagramutil/connector/models/connector/Type.java
Outdated
Show resolved
Hide resolved
...iagram-util/src/main/java/org/ballerinalang/diagramutil/connector/models/connector/Type.java
Outdated
Show resolved
Hide resolved
model-generator-commons/src/main/java/io/ballerina/modelgenerator/commons/CommonUtils.java
Show resolved
Hide resolved
model-generator-commons/src/main/java/io/ballerina/modelgenerator/commons/CommonUtils.java
Show resolved
Hide resolved
...generator-commons/src/main/java/io/ballerina/modelgenerator/commons/FunctionDataBuilder.java
Outdated
Show resolved
Hide resolved
0638db5 to
554bda2
Compare
|
Currently, this implementation partially fixes the issue. However, it still needs to handle the default value resolution for cached BIR package resolutions. This issue occurs when the user navigates to a client that is already added to the code and tries to configure it, the default values shown are still incorrect. |
NipunaRanasinghe
left a comment
There was a problem hiding this comment.
As discussed offline with @samithkavishke, there is still an issue with resolving default values from cached modules. At the moment, the current BIR does not provide enough information to reliably extract default values from the semantic model.
That said, the implementation works for the majority of cases (e.g., new connection creation), and we already have proper fallbacks in place for scenarios where this fails (which matches the current behavior).
So we are merging these changes now, and we’ll address the remaining edge cases in a follow-up PR.
Purpose
Fixes: wso2/product-ballerina-integrator#2345, wso2/product-ballerina-integrator#1821, wso2/product-ballerina-integrator#827, wso2/product-ballerina-integrator#2012
Goals
Approach
User stories
Release note
Documentation
Training
Certification
Marketing
Automation tests
Security checks
Samples
Related PRs
Migrations (if applicable)
Test environment
Learning