ballerina-lang icon indicating copy to clipboard operation
ballerina-lang copied to clipboard

[Improvement]: Test connection code lens

Open shafreenAnfar opened this issue 1 year ago • 1 comments

Description

Can we get a code lens to test the db connection. Like run.

Screenshot 2024-04-05 at 10 41 54 AM

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

shafreenAnfar avatar Apr 05 '24 05:04 shafreenAnfar

@shafreenAnfar, Just to clarify more, Do you suggest the code lens once the db is defined or when db is used?

KavinduZoysa avatar Apr 05 '24 05:04 KavinduZoysa

The functionality is similar to how IntelliJ tests the database connection with the Test Connection button after capturing user's parameters.

image

For each such connector initialization, VS Code should provide a Test code lens on top of the statement to execute this functionality. There are several concerns associated with the implementation of the code lens.

  1. There can be variables defined previously that are relevant to the connector initialization. Since there are two types, there is a specific approach to handle each such case.
    1. We can prompt a form (requiring a new UI for this) for the runtime variables. The language server can determine properties required to represent variable input based on the type and function signature.
    2. Otherwise, if it is a constant, we can use that value since it is available at compile-time. Still, the form can be provided with the constant value filled in as a default value.
  2. There can be different types of connectors and different ways to check the connection for each. Therefore, we have to consider how we can scale the respective code lens to each case. Ideally, the LS should provide a framework to support this code lens, and the respective library should provide the implementation of how to test the connection.

nipunayf avatar May 16 '24 11:05 nipunayf