-
Notifications
You must be signed in to change notification settings - Fork 36
Sync main with 1.6.x branch #711
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
Merged
NipunaRanasinghe
merged 11 commits into
ballerina-platform:main
from
NipunaRanasinghe:1.6-main-sync
Feb 17, 2026
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7e71687
Fix worker name duplication
pasindufernando1 27ef571
Add test coverage
pasindufernando1 322193b
Merge remote-tracking branch 'upstream/1.6.x' into 547FixBE
pasindufernando1 0d4e2b8
Resolve langlib typeNames to their supertypes
pasindufernando1 d6c4e15
Hide result type in inferred type scenarios
pasindufernando1 236b842
Update getSourceCode to handle lang lib functions
pasindufernando1 f159137
Minor refactoring
pasindufernando1 5208ae2
Address PR suggestion
pasindufernando1 1c5712a
Merge pull request #678 from pasindufernando1/547FixBE
pasindufernando1 acebc9d
Merge pull request #689 from pasindufernando1/1750Fix
LakshanWeerasinghe d97660f
Merge branch 'main' of https://github.com/ballerina-platform/ballerin…
NipunaRanasinghe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
99 changes: 99 additions & 0 deletions
99
...erator-core/src/main/java/io/ballerina/flowmodelgenerator/core/TypeParameterReplacer.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| /* | ||
| * Copyright (c) 2026, WSO2 LLC. (http://www.wso2.com) | ||
| * | ||
| * WSO2 LLC. licenses this file to you under the Apache License, | ||
| * Version 2.0 (the "License"); you may not use this file except | ||
| * in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package io.ballerina.flowmodelgenerator.core; | ||
|
|
||
| import java.util.Comparator; | ||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
|
|
||
| /** | ||
| * Utility class to replace generic lang type parameters with their super types. | ||
| * | ||
| * @since 1.7.0 | ||
| */ | ||
| public class TypeParameterReplacer { | ||
|
|
||
| private static final Map<String, String> TYPE_PARAMETER_REPLACEMENTS = new HashMap<>(); | ||
|
|
||
| static { | ||
| // lang.array type parameter replacements | ||
| TYPE_PARAMETER_REPLACEMENTS.put("array:Type1", "(any|error)"); | ||
| TYPE_PARAMETER_REPLACEMENTS.put("array:Type", "(any|error)"); | ||
| TYPE_PARAMETER_REPLACEMENTS.put("array:AnydataType", "(anydata|error)"); | ||
|
|
||
| // lang.error type parameter replacements | ||
| TYPE_PARAMETER_REPLACEMENTS.put("error:DetailType", "error:Detail"); | ||
|
|
||
| // lang.map type parameter replacements | ||
| TYPE_PARAMETER_REPLACEMENTS.put("map:Type1", "map<any|error>"); | ||
| TYPE_PARAMETER_REPLACEMENTS.put("map:Type", "map<any|error>"); | ||
|
|
||
| // lang.stream type parameter replacements | ||
| TYPE_PARAMETER_REPLACEMENTS.put("stream:Type1", "(any|error)"); | ||
| TYPE_PARAMETER_REPLACEMENTS.put("stream:Type", "(any|error)"); | ||
| TYPE_PARAMETER_REPLACEMENTS.put("stream:ErrorType", "error"); | ||
| TYPE_PARAMETER_REPLACEMENTS.put("stream:CompletionType", "error"); | ||
|
|
||
| // lang.xml type parameter replacements | ||
| TYPE_PARAMETER_REPLACEMENTS.put("xml:XmlType", "xml"); | ||
| TYPE_PARAMETER_REPLACEMENTS.put("xml:ItemType", | ||
| "(xml:Element|xml:Comment|xml:ProcessingInstruction|xml:Text)"); | ||
|
|
||
| // lang.table type parameter replacements | ||
| TYPE_PARAMETER_REPLACEMENTS.put("table:MapType1", "map<any|error>"); | ||
| TYPE_PARAMETER_REPLACEMENTS.put("table:MapType", "map<any|error>"); | ||
| TYPE_PARAMETER_REPLACEMENTS.put("table:KeyType", "anydata"); | ||
| TYPE_PARAMETER_REPLACEMENTS.put("table:Type", "(any|error)"); | ||
|
|
||
| // lang.value type parameter replacements | ||
| TYPE_PARAMETER_REPLACEMENTS.put("value:AnydataType", "anydata"); | ||
| TYPE_PARAMETER_REPLACEMENTS.put("value:Type", "(any|error)"); | ||
| } | ||
|
|
||
| public static List<String> getSortedPlaceholderValues() { | ||
| return Set.copyOf(TYPE_PARAMETER_REPLACEMENTS.values()).stream() | ||
| .sorted(Comparator.comparingInt(String::length).reversed()) | ||
| .toList(); | ||
| } | ||
|
|
||
| /** | ||
| * Replaces type parameters in a string value. | ||
| * | ||
| * @param original the original string | ||
| * @return the string with type parameters replaced | ||
| */ | ||
| public static String replaceTypeParameters(String original) { | ||
| if (original == null || original.isEmpty()) { | ||
| return original; | ||
| } | ||
|
|
||
| String result = original; | ||
| List<Map.Entry<String, String>> entries = TYPE_PARAMETER_REPLACEMENTS.entrySet().stream() | ||
| .sorted(Comparator.comparingInt((Map.Entry<String, String> e) -> e.getKey().length()).reversed()) | ||
| .toList(); | ||
|
|
||
| for (Map.Entry<String, String> entry : entries) { | ||
| result = result.replace(entry.getKey(), entry.getValue()); | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
| } |
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
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.