Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix source id as VS Code extension needs proper value #2673

Merged
merged 4 commits into from
Mar 6, 2024
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 @@ -111,7 +111,7 @@ public void testPureInstanceClassMapping()
" firstName: $src.fullName->substring(0, $src.fullName->indexOf(' '))\\n" +
" }\\n" +
")\\n";
test("{\"code\": \"" + code + "\"}", "{\"isolatedLambdas\":{\"lambdas\":{}},\"modelDataContext\":{\"_type\":\"data\",\"elements\":[{\"_type\":\"mapping\",\"associationMappings\":[],\"classMappings\":[{\"_type\":\"pureInstance\",\"class\":\"meta::pure::mapping::modelToModel::test::shared::dest::Person\",\"classSourceInformation\":{\"endColumn\":64,\"endLine\":4,\"sourceId\":\"\",\"startColumn\":4,\"startLine\":4},\"id\":\"meta_pure_mapping_modelToModel_test_shared_dest_Person\",\"propertyMappings\":[{\"_type\":\"purePropertyMapping\",\"explodeProperty\":false,\"property\":{\"class\":\"meta::pure::mapping::modelToModel::test::shared::dest::Person\",\"property\":\"firstName\",\"sourceInformation\":{\"endColumn\":13,\"endLine\":7,\"sourceId\":\"meta::pure::mapping::modelToModel::test::simple::simpleModelMapping\",\"startColumn\":5,\"startLine\":7}},\"source\":\"meta_pure_mapping_modelToModel_test_shared_dest_Person\",\"sourceInformation\":{\"endColumn\":71,\"endLine\":7,\"sourceId\":\"meta::pure::mapping::modelToModel::test::simple::simpleModelMapping\",\"startColumn\":5,\"startLine\":7},\"transform\":{\"_type\":\"lambda\",\"body\":[{\"_type\":\"func\",\"function\":\"substring\",\"parameters\":[{\"_type\":\"property\",\"parameters\":[{\"_type\":\"var\",\"name\":\"src\",\"sourceInformation\":{\"endColumn\":19,\"endLine\":7,\"sourceId\":\"meta::pure::mapping::modelToModel::test::simple::simpleModelMapping\",\"startColumn\":16,\"startLine\":7}}],\"property\":\"fullName\",\"sourceInformation\":{\"endColumn\":28,\"endLine\":7,\"sourceId\":\"meta::pure::mapping::modelToModel::test::simple::simpleModelMapping\",\"startColumn\":21,\"startLine\":7}},{\"_type\":\"integer\",\"sourceInformation\":{\"endColumn\":41,\"endLine\":7,\"sourceId\":\"meta::pure::mapping::modelToModel::test::simple::simpleModelMapping\",\"startColumn\":41,\"startLine\":7},\"value\":0},{\"_type\":\"func\",\"function\":\"indexOf\",\"parameters\":[{\"_type\":\"property\",\"parameters\":[{\"_type\":\"var\",\"name\":\"src\",\"sourceInformation\":{\"endColumn\":47,\"endLine\":7,\"sourceId\":\"meta::pure::mapping::modelToModel::test::simple::simpleModelMapping\",\"startColumn\":44,\"startLine\":7}}],\"property\":\"fullName\",\"sourceInformation\":{\"endColumn\":56,\"endLine\":7,\"sourceId\":\"meta::pure::mapping::modelToModel::test::simple::simpleModelMapping\",\"startColumn\":49,\"startLine\":7}},{\"_type\":\"string\",\"sourceInformation\":{\"endColumn\":69,\"endLine\":7,\"sourceId\":\"meta::pure::mapping::modelToModel::test::simple::simpleModelMapping\",\"startColumn\":67,\"startLine\":7},\"value\":\" \"}],\"sourceInformation\":{\"endColumn\":65,\"endLine\":7,\"sourceId\":\"meta::pure::mapping::modelToModel::test::simple::simpleModelMapping\",\"startColumn\":59,\"startLine\":7}}],\"sourceInformation\":{\"endColumn\":39,\"endLine\":7,\"sourceId\":\"meta::pure::mapping::modelToModel::test::simple::simpleModelMapping\",\"startColumn\":31,\"startLine\":7}}],\"parameters\":[]}}],\"root\":true,\"sourceClassSourceInformation\":{\"endColumn\":72,\"endLine\":6,\"sourceId\":\"meta::pure::mapping::modelToModel::test::simple::simpleModelMapping\",\"startColumn\":10,\"startLine\":6},\"sourceInformation\":{\"endColumn\":3,\"endLine\":8,\"sourceId\":\"\",\"startColumn\":3,\"startLine\":4},\"srcClass\":\"meta::pure::mapping::modelToModel::test::shared::src::_S_Person\"}],\"enumerationMappings\":[],\"includedMappings\":[],\"name\":\"simpleModelMapping\",\"package\":\"meta::pure::mapping::modelToModel::test::simple\",\"sourceInformation\":{\"endColumn\":1,\"endLine\":9,\"sourceId\":\"\",\"startColumn\":1,\"startLine\":2},\"tests\":[]},{\"_type\":\"sectionIndex\",\"name\":\"SectionIndex\",\"package\":\"__internal__\",\"sections\":[{\"_type\":\"importAware\",\"elements\":[],\"imports\":[],\"parserName\":\"Pure\",\"sourceInformation\":{\"endColumn\":8,\"endLine\":1,\"sourceId\":\"\",\"startColumn\":1,\"startLine\":1}},{\"_type\":\"importAware\",\"elements\":[\"meta::pure::mapping::modelToModel::test::simple::simpleModelMapping\"],\"imports\":[],\"parserName\":\"Mapping\",\"sourceInformation\":{\"endColumn\":2,\"endLine\":11,\"sourceId\":\"\",\"startColumn\":8,\"startLine\":2}}]}]},\"renderStyle\":\"STANDARD\"}");
test("{\"code\": \"" + code + "\"}", "{\"isolatedLambdas\":{\"lambdas\":{}},\"modelDataContext\":{\"_type\":\"data\",\"elements\":[{\"_type\":\"mapping\",\"associationMappings\":[],\"classMappings\":[{\"_type\":\"pureInstance\",\"class\":\"meta::pure::mapping::modelToModel::test::shared::dest::Person\",\"classSourceInformation\":{\"endColumn\":64,\"endLine\":4,\"sourceId\":\"\",\"startColumn\":4,\"startLine\":4},\"id\":\"meta_pure_mapping_modelToModel_test_shared_dest_Person\",\"propertyMappings\":[{\"_type\":\"purePropertyMapping\",\"explodeProperty\":false,\"property\":{\"class\":\"meta::pure::mapping::modelToModel::test::shared::dest::Person\",\"property\":\"firstName\",\"sourceInformation\":{\"endColumn\":13,\"endLine\":7,\"sourceId\":\"\",\"startColumn\":5,\"startLine\":7}},\"source\":\"meta_pure_mapping_modelToModel_test_shared_dest_Person\",\"sourceInformation\":{\"endColumn\":71,\"endLine\":7,\"sourceId\":\"\",\"startColumn\":5,\"startLine\":7},\"transform\":{\"_type\":\"lambda\",\"body\":[{\"_type\":\"func\",\"function\":\"substring\",\"parameters\":[{\"_type\":\"property\",\"parameters\":[{\"_type\":\"var\",\"name\":\"src\",\"sourceInformation\":{\"endColumn\":19,\"endLine\":7,\"sourceId\":\"\",\"startColumn\":16,\"startLine\":7}}],\"property\":\"fullName\",\"sourceInformation\":{\"endColumn\":28,\"endLine\":7,\"sourceId\":\"\",\"startColumn\":21,\"startLine\":7}},{\"_type\":\"integer\",\"sourceInformation\":{\"endColumn\":41,\"endLine\":7,\"sourceId\":\"\",\"startColumn\":41,\"startLine\":7},\"value\":0},{\"_type\":\"func\",\"function\":\"indexOf\",\"parameters\":[{\"_type\":\"property\",\"parameters\":[{\"_type\":\"var\",\"name\":\"src\",\"sourceInformation\":{\"endColumn\":47,\"endLine\":7,\"sourceId\":\"\",\"startColumn\":44,\"startLine\":7}}],\"property\":\"fullName\",\"sourceInformation\":{\"endColumn\":56,\"endLine\":7,\"sourceId\":\"\",\"startColumn\":49,\"startLine\":7}},{\"_type\":\"string\",\"sourceInformation\":{\"endColumn\":69,\"endLine\":7,\"sourceId\":\"\",\"startColumn\":67,\"startLine\":7},\"value\":\" \"}],\"sourceInformation\":{\"endColumn\":65,\"endLine\":7,\"sourceId\":\"\",\"startColumn\":59,\"startLine\":7}}],\"sourceInformation\":{\"endColumn\":39,\"endLine\":7,\"sourceId\":\"\",\"startColumn\":31,\"startLine\":7}}],\"parameters\":[]}}],\"root\":true,\"sourceClassSourceInformation\":{\"endColumn\":72,\"endLine\":6,\"sourceId\":\"\",\"startColumn\":10,\"startLine\":6},\"sourceInformation\":{\"endColumn\":3,\"endLine\":8,\"sourceId\":\"\",\"startColumn\":3,\"startLine\":4},\"srcClass\":\"meta::pure::mapping::modelToModel::test::shared::src::_S_Person\"}],\"enumerationMappings\":[],\"includedMappings\":[],\"name\":\"simpleModelMapping\",\"package\":\"meta::pure::mapping::modelToModel::test::simple\",\"sourceInformation\":{\"endColumn\":1,\"endLine\":9,\"sourceId\":\"\",\"startColumn\":1,\"startLine\":2},\"tests\":[]},{\"_type\":\"sectionIndex\",\"name\":\"SectionIndex\",\"package\":\"__internal__\",\"sections\":[{\"_type\":\"importAware\",\"elements\":[],\"imports\":[],\"parserName\":\"Pure\",\"sourceInformation\":{\"endColumn\":8,\"endLine\":1,\"sourceId\":\"\",\"startColumn\":1,\"startLine\":1}},{\"_type\":\"importAware\",\"elements\":[\"meta::pure::mapping::modelToModel::test::simple::simpleModelMapping\"],\"imports\":[],\"parserName\":\"Mapping\",\"sourceInformation\":{\"endColumn\":2,\"endLine\":11,\"sourceId\":\"\",\"startColumn\":8,\"startLine\":2}}]}]},\"renderStyle\":\"STANDARD\"}");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private Mapping visitMappingElement(MappingParserGrammar.MappingElementContext c
int lineOffset = walkerSourceInformation.getLineOffset() + startLine - 1;
// only add current walker source information column offset if this is the first line
int columnOffset = (startLine == 1 ? walkerSourceInformation.getColumnOffset() : 0) + ctx.mappingElementBody().BRACE_OPEN().getSymbol().getCharPositionInLine() + ctx.mappingElementBody().BRACE_OPEN().getText().length();
ParseTreeWalkerSourceInformation mappingElementWalkerSourceInformation = new ParseTreeWalkerSourceInformation.Builder(mapping.getPath(), lineOffset, columnOffset).withReturnSourceInfo(this.walkerSourceInformation.getReturnSourceInfo()).build();
ParseTreeWalkerSourceInformation mappingElementWalkerSourceInformation = new ParseTreeWalkerSourceInformation.Builder(this.walkerSourceInformation.getSourceId(), lineOffset, columnOffset).withReturnSourceInfo(this.walkerSourceInformation.getReturnSourceInfo()).build();
MappingElementSourceCode mappingElementSourceCode = new MappingElementSourceCode(mappingElementCode, parserName, mappingElementWalkerSourceInformation, ctx, this.walkerSourceInformation);
MappingElementParser extraParser = this.extensions.getExtraMappingElementParser(mappingElementSourceCode.name);
if (extraParser == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"sourceInformation": {
"endColumn": 8,
"endLine": 7,
"sourceId": "mapping::simpleModelMapping",
"sourceId": "",
"startColumn": 5,
"startLine": 7
}
Expand All @@ -35,7 +35,7 @@
"sourceInformation": {
"endColumn": 19,
"endLine": 7,
"sourceId": "mapping::simpleModelMapping",
"sourceId": "",
"startColumn": 5,
"startLine": 7
},
Expand All @@ -51,7 +51,7 @@
"sourceInformation": {
"endColumn": 14,
"endLine": 7,
"sourceId": "mapping::simpleModelMapping",
"sourceId": "",
"startColumn": 11,
"startLine": 7
}
Expand All @@ -61,7 +61,7 @@
"sourceInformation": {
"endColumn": 19,
"endLine": 7,
"sourceId": "mapping::simpleModelMapping",
"sourceId": "",
"startColumn": 16,
"startLine": 7
}
Expand All @@ -75,7 +75,7 @@
"sourceClassSourceInformation": {
"endColumn": 27,
"endLine": 6,
"sourceId": "mapping::simpleModelMapping",
"sourceId": "",
"startColumn": 10,
"startLine": 6
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"sourceInformation": {
"endColumn": 8,
"endLine": 9,
"sourceId": "mapping::simpleModelMapping",
"sourceId": "",
"startColumn": 5,
"startLine": 9
}
Expand All @@ -35,7 +35,7 @@
"sourceInformation": {
"endColumn": 19,
"endLine": 9,
"sourceId": "mapping::simpleModelMapping",
"sourceId": "",
"startColumn": 5,
"startLine": 9
},
Expand All @@ -51,7 +51,7 @@
"sourceInformation": {
"endColumn": 14,
"endLine": 9,
"sourceId": "mapping::simpleModelMapping",
"sourceId": "",
"startColumn": 11,
"startLine": 9
}
Expand All @@ -61,7 +61,7 @@
"sourceInformation": {
"endColumn": 19,
"endLine": 9,
"sourceId": "mapping::simpleModelMapping",
"sourceId": "",
"startColumn": 16,
"startLine": 9
}
Expand All @@ -75,7 +75,7 @@
"sourceClassSourceInformation": {
"endColumn": 27,
"endLine": 8,
"sourceId": "mapping::simpleModelMapping",
"sourceId": "",
"startColumn": 10,
"startLine": 8
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1595,7 +1595,7 @@ public void testUnknownSetImplementationIdWarning() throws Exception

MutableList<Warning> warnings = res.getTwo().getWarnings();
Assert.assertEquals(1, warnings.size());
Assert.assertEquals("{\"sourceInformation\":{\"sourceId\":\"simple::simpleRelationalMappingInc\",\"startLine\":30,\"startColumn\":12,\"endLine\":30,\"endColumn\":43},\"message\":\"Error 'x' can't be found in the mapping simple::simpleRelationalMappingInc\"}", new ObjectMapper().writeValueAsString(warnings.get(0)));
Assert.assertEquals("{\"sourceInformation\":{\"sourceId\":\"\",\"startLine\":30,\"startColumn\":12,\"endLine\":30,\"endColumn\":43},\"message\":\"Error 'x' can't be found in the mapping simple::simpleRelationalMappingInc\"}", new ObjectMapper().writeValueAsString(warnings.get(0)));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1594,7 +1594,7 @@ public void testUnknownSetImplementationIdWarning() throws Exception

MutableList<Warning> warnings = res.getTwo().getWarnings();
Assert.assertEquals(1, warnings.size());
Assert.assertEquals("{\"sourceInformation\":{\"sourceId\":\"simple::simpleRelationalMappingInc\",\"startLine\":30,\"startColumn\":12,\"endLine\":30,\"endColumn\":43},\"message\":\"Error 'x' can't be found in the mapping simple::simpleRelationalMappingInc\"}", new ObjectMapper().writeValueAsString(warnings.get(0)));
Assert.assertEquals("{\"sourceInformation\":{\"sourceId\":\"\",\"startLine\":30,\"startColumn\":12,\"endLine\":30,\"endColumn\":43},\"message\":\"Error 'x' can't be found in the mapping simple::simpleRelationalMappingInc\"}", new ObjectMapper().writeValueAsString(warnings.get(0)));
}

@Test
Expand Down Expand Up @@ -2372,6 +2372,6 @@ public void testCompilationMissingEnumMapping() throws Exception

MutableList<Warning> warnings = res.getTwo().getWarnings();
Assert.assertEquals(1, warnings.size());
Assert.assertEquals("{\"sourceInformation\":{\"sourceId\":\"test::Map\",\"startLine\":24,\"startColumn\":9,\"endLine\":24,\"endColumn\":33},\"message\":\"Missing an EnumerationMapping for the enum property 'type'. Enum properties require an EnumerationMapping in order to transform the store values into the Enum.\"}", new ObjectMapper().writeValueAsString(warnings.get(0)));
Assert.assertEquals("{\"sourceInformation\":{\"sourceId\":\"\",\"startLine\":24,\"startColumn\":9,\"endLine\":24,\"endColumn\":33},\"message\":\"Missing an EnumerationMapping for the enum property 'type'. Enum properties require an EnumerationMapping in order to transform the store values into the Enum.\"}", new ObjectMapper().writeValueAsString(warnings.get(0)));
}
}
Loading
Loading