Fix duplicate identifier suggestion during new connection scenarios#691
Fix duplicate identifier suggestion during new connection scenarios#691pasindufernando1 wants to merge 4 commits intoballerina-platform:1.6.xfrom
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing touches🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Comment |
There was a problem hiding this comment.
Pull request overview
This PR addresses duplicate connector identifier suggestions in NEW_CONNECTION template generation by improving the symbol set used for name de-duplication, and adds a regression test fixture to reproduce the issue.
Changes:
- Add
TemplateContext#getAllModuleSymbolNames()to fetch module-level symbols without requiring a cursor position. - Override
NewConnectionBuilder#setReturnTypeProperties()to use module symbols for connection identifier de-duplication. - Add a new node-template test project + config to validate duplicate connection-name handling.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
.../node_template/source/duplicate_connector/connections.bal |
New test source with an existing module-level connection variable to force a duplicate-name scenario. |
.../node_template/source/duplicate_connector/Ballerina.toml |
New test package metadata for the duplicate-connector fixture project. |
.../node_template/config/new_duplicate_connection.json |
New node-template test case expecting a non-duplicating suggested connection identifier. |
.../NewConnectionBuilder.java |
Switch NEW_CONNECTION return-variable naming to use module symbols instead of visible symbols. |
.../NodeBuilder.java |
Add a module-symbol collection helper on TemplateContext. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...tor-ls-extension/src/test/resources/node_template/source/duplicate_connector/connections.bal
Outdated
Show resolved
Hide resolved
...core/src/main/java/io/ballerina/flowmodelgenerator/core/model/node/NewConnectionBuilder.java
Show resolved
Hide resolved
| properties() | ||
| .type(functionData.returnType(), false, functionData.importStatements(), hidden, | ||
| Property.RESULT_TYPE_LABEL) | ||
| .data(functionData.returnType(), context.getAllModuleSymbolNames(), label, doc); |
There was a problem hiding this comment.
Have two concerns regarding this:
- If we create a connection locally, then locally declared connections are not accounted for.
- Whatever you’re doing here should also be applied to other module-level artifacts, such as model providers.
Purpose
This PR fixes an issue where duplicate connector identifier names were being suggested, even when connection identifiers with the same name already existed.
The root cause was in the duplicate name detection logic. The getVisibleSymbols() was used without providing a valid position, which resulted in an empty symbol list and prevented proper duplicate detection.
To resolve this, for “NEW CONNECTION” scenarios, the implementation was updated to use moduleSymbols() instead of visibleSymbols(). This ensures that existing connector identifiers are correctly identified and prevents suggesting duplicate names.
Screen.Recording.2026-02-16.at.11.08.28.mov
Fixes : wso2/product-ballerina-integrator#2275