Fix var type resolution in diagram generator#677
Merged
pasindufernando1 merged 3 commits intoballerina-platform:1.6.xfrom Feb 9, 2026
Merged
Fix var type resolution in diagram generator#677pasindufernando1 merged 3 commits intoballerina-platform:1.6.xfrom
pasindufernando1 merged 3 commits intoballerina-platform:1.6.xfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the diagram generator where variable declarations using the var keyword were being resolved to their inferred types (e.g., string, int, json) instead of preserving the var keyword as written in the source code. The fix adds a check for the VAR_TYPE_DESC syntax kind in the FormBuilder.dataVariable() method before falling back to semantic type resolution.
Changes:
- Modified FormBuilder.dataVariable() to check for VAR_TYPE_DESC syntax kind and preserve "var" keyword
- Added new test case (variable9.json) with corresponding source file (variable.bal)
- Updated 20 existing test configuration files to expect "var" instead of resolved types
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| FormBuilder.java | Added VAR_TYPE_DESC check in dataVariable() method to preserve "var" keyword instead of resolving to inferred type |
| variable.bal | New test source file with simple function containing var declaration |
| variable9.json | New test configuration for the variable.bal test case |
| variable1.json | Updated expected type values from resolved types ("int") to "var" for var declarations |
| xml_payload.json | Updated expected type value from "xml:Element" to "var" |
| binary_data.json | Updated expected type value from "byte[3]" to "var" |
| flags1.json | Updated expected type values from "boolean" to "var" |
| comment9.json, comment10.json | Updated expected type values from "()" and "int" to "var" |
| foreach1.json, foreach2.json | Updated expected type values from "int" to "var" |
| match8.json | Updated expected type value from "int" to "var" |
| resource_action_call-http-get1.json | Updated expected type value from "json" to "var" |
| resource_action_call-http-post1.json | Updated expected type value from "json" to "var" |
| remote_action_call-http-get2.json | Updated expected type value from "json" to "var" |
| remote_action_call-http-post2.json | Updated expected type value from "json" to "var" |
| transaction1.json through transaction6.json | Updated expected type values from "()" to "var" |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
NipunaRanasinghe
approved these changes
Feb 9, 2026
54 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
This PR addresses fixing the diagram generator resolving var type declarations to their inferred types (e.g., string) instead of preserving the var keyword. The FormBuilder.dataVariable() method now checks for VAR_TYPE_DESC syntax kind before falling back to semantic type resolution.
Fixes : wso2/product-ballerina-integrator#1674