Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -145,6 +145,7 @@ protected Object[] getConfigsList() {
{Path.of("configurable_variable2.json")},
{Path.of("function_def7.json")},
{Path.of("variable53.json")},
{Path.of("variable55.json")},
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
{
"source": "variable1.bal",
"description": "Sample diagram node",
"codedata": {
"node": "VARIABLE",
"lineRange": {
"fileName": "variable1.bal",
"startLine": {
"line": 29,
"offset": 12
},
"endLine": {
"line": 29,
"offset": 38
}
},
"sourceCode": "Student student = {};"
},
"position": {
"line": 29,
"offset": 12
},
"propertyKey": "expression",
"targetField": "student",
"model": {
"inputs": [
{
"name": "CONST",
"displayName": "CONST",
"typeName": "string",
"kind": "string",
"category": "constant"
},
{
"fields": [],
"name": "myStudent",
"displayName": "myStudent",
"typeName": "Student",
"kind": "record",
"category": "module-variable",
"ref": "545732303"
},
{
"fields": [],
"name": "student",
"displayName": "student",
"typeName": "Student",
"kind": "record",
"category": "local-variable",
"ref": "545732303"
}
],
"output": {
"fields": [],
"name": "student",
"displayName": "student",
"typeName": "PurchaseDetails",
"kind": "record",
"ref": "2079257237"
},
"mappings": [],
"refs": {
"2079257237": {
"fields": [
{
"name": "rewardId",
"displayName": "rewardId",
"typeName": "string",
"kind": "string",
"optional": true
},
{
"name": "skuId",
"displayName": "skuId",
"typeName": "string",
"kind": "string",
"optional": true
},
{
"name": "quantity",
"displayName": "quantity",
"typeName": "int:Signed32",
"kind": "int:Signed32",
"optional": true
}
],
"typeName": "PurchaseDetails",
"kind": "record"
},
"545732303": {
"fields": [
{
"name": "username",
"displayName": "username",
"typeName": "string",
"kind": "string",
"optional": false
},
{
"name": "password",
"displayName": "password",
"typeName": "string",
"kind": "string",
"optional": false
},
{
"name": "'record",
"displayName": "'record",
"typeName": "string",
"kind": "string",
"optional": false
},
{
"name": "data",
"displayName": "data",
"typeName": "json",
"kind": "json",
"optional": false
},
{
"name": "info",
"displayName": "info",
"typeName": "any",
"kind": "any",
"optional": false
}
],
"typeName": "Student",
"kind": "record"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -321,37 +321,78 @@ public static RefType fromSemanticSymbol(TypeSymbol symbol, String name, ModuleI
tupleType.memberTypes.add(refType);
}
return tupleType;
} else if (kind == TypeDescKind.REGEXP) {
return new RefType("regexp:RegExp");
}

throw new UnsupportedOperationException(
"Unsupported type kind: " + kind + " for symbol: " + symbol.getName().orElse("unknown"));
}

private static RefType getPrimitiveType(TypeDescKind kind, String name) {
if (kind == TypeDescKind.INT || kind == TypeDescKind.STRING || kind == TypeDescKind.FLOAT ||
kind == TypeDescKind.BOOLEAN || kind == TypeDescKind.NIL || kind == TypeDescKind.DECIMAL ||
kind == TypeDescKind.NEVER) {
return createPrimitiveRefType(kind, name);
String primitiveTypeName = getPrimitiveTypeName(kind);
if (primitiveTypeName == null) {
return null;
}
return null;
}

private static RefType createPrimitiveRefType(TypeDescKind kind, String name) {
RefType refType = new RefType(name);
refType.typeName = switch (kind) {
case INT -> "int";
case STRING -> "string";
case FLOAT -> "float";
case BOOLEAN -> "boolean";
case NIL -> "()";
case DECIMAL -> "decimal";
case NEVER -> "never";
default -> throw new UnsupportedOperationException("Unsupported primitive type: " + kind);
};
refType.name = refType.typeName;
refType.typeName = primitiveTypeName;
refType.name = primitiveTypeName;
return refType;
}

private static String getPrimitiveTypeName(TypeDescKind kind) {
switch (kind) {
case INT -> {
return "int";
}
case INT_SIGNED8 -> {
return "int:Signed8";
}
case INT_SIGNED16 -> {
return "int:Signed16";
}
case INT_SIGNED32 -> {
return "int:Signed32";
}
case INT_UNSIGNED8 -> {
return "int:Unsigned8";
}
case INT_UNSIGNED16 -> {
return "int:Unsigned16";
}
case INT_UNSIGNED32 -> {
return "int:Unsigned32";
}
case STRING -> {
return "string";
}
case FLOAT -> {
return "float";
}
case BOOLEAN -> {
return "boolean";
}
case NIL -> {
return "()";
}
case DECIMAL -> {
return "decimal";
}
case BYTE -> {
return "byte";
}
case STRING_CHAR -> {
return "string:Char";
}
case NEVER -> {
return "never";
}
default -> {
return null;
}
}
}


private static ModuleInfo createTypeInfo(ModuleID moduleID) {
return new ModuleInfo(moduleID.orgName(),
Expand Down
Loading