ballerina-platform / ballerina-lang

The Ballerina Programming Language
https://ballerina.io/
Apache License 2.0
3.59k stars 740 forks source link

[New Feature]: Code action to add configurable values to `Config.toml` #43016

Closed LakshanWeerasinghe closed 2 months ago

LakshanWeerasinghe commented 3 months ago

Description

$subject

This code action must perform the following functions:

Describe your problem(s)

No response

Describe your solution(s)

No response

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

LakshanWeerasinghe commented 3 months ago

There are two scenarios to consider:

Case 1: Config.toml is not present

In this scenario, we need to verify if there are more than one configurable variables present. If so, we can send a resolvable code action with a command to create the Config.toml from the VS Code plugin. The subsequent code action resolution phase will calculate the necessary text edits and apply them to the Config.toml.

Case 2: Config.toml is present

When Config.toml is present, we must parse the existing Config.toml to identify the configurable variables in the project. Then, we need to find the differences between the existing Config.toml and the current project configuration. Due to the complexity of this computation, having a code action for this case as a resolvable code action is not beneficial.

LakshanWeerasinghe commented 3 months ago

In order to retrieve the configurable variables in a project we can use the ConfigReader. But it won't give the default values for the configurable variables. So we need to address this issue.