Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implicitly add the import when opening the form of a node template #521

Merged
merged 13 commits into from
Dec 13, 2024

Conversation

nipunayf
Copy link
Contributor

Proposal

Currently, when opening a node form from the node palette, the imports required for the types used in the node are not automatically added to the source code. This results in unnecessary diagnostics about missing imports being displayed to users. This PR addresses this issue by automatically adding the required imports when opening a node form.

Approach

The implementation approach consists of four main components:

  • Added importStatements to the central index property table, using comma separation for multiple imports since only _ is allowed in org/package/module names
  • Implemented recursive processing for complex types (Unions, Tuples) to extract all required imports from member types
  • Enhanced property codedata to include importStatements for consistent communication between extension and server
  • Updated expression editor to automatically add both node-specific imports and dependent module imports (e.g., sql types for snowflake)

Security checks

@nipunayf nipunayf added the Area/FlowModel Related to the flow model generation LS extension label Dec 12, 2024
@LakshanWeerasinghe
Copy link
Contributor

how are we going to handle if user close the node template without saving anything?

@nipunayf
Copy link
Contributor Author

how are we going to handle if user close the node template without saving anything?

When the user opens the form, the LS starts a shadowed project and applies all changes to that shadow project. If the user closes without saving, the shadowed project is closed, and the state reverts to what it was before opening the expression editor.

@hasithaa hasithaa merged commit dc01386 into ballerina-platform:main Dec 13, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/FlowModel Related to the flow model generation LS extension
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants