Fix generating unnecessary import statements when adding connections, model-providers, function-calls with reference-typed parameters#269
Merged
nipunayf merged 14 commits intoballerina-platform:mainfrom Sep 2, 2025
Conversation
c273565 to
addb061
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR addresses issues with generating unnecessary import statements when adding connections, model-providers, function-calls with reference-typed parameters. The fix centralizes import statement generation logic to avoid redundant imports and correctly handles module references.
Key changes:
- Modified
FunctionDataBuilder.javato conditionally generate import statements based on function type - Added comprehensive test data updates to reflect the corrected import behavior
- Enhanced import statement processing in
SourceBuilder.javato handle module references properly
Reviewed Changes
Copilot reviewed 77 out of 77 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| model-generator-commons/src/main/java/io/ballerina/modelgenerator/commons/FunctionDataBuilder.java | Core logic fix for conditional import statement generation based on function types |
| flow-model-generator/modules/flow-model-generator-core/src/main/java/io/ballerina/flowmodelgenerator/core/model/node/NewConnectionBuilder.java | Simplified connection builder import handling |
| flow-model-generator/modules/flow-model-generator-core/src/main/java/io/ballerina/flowmodelgenerator/core/model/node/ModelProviderBuilder.java | Added parameter property handling for model providers |
| flow-model-generator/modules/flow-model-generator-core/src/main/java/io/ballerina/flowmodelgenerator/core/model/SourceBuilder.java | Enhanced import processing with better module reference handling |
| flow-model-generator/modules/flow-model-generator-core/src/main/java/io/ballerina/flowmodelgenerator/core/model/Property.java | Property cleanup fix |
| Multiple test JSON files | Updated test data to reflect corrected import statement behavior |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
...generator-commons/src/main/java/io/ballerina/modelgenerator/commons/FunctionDataBuilder.java
Outdated
Show resolved
Hide resolved
...generator-commons/src/main/java/io/ballerina/modelgenerator/commons/FunctionDataBuilder.java
Show resolved
Hide resolved
...l-generator-core/src/main/java/io/ballerina/flowmodelgenerator/core/model/SourceBuilder.java
Show resolved
Hide resolved
Fix adding previously added imports to every property and resolve correct return type import.
…tor/commons/FunctionDataBuilder.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
6a531e3 to
fc804a7
Compare
KavinduZoysa
reviewed
Sep 1, 2025
| } | ||
|
|
||
| if (moduleName.equals(importModule)) { | ||
| imports.remove(orgName + "/" + moduleName); |
Contributor
There was a problem hiding this comment.
Without modifying the iterating set, shall we modify a duplicated set?
Contributor
Author
There was a problem hiding this comment.
Good catch. Will resolved this.
nipunayf
approved these changes
Sep 2, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Purpose
Addresses the following:
httpandballerina/aiimport wso2/product-ballerina-integrator#916httpimport and empty flow-diagram when adding a endpoint call wso2/product-ballerina-integrator#675Goals
Approach
User stories
Release note
Documentation
Training
Certification
Marketing
Automation tests
Security checks
Samples
Related PRs
Migrations (if applicable)
Test environment
Learning