-
Notifications
You must be signed in to change notification settings - Fork 36
Fix enum type misinterpretation as union in record fields #663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
pasindufernando1
merged 5 commits into
ballerina-platform:1.5.x
from
pasindufernando1:1381Fix
Jan 30, 2026
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d56a577
Distinguish enums from unions
pasindufernando1 af00981
Update RefType test cases
pasindufernando1 48f0df8
Update datamapping model tests
pasindufernando1 be9376e
Add newline at EOF
pasindufernando1 362c89c
Address PR suggestions
pasindufernando1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
...rator-ls-extension/src/test/resources/data_mapper_custom_function/config/enum_member.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| { | ||
| "source": "proj4/main.bal", | ||
| "description": "Sample diagram node", | ||
| "codedata": { | ||
| "node": "VARIABLE", | ||
| "lineRange": { | ||
| "fileName": "proj4/main.bal", | ||
| "startLine": { | ||
| "line": 9, | ||
| "offset": 0 | ||
| }, | ||
| "endLine": { | ||
| "line": 12, | ||
| "offset": 2 | ||
| } | ||
| } | ||
| }, | ||
| "mapping": { | ||
| "output": "transformTest.gender", | ||
| "expression": "patient.gender" | ||
| }, | ||
| "functionMetadata": { | ||
| "returnType": { | ||
| "type": "unknown|male|female|other", | ||
| "kind": "union" | ||
| }, | ||
| "parameters": [ | ||
| { | ||
| "name": "gender", | ||
| "type": "string?", | ||
| "isOptional": true, | ||
| "isNullable": false, | ||
| "kind": "string" | ||
| } | ||
| ] | ||
| }, | ||
| "targetField": "transformTest", | ||
| "output": { | ||
| "proj4/main.bal": [ | ||
| { | ||
| "range": { | ||
| "start": { | ||
| "line": 11, | ||
| "character": 12 | ||
| }, | ||
| "end": { | ||
| "line": 11, | ||
| "character": 12 | ||
| } | ||
| }, | ||
| "newText": ", gender: mapStringToUnion1(patient.gender)" | ||
| } | ||
| ], | ||
| "proj4/functions.bal": [ | ||
| { | ||
| "range": { | ||
| "start": { | ||
| "line": 0, | ||
| "character": 0 | ||
| }, | ||
| "end": { | ||
| "line": 0, | ||
| "character": 0 | ||
| } | ||
| }, | ||
| "newText": "\nfunction mapStringToUnion1(string? gender) returns unknown|male|female|other {}" | ||
| } | ||
| ] | ||
| } | ||
| } |
6 changes: 6 additions & 0 deletions
6
...r-ls-extension/src/test/resources/data_mapper_custom_function/source/proj4/Ballerina.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| [package] | ||
| org = "org" | ||
| name = "name" | ||
| version = "0.1.0" | ||
| distribution = "2201.9.2" | ||
|
|
Empty file.
14 changes: 14 additions & 0 deletions
14
...nerator-ls-extension/src/test/resources/data_mapper_custom_function/source/proj4/main.bal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import ballerinax/health.fhir.r4.uscore311; | ||
|
|
||
| public type PatientDataOptionalized record {| | ||
| string id?; | ||
| string? name?; | ||
| string? gender?; | ||
| string? birthDate?; | ||
| |}; | ||
|
|
||
| function transformTest(PatientDataOptionalized patient) returns uscore311:USCorePatientProfile => { | ||
| identifier: [], | ||
| name: [] | ||
| }; | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
misc/diagram-util/src/test/resources/RefTypeTest/TestData/enumSample2.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| { | ||
| "description": "A simple example of a reference-based type", | ||
| "source": "RefTypeTest/BalProject7", | ||
| "typeSymbolName": "Person2", | ||
| "refType": { | ||
| "fields": [ | ||
| { | ||
| "fieldName": "name", | ||
| "type": { | ||
| "dependentTypeKeys": [], | ||
| "name": "string", | ||
| "typeName": "string" | ||
| }, | ||
| "optional": false, | ||
| "defaultValue": "" | ||
| }, | ||
| { | ||
| "fieldName": "age", | ||
| "type": { | ||
| "dependentTypeKeys": [], | ||
| "name": "int", | ||
| "typeName": "int" | ||
| }, | ||
| "optional": false, | ||
| "defaultValue": "" | ||
| }, | ||
| { | ||
| "fieldName": "favoriteColor", | ||
| "type": { | ||
| "members": [ | ||
| { | ||
| "dependentTypeKeys": [], | ||
| "name": "BLUE" | ||
| }, | ||
| { | ||
| "dependentTypeKeys": [], | ||
| "name": "GREEN" | ||
| }, | ||
| { | ||
| "dependentTypeKeys": [], | ||
| "name": "RED" | ||
| } | ||
| ], | ||
| "dependentTypeKeys": [], | ||
| "hashCode": "1321203991", | ||
| "key": "-955095486", | ||
| "name": "Color", | ||
| "typeName": "enum", | ||
| "moduleInfo": { | ||
| "orgName": "ballerinax", | ||
| "moduleName": "test.streams", | ||
| "packageName": "test.streams", | ||
| "version": "0.1.0", | ||
| "modulePrefix": "streams" | ||
| } | ||
| }, | ||
| "optional": false, | ||
| "defaultValue": "" | ||
| } | ||
| ], | ||
| "dependentTypeKeys": [ | ||
| "-955095486" | ||
| ], | ||
| "hashCode": "1975722613", | ||
| "key": "-351745380", | ||
| "name": "Person2", | ||
| "typeName": "record", | ||
| "dependentTypes": { | ||
| "-955095486": { | ||
| "members": [ | ||
| { | ||
| "dependentTypeKeys": [], | ||
| "name": "BLUE" | ||
| }, | ||
| { | ||
| "dependentTypeKeys": [], | ||
| "name": "GREEN" | ||
| }, | ||
| { | ||
| "dependentTypeKeys": [], | ||
| "name": "RED" | ||
| } | ||
| ], | ||
| "dependentTypeKeys": [], | ||
| "hashCode": "1321203991", | ||
| "key": "-955095486", | ||
| "name": "Color", | ||
| "typeName": "enum", | ||
| "moduleInfo": { | ||
| "orgName": "ballerinax", | ||
| "moduleName": "test.streams", | ||
| "packageName": "test.streams", | ||
| "version": "0.1.0", | ||
| "modulePrefix": "streams" | ||
| } | ||
| } | ||
| }, | ||
| "moduleInfo": { | ||
| "orgName": "ballerinax", | ||
| "moduleName": "test.streams", | ||
| "packageName": "test.streams", | ||
| "version": "0.1.0", | ||
| "modulePrefix": "streams" | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.