Skip to content
Draft
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,15 @@ public CompletableFuture<DataMapperSourceResponse> getSource(DataMapperSourceReq
try {
Path filePath = Path.of(request.filePath());
this.workspaceManager.loadProject(filePath);
Optional<SemanticModel> semanticModel = this.workspaceManager.semanticModel(filePath);
Optional<Document> document = this.workspaceManager.document(filePath);
if (document.isEmpty()) {
if (document.isEmpty() || semanticModel.isEmpty()) {
return response;
}

DataMapManager dataMapManager = new DataMapManager(document.get());
response.setTextEdits(dataMapManager.getSource(filePath, request.codedata(), request.mapping(),
request.targetField()));
response.setTextEdits(dataMapManager.getSource(semanticModel.get(), filePath, request.codedata(),
request.mapping(), request.targetField()));
} catch (Throwable e) {
response.setError(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ protected Object[] getConfigsList() {
{Path.of("variable10.json")},
{Path.of("variable11.json")},
{Path.of("query_collect.json")},
{Path.of("query_collect2.json")}

{Path.of("query_collect2.json")},
{Path.of("tuple_member.json")}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ protected Object[] getConfigsList() {
{Path.of("query29.json")},
{Path.of("variable58.json")},
{Path.of("variable59.json")},
{Path.of("tuple.json")},
{Path.of("tuple_based_transformation.json")},
{Path.of("tuple_based_transformation2.json")},
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ protected Object[] getConfigsList() {
{Path.of("query7.json")},
{Path.of("query8.json")},
{Path.of("variable20.json")},
{Path.of("tuple_mapping.json")},
{Path.of("tuple_mapping2.json")},
{Path.of("tuple_transformation.json")},
{Path.of("tuple_based_query.json")}
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
{
"source": "variable50.bal",
"description": "Sample diagram node",
"codedata": {
"node": "VARIABLE",
"lineRange": {
"fileName": "variable50.bal",
"startLine": {
"line": 17,
"offset": 8
},
"endLine": {
"line": 17,
"offset": 39
}
},
"sourceCode": "Bar[] bars = [\n {a: 1, b: 3},\n (from var baz in bazs\n select {a: baz.x, b: baz.y})[0]\n ];"
},
"position": {
"line": 17,
"offset": 8
},
"targetField": "person",
"model": {
"inputs": [
{
"members": [
{
"name": "[0]",
"displayName": "data[0]",
"typeName": "int",
"kind": "int"
},
{
"name": "[1]",
"displayName": "data[1]",
"typeName": "string",
"kind": "string"
},
{
"name": "[2]",
"displayName": "data[2]",
"typeName": "float",
"kind": "float"
}
],
"name": "data",
"displayName": "data",
"typeName": "[int, string, float]",
"kind": "tuple",
"category": "local-variable"
}
],
"output": {
"fields": [],
"name": "person",
"displayName": "person",
"typeName": "Person",
"kind": "record",
"ref": "887620673"
},
"mappings": [
{
"output": "person.age",
"inputs": [
"data[0]"
],
"expression": "data[0]",
"diagnostics": [],
"elements": [],
"isQueryExpression": false,
"isFunctionCall": false
}
],
"refs": {
"887620673": {
"fields": [
{
"name": "name",
"displayName": "name",
"typeName": "string",
"kind": "string",
"optional": false
},
{
"name": "age",
"displayName": "age",
"typeName": "int",
"kind": "int",
"optional": false
},
{
"members": [
{
"name": "[0]",
"displayName": "data[0]",
"typeName": "int",
"kind": "int"
},
{
"name": "[1]",
"displayName": "data[1]",
"typeName": "string",
"kind": "string"
},
{
"name": "[2]",
"displayName": "data[2]",
"typeName": "float",
"kind": "float"
}
],
"name": "data",
"displayName": "data",
"typeName": "[int, string, float]",
"kind": "tuple",
"optional": false
}
],
"typeName": "Person",
"kind": "record"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
{
"source": "tupleBasedTransformation.bal",
"description": "Sample diagram node",
"codedata": {
"node": "VARIABLE",
"lineRange": {
"fileName": "tupleBasedTransformation.bal",
"startLine": {
"line": 28,
"offset": 0
},
"endLine": {
"line": 28,
"offset": 123
}
},
"sourceCode": "Bar[] bars = [\n {a: 1, b: 3},\n (from var baz in bazs\n select {a: baz.x, b: baz.y})[0]\n ];"
},
"position": {
"line": 28,
"offset": 91
},
"targetField": "transform1",
"model": {
"inputs": [
{
"fields": [],
"name": "course",
"displayName": "course",
"typeName": "Course",
"kind": "record",
"category": "parameter",
"ref": "524765447"
},
{
"fields": [],
"name": "person",
"displayName": "person",
"typeName": "DetailedPerson",
"kind": "record",
"category": "parameter",
"ref": "-692431599"
}
],
"output": {
"members": [
{
"name": "[0]",
"displayName": "transform1[0]",
"typeName": "int",
"kind": "int"
},
{
"name": "[1]",
"displayName": "transform1[1]",
"typeName": "string",
"kind": "string"
},
{
"fields": [],
"name": "[2]",
"displayName": "transform1[2]",
"typeName": "Course",
"kind": "record",
"ref": "524765447"
}
],
"name": "transform1",
"displayName": "transform1",
"typeName": "[int, string, Course]",
"kind": "tuple"
},
"mappings": [
{
"output": "transform1",
"inputs": [],
"expression": "[0, person.id, {id: person.id}]",
"diagnostics": [
{
"message": "missing non-defaultable required record field 'credits'",
"code": "BCE2520"
},
{
"message": "missing non-defaultable required record field 'name'",
"code": "BCE2520"
}
],
"elements": [
{
"mappings": [
{
"output": "transform1[0]",
"inputs": [],
"expression": "0",
"diagnostics": [],
"elements": [],
"isQueryExpression": false,
"isFunctionCall": false
}
]
},
{
"mappings": [
{
"output": "transform1[1]",
"inputs": [
"person.id"
],
"expression": "person.id",
"diagnostics": [],
"elements": [],
"isQueryExpression": false,
"isFunctionCall": false
}
]
},
{
"mappings": [
{
"output": "transform1[2].id",
"inputs": [
"person.id"
],
"expression": "person.id",
"diagnostics": [],
"elements": [],
"isQueryExpression": false,
"isFunctionCall": false
}
]
}
]
}
],
"refs": {
"-692431599": {
"fields": [
{
"name": "id",
"displayName": "id",
"typeName": "string",
"kind": "string",
"optional": false
},
{
"name": "name",
"displayName": "name",
"typeName": "string",
"kind": "string",
"optional": false
}
],
"typeName": "DetailedPerson",
"kind": "record"
},
"524765447": {
"fields": [
{
"name": "id",
"displayName": "id",
"typeName": "string",
"kind": "string",
"optional": false
},
{
"name": "name",
"displayName": "name",
"typeName": "string",
"kind": "string",
"optional": false
},
{
"name": "credits",
"displayName": "credits",
"typeName": "float",
"kind": "float",
"optional": false
}
],
"typeName": "Course",
"kind": "record"
}
}
}
}
Loading
Loading