Fix adding missing imports when using imported type in config variables#664
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adds support for automatically importing required modules when configurable variables use types from external modules. The implementation adds import detection and insertion logic to the ConfigEditorV2Service.
Changes:
- Added new method
addImportEdits()to detect and add missing import statements for configurable variable types - Refactored to use a constant
LSfor line separators throughout the service - Added test resources for validating import addition functionality
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| ConfigEditorV2Service.java | Core implementation: added import detection/insertion logic via addImportEdits() method and refactored line separator usage |
| config_with_import.bal | Test resource file with existing import to validate import deduplication |
| config10.json | Test configuration for adding config variable requiring new import (has critical bugs in expected output) |
| config11.json | Test configuration for adding config variable with existing import |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...extension/src/main/java/io/ballerina/flowmodelgenerator/extension/ConfigEditorV2Service.java
Outdated
Show resolved
Hide resolved
...erator-ls-extension/src/test/resources/configurable_variables_v2_update/config/config10.json
Show resolved
Hide resolved
...extension/src/main/java/io/ballerina/flowmodelgenerator/extension/ConfigEditorV2Service.java
Outdated
Show resolved
Hide resolved
...extension/src/main/java/io/ballerina/flowmodelgenerator/extension/ConfigEditorV2Service.java
Show resolved
Hide resolved
...extension/src/main/java/io/ballerina/flowmodelgenerator/extension/ConfigEditorV2Service.java
Show resolved
Hide resolved
There was a problem hiding this comment.
@LakshanWeerasinghe Although this is not directly related to the current scope, we could add a few test cases to ensure that imported types are correctly removed when the corresponding config variables are deleted. We should also ensure that imports are removed only when they are not used elsewhere.
@NipunaRanasinghe We can address this in another PR. |
@LakshanWeerasinghe Ack, +1. Shall we please create a separate GH issue and tag here in that case? |
Purpose
$subject
Fixes wso2/product-ballerina-integrator#2024
Screen.Recording.2026-01-29.at.11.21.52.mov