Skip to content

Comments

Add lang lib related function support#689

Merged
LakshanWeerasinghe merged 5 commits intoballerina-platform:1.6.xfrom
pasindufernando1:1750Fix
Feb 16, 2026
Merged

Add lang lib related function support#689
LakshanWeerasinghe merged 5 commits intoballerina-platform:1.6.xfrom
pasindufernando1:1750Fix

Conversation

@pasindufernando1
Copy link
Contributor

@pasindufernando1 pasindufernando1 commented Feb 11, 2026

Purpose

This PR addresses three aspects related to adding support to lang lib function usage via low code

  1. Resolve langlib typeNames to their supertypes — Introduced TypeParameterReplacer to substitute internal lang lib type parameters (e.g. array:Type, stream:ErrorType) with their human-readable supertypes (e.g. (any|error),
    error) throughout the form/property model.
  2. Hide result type in inferred type scenarios — When a type was replaced by a supertype placeholder, the result type field is hidden in the UI since showing a generic (any|error) to the user isn't useful.
  3. Update getSourceCode to handle lang lib functions — At source generation time, infers the concrete return type by looking up the actual variable's type via the semantic model during lang lib scenarios

Fixes : wso2/product-ballerina-integrator#1750

Now the experience looks like below, where the return type is hidden for lang lib related functions and the actual type is inferred during the saving process

Screen.Recording.2026-02-16.at.10.00.26.mov

Copilot AI review requested due to automatic review settings February 11, 2026 10:53
@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@pasindufernando1 pasindufernando1 changed the title 1750 fix Add lang lib related function support Feb 11, 2026
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 comprehensive support for Ballerina lang lib function usage in the low-code flow model generator. The implementation addresses three key aspects: (1) type parameter replacement to convert internal lang lib type parameters (e.g., array:Type, stream:ErrorType) into human-readable supertypes (e.g., (any|error), error), (2) automatic hiding of result type fields in the UI when types are replaced by generic placeholders, and (3) enhanced source code generation that infers concrete return types by analyzing actual variable types via the semantic model during lang lib function calls.

Changes:

  • Introduced TypeParameterReplacer utility class to systematically replace lang lib internal type parameters with their corresponding supertypes across multiple lang lib modules (array, error, map, stream, xml, table, value)
  • Enhanced CallBuilder with resolveLangLibReturnType method that dynamically resolves concrete return types at source generation time by inspecting variable types through the semantic model
  • Updated test configurations for lang lib functions to reflect the new type parameter replacements and proper type hiding behavior

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
TypeParameterReplacer.java New utility class providing systematic type parameter replacement for lang lib modules with mappings for array, error, map, stream, xml, table, and value modules
CallBuilder.java Added lang lib detection, return type resolution logic, and concrete type inference by analyzing visible symbols through the semantic model
FunctionCall.java Integrated lang lib return type resolution before falling back to type inference
MethodCall.java Integrated lang lib return type resolution for method call scenarios
SourceBuilder.java Added newVariableWithType method to support explicit type specification
Property.java Integrated type parameter replacement in ballerinaType setter
FormBuilder.java Applied type parameter replacement to type and returnType properties, with automatic hiding when replacement occurs
ModelGeneratorTest.java Uncommented updateConfig call (typically kept commented across test suite)
function_call-lang-lib_5.json New test configuration for array:enumerate function demonstrating type resolution from CSV[] to [int, CSV][]
lang_lib-*.json Updated test configurations for various lang lib functions (array, error, map, stream, table) with replaced type parameters and hidden result types
function_call/main.bal New test source file for function call scenarios
function_call-langlib.bal Additional test source file for lang lib function call scenarios
Ballerina.toml Test project configuration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@nipunayf nipunayf marked this pull request as draft February 11, 2026 16:21
@pasindufernando1 pasindufernando1 marked this pull request as ready for review February 16, 2026 04:24
@LakshanWeerasinghe LakshanWeerasinghe merged commit acebc9d into ballerina-platform:1.6.x Feb 16, 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.

2 participants