Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1ee9025
Fix version mismatch issues
samithkavishke Feb 2, 2026
001888a
Implement enum reordering and fix version mismatch issues
samithkavishke Feb 2, 2026
827ef1f
Fix the sqlite rebasing issue
samithkavishke Feb 2, 2026
545f705
Add copilot suggestions
samithkavishke Feb 2, 2026
6b86078
Add copilot suggestions
samithkavishke Feb 2, 2026
e740813
Resolve checkstyle warnings
samithkavishke Feb 3, 2026
d8f4894
Add expression map functionality
samithkavishke Feb 3, 2026
834ad6c
Fix versions
samithkavishke Feb 3, 2026
4ce366e
Resolve the review comments
samithkavishke Feb 3, 2026
315a2a8
Remove space lines:
samithkavishke Feb 3, 2026
02db70b
Correct import order
samithkavishke Feb 3, 2026
ef12c59
Resolve spot bugs
samithkavishke Feb 4, 2026
6645e27
Resolve conflicts
samithkavishke Feb 4, 2026
5ad632e
Remove the logic of mapping expression from main branch
samithkavishke Feb 4, 2026
c770f26
Resolve checkstyle issues
samithkavishke Feb 4, 2026
3ae5d24
Resolve version mismatch in oracle and sql
samithkavishke Feb 4, 2026
5e2ab0a
Resolve version mismatch in postgresql
samithkavishke Feb 4, 2026
63fa373
Address changes
samithkavishke Feb 5, 2026
1c72382
Fix version mismathc in ai.azure module
samithkavishke Feb 5, 2026
eac9b02
Add changes
samithkavishke Feb 5, 2026
b47fc21
Resolve the suggested changes
samithkavishke Feb 6, 2026
62eec47
Resolve checkstyle changes
samithkavishke Feb 6, 2026
ed01dd5
Resolve suggestions
samithkavishke Feb 9, 2026
50773f8
Add version resolution
samithkavishke Feb 9, 2026
3027dd5
Add resolve package logic to the function
samithkavishke Feb 10, 2026
e878999
Decouple the functionDatabuilder with the default value extraction logic
samithkavishke Feb 10, 2026
a569ddb
Remove unwanted code
samithkavishke Feb 16, 2026
7687cad
Add functiondata builder resolve package resolution all the places
samithkavishke Feb 16, 2026
4001847
Remove unwanted changes
samithkavishke Feb 16, 2026
2eb528f
Resolve conflicts
samithkavishke Feb 16, 2026
d386b5e
Resolve package resolution
samithkavishke Feb 16, 2026
30946f7
Refactor the resolvePackage logic
samithkavishke Feb 17, 2026
0e0b09d
Resolve failing test cases
samithkavishke Feb 17, 2026
2c2b9c9
Include compilation step in pull module executor
nipunayf Feb 17, 2026
554bda2
Resolve the suggestions
samithkavishke Feb 17, 2026
dfc82a8
Merge pull request #660 from samithkavishke/issue-2309
NipunaRanasinghe Feb 17, 2026
da277de
Merge pull request #708 from nipunayf/fix-pull-loop-16x
NipunaRanasinghe Feb 17, 2026
5c4ae45
Merge branch 'main' of https://github.com/ballerina-platform/ballerin…
NipunaRanasinghe Feb 17, 2026
b952411
Merge branch 'main' into 1.6.x-main-sync
NipunaRanasinghe Feb 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -734,10 +734,16 @@ public JsonArray getActions(JsonElement node, Path filePath, Project project, Wo
}
String parentSymbolName = variableSymbol.getName().orElseThrow();
String className = classSymbol.getName().orElseThrow();
ModuleInfo moduleInfo = classSymbol.getModule()
.map(moduleSymbol -> ModuleInfo.from(moduleSymbol.id()))
.orElse(null);

// Obtain methods of the connector
List<FunctionData> methodFunctionsData = new FunctionDataBuilder()
.parentSymbol(classSymbol)
.moduleInfo(moduleInfo)
.workspaceManager(workspaceManager)
.filePath(filePath)
.buildChildNodes();

for (FunctionData methodFunction : methodFunctionsData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import io.ballerina.modelgenerator.commons.FunctionData;
import io.ballerina.modelgenerator.commons.FunctionDataBuilder;
import io.ballerina.modelgenerator.commons.ModuleInfo;
import io.ballerina.modelgenerator.commons.PackageUtil;
import io.ballerina.projects.Document;
import io.ballerina.projects.Package;
import io.ballerina.tools.text.LinePosition;
Expand Down Expand Up @@ -387,11 +388,17 @@ private Optional<Category> getCategory(Symbol symbol, Predicate<ClassSymbol> con
.map(moduleSymbol -> ModuleInfo.from(moduleSymbol.id()))
.orElse(null);

// Create and set the resolved package for the function
Optional<Package> resolvedPackage = moduleInfo != null ?
PackageUtil.resolveModulePackage(moduleInfo.org(), moduleInfo.packageName(), moduleInfo.version()) :
Optional.empty();

FunctionDataBuilder functionDataBuilder = new FunctionDataBuilder()
.parentSymbol(classSymbol)
.parentSymbolType(className)
.project(pkg.project())
.moduleInfo(moduleInfo)
.resolvedPackage(resolvedPackage.orElse(null))
.enableIndex();

// Obtain methods of the classes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,10 @@
import io.ballerina.modelgenerator.commons.FunctionData;
import io.ballerina.modelgenerator.commons.FunctionDataBuilder;
import io.ballerina.modelgenerator.commons.ModuleInfo;
import io.ballerina.modelgenerator.commons.PackageUtil;
import io.ballerina.modelgenerator.commons.ParameterData;
import io.ballerina.projects.Document;
import io.ballerina.projects.Package;
import io.ballerina.projects.Project;
import io.ballerina.tools.diagnostics.Location;
import io.ballerina.tools.text.LinePosition;
Expand Down Expand Up @@ -760,11 +762,16 @@ private void setFunctionProperties(String functionName, ExpressionNode expressio
RemoteMethodCallActionNode remoteMethodCallActionNode,
MethodSymbol functionSymbol, String objName,
Map<String, Object> metadataData) {
Optional<Package> resolvedPackage = moduleInfo != null ?
PackageUtil.resolveModulePackage(moduleInfo.org(), moduleInfo.packageName(), moduleInfo.version()) :
Optional.empty();

FunctionDataBuilder functionDataBuilder = new FunctionDataBuilder()
.name(functionName)
.functionSymbol(functionSymbol)
.semanticModel(semanticModel)
.userModuleInfo(moduleInfo);
.userModuleInfo(moduleInfo)
.resolvedPackage(resolvedPackage.orElse(null));
FunctionData functionData = functionDataBuilder.build();

nodeBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public void setConcreteTemplateData(TemplateContext context) {
FunctionData functionData = new FunctionDataBuilder().parentSymbolType(AI_MCP_TOOL_KIT_CLASS)
.name(INIT_METHOD_NAME).moduleInfo(codedataModuleInfo).userModuleInfo(moduleInfo)
.lsClientLogger(context.lsClientLogger()).functionResultKind(FunctionData.Kind.MCP_TOOL_KIT)
.workspaceManager(context.workspaceManager())
.filePath(context.filePath())
.build();

metadata().label(functionData.packageName()).description(functionData.description())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,11 +553,27 @@ public Builder<T> typeWithTemplate(Property.ValueType valueType, Property templa
}

public Builder<T> typeWithExpression(TypeSymbol typeSymbol, ModuleInfo moduleInfo) {
return typeWithExpression(typeSymbol, moduleInfo, null, null, null);
return typeWithExpression(typeSymbol, moduleInfo, null, null);
}

public Builder<T> typeWithExpression(TypeSymbol typeSymbol, ModuleInfo moduleInfo, String defaultValue) {
return typeWithExpression(typeSymbol, moduleInfo, null, null, defaultValue, null);
}

public Builder<T> typeWithExpression(TypeSymbol typeSymbol, ModuleInfo moduleInfo,
Node value, SemanticModel semanticModel) {
return typeWithExpression(typeSymbol, moduleInfo, value, semanticModel, null, null);
}

public Builder<T> typeWithExpression(TypeSymbol typeSymbol, ModuleInfo moduleInfo,
Node value, SemanticModel semanticModel,
Property.Builder<?> builder) {
return typeWithExpression(typeSymbol, moduleInfo, value, semanticModel, null, builder);
}

public Builder<T> typeWithExpression(TypeSymbol typeSymbol, ModuleInfo moduleInfo,
Node value, SemanticModel semanticModel, Property.Builder<?> builder) {
Node value, SemanticModel semanticModel, String defaultValue,
Property.Builder<?> builder) {
if (typeSymbol == null) {
return this;
}
Expand Down Expand Up @@ -585,6 +601,10 @@ public Builder<T> typeWithExpression(TypeSymbol typeSymbol, ModuleInfo moduleInf

// If all the member types are singletons, treat it as a single-select option
if (allSingletons) {
// Reorder options so that the default value appears first
if (defaultValue != null && !defaultValue.isEmpty()) {
options = reorderOptionsByDefaultValue(options, defaultValue);
}
type().fieldType(ValueType.SINGLE_SELECT).options(options).stepOut();
} else {
// Handle union of primitive types by defining an input type for each primitive type
Expand Down Expand Up @@ -761,6 +781,39 @@ private ValueType findMatchingValueType(Node node) {
};
}

/**
* Reorders enum options so that the option matching the defaultValue appears first in the list.
* This improves user experience by showing the default option at the top of dropdown lists.
* Returns a new list without modifying the input list.
*
* @param options The list of Option objects to reorder
* @param defaultValue The default value to prioritize (may contain quotes)
* @return A new list with the default option first, or the original list if no match found
*/
private static List<Option> reorderOptionsByDefaultValue(List<Option> options, String defaultValue) {
if (options == null || options.isEmpty() || defaultValue == null || defaultValue.isEmpty()) {
return new ArrayList<>(options != null ? options : List.of());
}

String cleanedDefaultValue = CommonUtils.removeQuotes(defaultValue);
List<Option> reorderedOptions = new ArrayList<>(options);

// Find and move matching option to front
for (int i = 0; i < reorderedOptions.size(); i++) {
Option option = reorderedOptions.get(i);
String cleanedOptionValue = CommonUtils.removeQuotes(option.value());
if (cleanedDefaultValue.equalsIgnoreCase(cleanedOptionValue) ||
cleanedDefaultValue.equalsIgnoreCase(option.value())) {
if (i > 0) {
reorderedOptions.remove(i);
reorderedOptions.addFirst(option);
}
break;
}
}
return reorderedOptions;
}

public Builder<T> types(List<PropertyType> existingTypes) {
if (existingTypes != null) {
this.types.addAll(existingTypes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
import io.ballerina.modelgenerator.commons.PackageUtil;
import io.ballerina.modelgenerator.commons.ParameterData;
import io.ballerina.projects.Document;
import io.ballerina.projects.PackageDescriptor;
import io.ballerina.projects.Project;
import io.ballerina.projects.ProjectException;
import io.ballerina.tools.text.LinePosition;
import org.ballerinalang.langserver.common.utils.CommonUtil;
Expand Down Expand Up @@ -78,31 +76,22 @@ public void setConcreteConstData() {
public void setConcreteTemplateData(TemplateContext context) {
Codedata codedata = context.codedata();

ModuleInfo targetModuleInfo = new ModuleInfo(codedata.org(), codedata.packageName(), codedata.module(),
codedata.version());
FunctionDataBuilder functionDataBuilder = new FunctionDataBuilder()
.name(codedata.symbol())
.moduleInfo(new ModuleInfo(codedata.org(), codedata.packageName(), codedata.module(),
codedata.version()))
.moduleInfo(targetModuleInfo)
.lsClientLogger(context.lsClientLogger())
.functionResultKind(getFunctionResultKind())
.project(PackageUtil.loadProject(context.workspaceManager(), context.filePath()))
.userModuleInfo(moduleInfo);
.userModuleInfo(moduleInfo)
.workspaceManager(context.workspaceManager())
.filePath(context.filePath());

NodeKind functionNodeKind = getFunctionNodeKind();
if (functionNodeKind != NodeKind.FUNCTION_CALL) {
functionDataBuilder.parentSymbolType(codedata.object());
}

// Set the semantic model if the function is local
boolean isLocalFunction = isLocalFunction(context.workspaceManager(), context.filePath(), codedata);
if (isLocalFunction) {
WorkspaceManager workspaceManager = context.workspaceManager();
PackageUtil.loadProject(context.workspaceManager(), context.filePath());
context.workspaceManager().module(context.filePath())
.map(module -> ModuleInfo.from(module.descriptor()))
.ifPresent(functionDataBuilder::userModuleInfo);
SemanticModel semanticModel = workspaceManager.semanticModel(context.filePath()).orElseThrow();
functionDataBuilder.semanticModel(semanticModel);
}
FunctionData functionData = functionDataBuilder.build();

metadata()
Expand All @@ -129,7 +118,8 @@ public void setConcreteTemplateData(TemplateContext context) {
.label(Property.CONNECTION_LABEL)
.description(Property.CONNECTION_DOC)
.stepOut()
.type(Property.ValueType.EXPRESSION, isLocalFunction ? codedata.object() :
.type(Property.ValueType.EXPRESSION, PackageUtil.isLocalFunction(context.workspaceManager(),
context.filePath(), codedata.org(), codedata.module()) ? codedata.object() :
CommonUtils.getClassType(codedata.module(), codedata.object()))
.value(codedata.parentSymbol())
.hidden()
Expand Down Expand Up @@ -234,7 +224,8 @@ protected void setParameterProperties(FunctionData function) {
.selected(true)
.stepOut();
}
customPropBuilder.typeWithExpression(paramResult.typeSymbol(), moduleInfo);
customPropBuilder.typeWithExpression(paramResult.typeSymbol(), moduleInfo,
paramResult.defaultValue());
}
}

Expand Down Expand Up @@ -380,20 +371,4 @@ private static String resolveConcreteType(WorkspaceManager workspaceManager, Pat
}
}

protected static boolean isLocalFunction(WorkspaceManager workspaceManager, Path filePath, Codedata codedata) {
if (codedata.org() == null || codedata.module() == null) {
return false;
}
try {
Project project = workspaceManager.loadProject(filePath);
PackageDescriptor descriptor = project.currentPackage().descriptor();
String packageOrg = descriptor.org().value();
String packageName = descriptor.name().value();

return packageOrg.equals(codedata.org())
&& packageName.equals(codedata.module());
} catch (WorkspaceDocumentException | EventSyncException e) {
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ public void setConcreteTemplateData(TemplateContext context) {

FunctionData functionData = new FunctionDataBuilder().parentSymbolType(codedata.object())
.name(codedata.symbol()).moduleInfo(codedataModuleInfo).userModuleInfo(moduleInfo)
.workspaceManager(context.workspaceManager())
.filePath(context.filePath())
.lsClientLogger(context.lsClientLogger()).functionResultKind(FunctionData.Kind.CHUNKER)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public void setConcreteTemplateData(NodeBuilder.TemplateContext context) {
FunctionData functionData = new FunctionDataBuilder().parentSymbolType(codedata.object())
.name(codedata.symbol()).moduleInfo(codedataModuleInfo).userModuleInfo(moduleInfo)
.lsClientLogger(context.lsClientLogger()).functionResultKind(FunctionData.Kind.DATA_LOADER)
.workspaceManager(context.workspaceManager())
.filePath(context.filePath())
.build();

metadata().label(functionData.packageName()).description(functionData.description())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ public void setConcreteTemplateData(NodeBuilder.TemplateContext context) {
FunctionData functionData = new FunctionDataBuilder().moduleInfo(codedataModuleInfo).userModuleInfo(moduleInfo)
.parentSymbolType(codedata.object()).name(codedata.symbol())
.lsClientLogger(context.lsClientLogger()).functionResultKind(FunctionData.Kind.EMBEDDING_PROVIDER)
.workspaceManager(context.workspaceManager())
.filePath(context.filePath())
.build();

metadata().label(functionData.packageName()).description(functionData.description())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import io.ballerina.flowmodelgenerator.core.model.SourceBuilder;
import io.ballerina.flowmodelgenerator.core.utils.FlowNodeUtil;
import io.ballerina.modelgenerator.commons.FunctionData;
import io.ballerina.modelgenerator.commons.PackageUtil;
import org.eclipse.lsp4j.TextEdit;

import java.nio.file.Path;
Expand Down Expand Up @@ -60,7 +61,8 @@ public Map<Path, List<TextEdit>> toSource(SourceBuilder sourceBuilder) {
sourceBuilder.token().keyword(SyntaxKind.CHECK_KEYWORD);
}

if (isLocalFunction(sourceBuilder.workspaceManager, sourceBuilder.filePath, codedata)) {
if (PackageUtil.isLocalFunction(sourceBuilder.workspaceManager, sourceBuilder.filePath,
codedata.org(), codedata.module())) {
return sourceBuilder.token()
.name(codedata.symbol())
.stepOut()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public void setConcreteTemplateData(NodeBuilder.TemplateContext context) {
FunctionData functionData = new FunctionDataBuilder().parentSymbolType(codedata.object())
.name(codedata.symbol()).moduleInfo(codedataModuleInfo).userModuleInfo(moduleInfo)
.lsClientLogger(context.lsClientLogger()).functionResultKind(FunctionData.Kind.KNOWLEDGE_BASE)
.workspaceManager(context.workspaceManager())
.filePath(context.filePath())
.build();

metadata().label(functionData.packageName()).description(functionData.description())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public void setConcreteTemplateData(TemplateContext context) {
FunctionData functionData = new FunctionDataBuilder().moduleInfo(codedataModuleInfo).userModuleInfo(moduleInfo)
.parentSymbolType(codedata.object()).name(codedata.symbol())
.lsClientLogger(context.lsClientLogger()).functionResultKind(FunctionData.Kind.MEMORY)
.workspaceManager(context.workspaceManager())
.filePath(context.filePath())
.build();

metadata().label(functionData.packageName()).description(functionData.description())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public void setConcreteTemplateData(TemplateContext context) {
FunctionData functionData = new FunctionDataBuilder().moduleInfo(codedataModuleInfo).userModuleInfo(moduleInfo)
.parentSymbolType(codedata.object()).name(codedata.symbol())
.lsClientLogger(context.lsClientLogger()).functionResultKind(FunctionData.Kind.MEMORY_STORE)
.workspaceManager(context.workspaceManager())
.filePath(context.filePath())
.build();

metadata().label(functionData.packageName()).description(functionData.description())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public void setConcreteTemplateData(TemplateContext context) {
FunctionData functionData = new FunctionDataBuilder().moduleInfo(codedataModuleInfo).userModuleInfo(moduleInfo)
.parentSymbolType(codedata.object()).name(codedata.symbol())
.lsClientLogger(context.lsClientLogger()).functionResultKind(FunctionData.Kind.MODEL_PROVIDER)
.workspaceManager(context.workspaceManager())
.filePath(context.filePath())
.build();

metadata().label(functionData.packageName()).description(functionData.description())
Expand Down
Loading
Loading