-
Notifications
You must be signed in to change notification settings - Fork 36
Fix data mapping function detection to exclude regular and natural expression functions in data_mappings.bal #380
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
Closed
Closed
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
61d7a54
Initial plan
Copilot bfeef35
Fix data mapping function detection in FunctionSearchCommand
Copilot f4ce62e
Add isDataMappingFunction helper method to CommonUtils
Copilot 4a49892
Handle natural expression functions in data_mappings.bal
Copilot d02ae8f
Fix checkstyle line length error in CommonUtils.java
Copilot 6494374
Update test
dulajdilshan 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
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
124 changes: 124 additions & 0 deletions
124
...tension/src/test/resources/search/config/functions/custom_functions_in_data_mappings.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,124 @@ | ||
| { | ||
| "description": "Functions in data_mappings.bal - only expression-bodied functions should be marked as data mapping functions", | ||
| "kind": "FUNCTION", | ||
| "source": "custom_func_proj/main.bal", | ||
| "position": { | ||
| "startLine": { | ||
| "line": 2, | ||
| "offset": 0 | ||
| }, | ||
| "endLine": { | ||
| "line": 4, | ||
| "offset": 1 | ||
| } | ||
| }, | ||
| "queryMap": {}, | ||
| "categories": [ | ||
| { | ||
| "metadata": { | ||
| "label": "Current Integration", | ||
| "description": "Functions defined within the current integration", | ||
| "keywords": [ | ||
| "Project", | ||
| "Local", | ||
| "Function" | ||
| ] | ||
| }, | ||
| "items": [ | ||
| { | ||
| "metadata": { | ||
| "label": "customHelper", | ||
| "description": null, | ||
| "data": { | ||
| "isDataMappedFunction": false, | ||
| "isAgentTool": false, | ||
| "isIsolatedFunction": false | ||
| } | ||
| }, | ||
| "codedata": { | ||
| "node": "FUNCTION_CALL", | ||
| "org": "test", | ||
| "module": "custom_func_proj", | ||
| "symbol": "customHelper", | ||
| "version": "0.1.0" | ||
| }, | ||
| "enabled": true | ||
| }, | ||
| { | ||
| "metadata": { | ||
| "label": "mapPersonToEmployee", | ||
| "description": null, | ||
| "data": { | ||
| "isDataMappedFunction": true, | ||
| "isAgentTool": false, | ||
| "isIsolatedFunction": false | ||
| } | ||
| }, | ||
| "codedata": { | ||
| "node": "FUNCTION_CALL", | ||
| "org": "test", | ||
| "module": "custom_func_proj", | ||
| "symbol": "mapPersonToEmployee", | ||
| "version": "0.1.0" | ||
| }, | ||
| "enabled": true | ||
| }, | ||
| { | ||
| "metadata": { | ||
| "label": "validateAge", | ||
| "description": null, | ||
| "data": { | ||
| "isDataMappedFunction": false, | ||
| "isAgentTool": false, | ||
| "isIsolatedFunction": true | ||
| } | ||
| }, | ||
| "codedata": { | ||
| "node": "FUNCTION_CALL", | ||
| "org": "test", | ||
| "module": "custom_func_proj", | ||
| "symbol": "validateAge", | ||
| "version": "0.1.0" | ||
| }, | ||
| "enabled": true | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "metadata": { | ||
| "label": "Agent Tools", | ||
| "description": "Functions used as agent tools", | ||
| "keywords": [ | ||
| "Project", | ||
| "Local", | ||
| "Function" | ||
| ] | ||
| }, | ||
| "items": [] | ||
| }, | ||
| { | ||
| "metadata": { | ||
| "label": "Imported Functions", | ||
| "description": "Functions imported from other integrations", | ||
| "keywords": [ | ||
| "Imported", | ||
| "Function", | ||
| "Library" | ||
| ] | ||
| }, | ||
| "items": [] | ||
| }, | ||
| { | ||
| "metadata": { | ||
| "label": "Available Functions", | ||
| "description": "Functions available in the library", | ||
| "keywords": [ | ||
| "Available", | ||
| "Function", | ||
| "Library" | ||
| ] | ||
| }, | ||
| "items": [] | ||
| } | ||
| ] | ||
| } |
4 changes: 4 additions & 0 deletions
4
...l-generator-ls-extension/src/test/resources/search/source/custom_func_proj/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,4 @@ | ||
| [package] | ||
| org = "test" | ||
| name = "custom_func_proj" | ||
| version = "0.1.0" |
36 changes: 36 additions & 0 deletions
36
...enerator-ls-extension/src/test/resources/search/source/custom_func_proj/data_mappings.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,36 @@ | ||
| import ballerina/ai; | ||
|
|
||
| type Person record { | ||
| string name; | ||
| int age; | ||
| }; | ||
|
|
||
| type Employee record { | ||
| string fullName; | ||
| int age; | ||
| }; | ||
|
|
||
| // This is a data mapping function (expression-bodied) | ||
| function mapPersonToEmployee(Person person) returns Employee => { | ||
| fullName: person.name, | ||
| age: person.age | ||
| }; | ||
|
|
||
| // This is a custom function (regular function body), not a data mapping function | ||
| function customHelper(string input) returns string { | ||
| return "Processed: " + input; | ||
| } | ||
|
|
||
| // This is another custom function (regular function body) | ||
| isolated function validateAge(int age) returns boolean { | ||
| return age >= 18; | ||
| } | ||
|
|
||
| // This is a natural expression function - should be skipped entirely | ||
| function generateGreeting(string name) returns string|error => natural (check ai:getDefaultModelProvider()) { | ||
| **What to do** | ||
| Generate a personalized greeting for ${name} | ||
|
|
||
| **Output** | ||
| string - A friendly greeting message | ||
| }; |
5 changes: 5 additions & 0 deletions
5
...w-model-generator-ls-extension/src/test/resources/search/source/custom_func_proj/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,5 @@ | ||
| import ballerina/io; | ||
|
|
||
| public function main() { | ||
| io:println("Hello World"); | ||
| } |
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
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.