Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -26,6 +26,7 @@
import io.ballerina.compiler.api.symbols.ConstantSymbol;
import io.ballerina.compiler.api.symbols.EnumSymbol;
import io.ballerina.compiler.api.symbols.FunctionSymbol;
import io.ballerina.compiler.api.symbols.FunctionTypeSymbol;
import io.ballerina.compiler.api.symbols.ModuleSymbol;
import io.ballerina.compiler.api.symbols.ParameterSymbol;
import io.ballerina.compiler.api.symbols.Qualifier;
Expand Down Expand Up @@ -1346,6 +1347,34 @@ private void genDeleteMappingSource(SemanticModel semanticModel, ExpressionNode
textEdits.add(new TextEdit(CommonUtils.toRange(expr.lineRange()), defaultVal));
}
}
} else if (parent.kind() == SyntaxKind.EXPRESSION_FUNCTION_BODY) {
Optional<Symbol> optSymbol = semanticModel.symbol(parent.parent());
if (optSymbol.isEmpty()) {
return;
}
Symbol symbol = optSymbol.get();
if (symbol.kind() == SymbolKind.FUNCTION) {
FunctionSymbol functionSymbol = (FunctionSymbol) symbol;
Optional<TypeSymbol> returnType = functionSymbol.typeDescriptor().returnTypeDescriptor();
if (returnType.isPresent()) {
TypeSymbol returnTypeSymbol = returnType.get();
String defaultVal = getDefaultValue(
CommonUtil.getRawType(returnTypeSymbol).typeKind().getName());
textEdits.add(new TextEdit(CommonUtils.toRange(expr.lineRange()), defaultVal));
}
}

} else if (parent.kind() == SyntaxKind.SELECT_CLAUSE) {
Optional<Symbol> optSymbol = semanticModel.symbol(expr);
if (optSymbol.isPresent()) {
Symbol symbol = optSymbol.get();
if (symbol.kind() == SymbolKind.VARIABLE) {
VariableSymbol varSymbol = (VariableSymbol) symbol;
String defaultVal = getDefaultValue(
CommonUtil.getRawType(varSymbol.typeDescriptor()).typeKind().getName());
textEdits.add(new TextEdit(CommonUtils.toRange(expr.lineRange()), defaultVal));
}
}
}
}
} else if (expr.kind() == SyntaxKind.MAPPING_CONSTRUCTOR) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ protected Object[] getConfigsList() {
{Path.of("function_defn1.json")},
{Path.of("function_defn2.json")},
{Path.of("variable6.json")},
{Path.of("variable7.json")}
{Path.of("variable7.json")},
{Path.of("variable8.json")},
{Path.of("variable9.json")},
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"source": "variable6.bal",
"description": "",
"codedata": {
"node": "VARIABLE",
"lineRange": {
"fileName": "variable6.bal",
"startLine": {
"line": 10,
"offset": 0
},
"endLine": {
"line": 10,
"offset": 52
}
}
},
"mapping": {
"output": "name",
"inputs": [
"arr1"
],
"expression": "arr1",
"diagnostics": [],
"elements": []
},
"targetField": "name",
"output": {
"variable6.bal": [
{
"range": {
"start": {
"line": 10,
"character": 47
},
"end": {
"line": 10,
"character": 51
}
},
"newText": "{}"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"source": "variable6.bal",
"description": "",
"codedata": {
"node": "VARIABLE",
"lineRange": {
"fileName": "variable6.bal",
"startLine": {
"line": 17,
"offset": 12
},
"endLine": {
"line": 20,
"offset": 14
}
}
},
"mapping": {
"output": "rec",
"inputs": [
"recItem"
],
"expression": "recItem\n",
"diagnostics": [],
"elements": [],
"isQueryExpression": false,
"isFunctionCall": false
},
"targetField": "v2.rec",
"output": {
"variable6.bal": [
{
"range": {
"start": {
"line": 19,
"character": 27
},
"end": {
"line": 19,
"character": 34
}
},
"newText": "{}"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import ballerina/http;

type RecType record {|
int i;
|};

type ArrType record {|
RecType[] rec;
|};

function name(ArrType arr1) returns ArrType => arr1;

service OASServiceType on new http:Listener(9090) {

resource function get pet() returns int|http:NotFound {
do {
ArrType v1 = {};
ArrType v2 = {
rec: from var recItem in v1.rec
select recItem
};
} on fail error e {
return http:NOT_FOUND;
}
}
}
Loading