Skip to content

Comments

Fix adding missing imports when using imported type in config variables#664

Merged
KavinduZoysa merged 3 commits intoballerina-platform:1.6.xfrom
LakshanWeerasinghe:fix#2024
Feb 3, 2026
Merged

Fix adding missing imports when using imported type in config variables#664
KavinduZoysa merged 3 commits intoballerina-platform:1.6.xfrom
LakshanWeerasinghe:fix#2024

Conversation

@LakshanWeerasinghe
Copy link
Contributor

Purpose

$subject

Fixes wso2/product-ballerina-integrator#2024

Screen.Recording.2026-01-29.at.11.21.52.mov

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 LS for 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.

Copy link
Contributor

@NipunaRanasinghe NipunaRanasinghe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

@LakshanWeerasinghe LakshanWeerasinghe changed the base branch from 1.5.x to 1.6.x February 3, 2026 04:24
@LakshanWeerasinghe
Copy link
Contributor Author

@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.

@NipunaRanasinghe
Copy link
Contributor

@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?

Copy link
Contributor

@NipunaRanasinghe NipunaRanasinghe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@KavinduZoysa KavinduZoysa merged commit 71238b9 into ballerina-platform:1.6.x Feb 3, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants