Skip to content
Merged
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 @@ -807,7 +807,7 @@ private ConvertedVariable convertedOutput(LetVariableDeclarationNode letVarDecla
}
String varName = ((CaptureBindingPatternNode) bindingPattern).variableName().text();
String jsonConversion = "jsondata:toJson(" + varName + ")";
String xmlConversion = "xml:toXml(" + varName + ")";
String xmlConversion = "xmldata:toXml(" + varName + ")";

String letExprSource = letExpr.toSourceCode().trim();
if (varName.equals(letExprSource) ||
Expand Down Expand Up @@ -1727,21 +1727,21 @@ public JsonElement deleteMapping(SemanticModel semanticModel, Path filePath, Jso

private ExpressionNode findConvertedVariable(LetExpressionNode letExpr) {
ExpressionNode expr = letExpr.expression();
if (expr.kind() != SyntaxKind.SIMPLE_NAME_REFERENCE) {
return expr;
}
String name = expr.toSourceCode().trim();
String exprSource = expr.toSourceCode().trim();
for (LetVariableDeclarationNode letVar : letExpr.letVarDeclarations()) {
BindingPatternNode bindingPattern = letVar.typedBindingPattern().bindingPattern();
if (bindingPattern.kind() != SyntaxKind.CAPTURE_BINDING_PATTERN) {
continue;
}
if (((CaptureBindingPatternNode) bindingPattern).variableName().text().equals(name)) {
expr = letVar.expression();
if (expr.kind() == SyntaxKind.LET_EXPRESSION) {
return ((LetExpressionNode) expr).expression();
String varName = ((CaptureBindingPatternNode) bindingPattern).variableName().text();
String jsonConversion = "jsondata:toJson(" + varName + ")";
String xmlConversion = "xmldata:toXml(" + varName + ")";
if (varName.equals(exprSource) || jsonConversion.equals(exprSource) || xmlConversion.equals(exprSource)) {
ExpressionNode letVarExpr = letVar.expression();
if (letVarExpr.kind() == SyntaxKind.LET_EXPRESSION) {
return ((LetExpressionNode) letVarExpr).expression();
} else {
return expr;
return letVarExpr;
}
}
}
Expand Down Expand Up @@ -1781,7 +1781,7 @@ private ExpressionNode getMappingExpr(Node node) {
String varName = ((CaptureBindingPatternNode) bindingPatternNode).variableName().text();
String letExprSource = letExpr.toSourceCode().trim();
String jsonConversion = "jsondata:toJson(" + varName + ")";
String xmlConversion = "xml:toXml(" + varName + ")";
String xmlConversion = "xmldata:toXml(" + varName + ")";
if (varName.equals(letExprSource) ||
jsonConversion.equals(letExprSource) || xmlConversion.equals(letExprSource)) {
return letVarDeclaration.expression();
Expand Down Expand Up @@ -3881,16 +3881,14 @@ public JsonElement convertType(Path filePath, SemanticModel semanticModel, JsonE
CommonUtils.toRange(letVar.typedBindingPattern().typeDescriptor().lineRange()), typeName));
}
} else {
SeparatedNodeList<LetVariableDeclarationNode> letVarDeclarationNodes = letExpr.letVarDeclarations();
if (codedata.isNew() != null && codedata.isNew()) {
String statement = String.format(", %s %sConverted = check %s.ensureType()", typeName, variableName,
String statement = String.format(" %s %sConverted = check %s.ensureType(),", typeName, variableName,
variableName);
LinePosition linePosition =
letVarDeclarationNodes.get(letVarDeclarationNodes.size() - 1).lineRange().endLine();
textEdits.add(new TextEdit(CommonUtils.toRange(linePosition), statement));
textEdits.add(
new TextEdit(CommonUtils.toRange(letExpr.letKeyword().lineRange().endLine()), statement));
addErrorReturn(functionDefinitionNode, semanticModel, textEdits);
} else {
LetVariableDeclarationNode letVar = getMatchingLetVar(letVarDeclarationNodes, variableName);
LetVariableDeclarationNode letVar = getMatchingLetVar(letExpr.letVarDeclarations(), variableName);
textEdits.add(new TextEdit(
CommonUtils.toRange(letVar.typedBindingPattern().typeDescriptor().lineRange()), typeName));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
"range": {
"start": {
"line": 19,
"character": 56
"character": 7
},
"end": {
"line": 19,
"character": 56
"character": 7
}
},
"newText": ", Student studentConverted = check student.ensureType()"
"newText": " Student studentConverted = check student.ensureType(),"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
"range": {
"start": {
"line": 23,
"character": 56
"character": 7
},
"end": {
"line": 23,
"character": 56
"character": 7
}
},
"newText": ", Student studentConverted = check student.ensureType()"
"newText": " Student studentConverted = check student.ensureType(),"
}
]
}
Expand Down
Loading