Skip to content

Commit

Permalink
Improve readability of the first line in error messages.
Browse files Browse the repository at this point in the history
Signed-off-by: Jessica He <[email protected]>
  • Loading branch information
JessicaJHee authored and datho7561 committed Aug 15, 2022
1 parent 39eefb7 commit 67b1340
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@ public static Object[] reformatSchemaArguments(XMLSchemaErrorCode code, Object[]
return cvc_2_4_b_solution(arguments);
case cvc_enumeration_valid:
return enumeration_valid_solution(arguments);
case cvc_complex_type_4:
arguments[1] = "- " + arguments[1];
arguments[0] = "- " + arguments[0];
default:
return arguments;
}
Expand Down Expand Up @@ -237,7 +234,6 @@ private static Object[] cvc_2_4_a_solution(Object[] arguments) {
schema = "{the schema}";
validNames = reformatElementNames(getString(arguments[1]));
}
name = "- " + name;
return new Object[] { name, validNames, schema };
}

Expand Down Expand Up @@ -272,7 +268,7 @@ private static Object[] cvc_2_4_b_solution(Object[] arguments) {
missingChildElements = reformatElementNames(getString(arguments[1]));
schema = "{the schema}";
}
element = "- " + getString(arguments[0]);
element = getString(arguments[0]);
return new Object[] { element, missingChildElements, schema };
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
# changed
cvc-complex-type.2.3 = Element ''{0}'' cannot contain text content.\nThe content type is defined as element-only.\n\nCode:
# changed
cvc-complex-type.2.4.a = Invalid element name:\n {0}\n\nOne of the following is expected:\n{1}\nError indicated by:\n {2}\nwith code:
cvc-complex-type.2.4.a = Element name ''{0}'' is invalid.\n\nOne of the following is expected:\n{1}\nError indicated by:\n {2}\nwith code:
# changed
cvc-complex-type.2.4.b = Child elements are missing from element:\n {0}\n\nThe following elements are expected:\n{1}\nError indicated by\n {2}\nwith code:
cvc-complex-type.2.4.b = Child elements are missing from element ''{0}''.\n\nThe following elements are expected:\n{1}\nError indicated by:\n {2}\nwith code:
# changed
cvc-complex-type.4 = Attribute:\n {1}\nis required in element:\n {0}\n\nCode:
cvc-complex-type.4 = Attribute ''{1}'' is missing from element ''{0}''.\n\nCode:
# changed
cvc-datatype-valid.1.2.1 = Content of type ''{1}'' is expected.\n\nThe following content is not a valid type:\n ''{0}''\n\nCode:
# changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void cvc_complex_type_4() throws Exception {
" </bean>\r\n" + //
"</beans>";
Diagnostic d = d(3, 3, 3, 11, XMLSchemaErrorCode.cvc_complex_type_4,
"Attribute:\n - name\nis required in element:\n - property\n\nCode:");
"Attribute 'name' is missing from element 'property'.\n\nCode:");
testDiagnosticsWithCatalogFor(xml, d);
testCodeActionsFor(xml, d, ca(d, te(3, 11, 3, 11, " name=\"\"")));
}
Expand All @@ -112,9 +112,9 @@ public void cvc_type_4_Multiple_attributes() throws Exception {
" </payments>\r\n" + //
"</invoice>";
Diagnostic d2 = d(6, 4, 6, 11, XMLSchemaErrorCode.cvc_complex_type_4,
"Attribute:\n - description\nis required in element:\n - product\n\nCode:");
"Attribute 'description' is missing from element 'product'.\n\nCode:");
Diagnostic d1 = d(6, 4, 6, 11, XMLSchemaErrorCode.cvc_complex_type_4,
"Attribute:\n - price\nis required in element:\n - product\n\nCode:");
"Attribute 'price' is missing from element 'product'.\n\nCode:");
testDiagnosticsFor(xml, d1, d2);

testCodeActionsFor(xml, d1, ca(d1, te(6, 11, 6, 11, " price=\"\" description=\"\"")));
Expand All @@ -129,7 +129,7 @@ public void cvc_complex_type_2_4_a() throws Exception {
" <XXX></XXX>\r\n" + // <- error
"</project>";

String message = "Invalid element name:\n - XXX\n\nOne of the following is expected:\n - modelVersion\n - parent\n - groupId\n - artifactId\n - version\n - packaging\n - name\n - description\n - url\n - inceptionYear\n - organization\n - licenses\n - developers\n - contributors\n - mailingLists\n - prerequisites\n - modules\n - scm\n - issueManagement\n - ciManagement\n - distributionManagement\n - properties\n - dependencyManagement\n - dependencies\n - repositories\n - pluginRepositories\n - build\n - reports\n - reporting\n - profiles\n\nError indicated by:\n {http://maven.apache.org/POM/4.0.0}\nwith code:";
String message = "Element name 'XXX' is invalid.\n\nOne of the following is expected:\n - modelVersion\n - parent\n - groupId\n - artifactId\n - version\n - packaging\n - name\n - description\n - url\n - inceptionYear\n - organization\n - licenses\n - developers\n - contributors\n - mailingLists\n - prerequisites\n - modules\n - scm\n - issueManagement\n - ciManagement\n - distributionManagement\n - properties\n - dependencyManagement\n - dependencies\n - repositories\n - pluginRepositories\n - build\n - reports\n - reporting\n - profiles\n\nError indicated by:\n {http://maven.apache.org/POM/4.0.0}\nwith code:";
testDiagnosticsWithCatalogFor(xml, d(3, 2, 3, 5, XMLSchemaErrorCode.cvc_complex_type_2_4_a, message));
}

Expand Down Expand Up @@ -581,7 +581,7 @@ public void issue217() {
" \r\n" + //
"</edmx:Edmx>";
Diagnostic d = d(1, 1, 1, 10, XMLSchemaErrorCode.cvc_complex_type_2_4_b,
"Child elements are missing from element:\n - edmx:Edmx\n\nThe following elements are expected:\n - Reference\n - DataServices\n\nError indicated by\n {http://docs.oasis-open.org/odata/ns/edmx\":Reference, \"http://docs.oasis-open.org/odata/ns/edmx}\nwith code:");
"Child elements are missing from element 'edmx:Edmx'.\n\nThe following elements are expected:\n - Reference\n - DataServices\n\nError indicated by:\n {http://docs.oasis-open.org/odata/ns/edmx\":Reference, \"http://docs.oasis-open.org/odata/ns/edmx}\nwith code:");
testDiagnosticsWithCatalogFor(xml, d);
}

Expand Down Expand Up @@ -682,7 +682,7 @@ public void fuzzyElementNameCodeActionTest() throws Exception {
" </modules>\r\n" + //
"</project>";
Diagnostic diagnostic = d(4, 7, 4, 13, XMLSchemaErrorCode.cvc_complex_type_2_4_a,
"Invalid element name:\n - bodule\n\nOne of the following is expected:\n - module\n\nError indicated by:\n {http://maven.apache.org/POM/4.0.0}\nwith code:");
"Element name 'bodule' is invalid.\n\nOne of the following is expected:\n - module\n\nError indicated by:\n {http://maven.apache.org/POM/4.0.0}\nwith code:");
testDiagnosticsWithCatalogFor(xml, diagnostic);

testCodeActionsWithCatalogFor(xml, diagnostic,
Expand All @@ -706,8 +706,7 @@ public void fuzzyElementNamesWithOtherOptionsCodeActionTest() throws Exception {
" </ciManagement>\r\n" + //
"</project>";
Diagnostic diagnostic = d(4, 7, 4, 16, XMLSchemaErrorCode.cvc_complex_type_2_4_a, //
"Invalid element name:\n" + //
" - XXXXXXXXX\n\n" + //
"Element name 'XXXXXXXXX' is invalid.\n\n" + //
"One of the following is expected:\n" + //
" - system\n" + //
" - url\n" + //
Expand All @@ -733,8 +732,7 @@ public void elementFormDefaultUnqualified() throws Exception {
" <bar />\r\n" + //
"</foo>";
Diagnostic diagnostic = d(1, 2, 1, 5, XMLSchemaErrorCode.cvc_complex_type_2_4_a, //
"Invalid element name:\n" + //
" - bar\n\n" + //
"Element name 'bar' is invalid.\n\n" + //
"One of the following is expected:\n" + //
" - bar\n\n" + //
"Error indicated by:\n" + //
Expand Down Expand Up @@ -1128,7 +1126,7 @@ public void diagnosticRelatedInformationWithXMLModelSchemaProblem() throws Excep
diagnostic.getRelatedInformation().add(new DiagnosticRelatedInformation(l(xsdFileURI, r(1, 71, 1, 73)), ""));

Diagnostic diagnosticBasedOnXSD = new Diagnostic(r(2, 2, 2, 6),
"Invalid element name:\n - barX\n\nOne of the following is expected:\n - bar\n\nError indicated by:\n {the schema}\nwith code:",
"Element name 'barX' is invalid.\n\nOne of the following is expected:\n - bar\n\nError indicated by:\n {the schema}\nwith code:",
DiagnosticSeverity.Error, "xml", XMLSchemaErrorCode.cvc_complex_type_2_4_a.getCode());

XMLLanguageService xmlLanguageService = new XMLLanguageService();
Expand Down Expand Up @@ -1160,7 +1158,7 @@ public void diagnosticRelatedInformationWithNoNamespaceSchemaLocationSchemaProbl
diagnostic.getRelatedInformation().add(new DiagnosticRelatedInformation(l(xsdFileURI, r(1, 71, 1, 73)), ""));

Diagnostic diagnosticBasedOnXSD = new Diagnostic(r(2, 2, 2, 6),
"Invalid element name:\n - barX\n\nOne of the following is expected:\n - bar\n\nError indicated by:\n {the schema}\nwith code:",
"Element name 'barX' is invalid.\n\nOne of the following is expected:\n - bar\n\nError indicated by:\n {the schema}\nwith code:",
DiagnosticSeverity.Error, "xml", XMLSchemaErrorCode.cvc_complex_type_2_4_a.getCode());

XMLLanguageService xmlLanguageService = new XMLLanguageService();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void validationFileCommand() throws Exception {
"cvc-elt.1.a: Cannot find the declaration of element 'root'.", "xml",
DiagnosticSeverity.Error)), //
pd(xmlIdentifier.getUri(), d(4, 3, 4, 7, XMLSchemaErrorCode.cvc_complex_type_2_4_a,
"Invalid element name:\n - tags\n\nOne of the following is expected:\n - tag\n\nError indicated by:\n {the schema}\nwith code:",
"Element name 'tags' is invalid.\n\nOne of the following is expected:\n - tag\n\nError indicated by:\n {the schema}\nwith code:",
"xml", DiagnosticSeverity.Error)

));
Expand Down Expand Up @@ -262,7 +262,7 @@ public void validationAllFilesCommand() throws Exception {
"cvc-elt.1.a: Cannot find the declaration of element 'root'.", "xml",
DiagnosticSeverity.Error)), //
pd(xml1Identifier.getUri(), d(4, 3, 4, 7, XMLSchemaErrorCode.cvc_complex_type_2_4_a,
"Invalid element name:\n - tags\n\nOne of the following is expected:\n - tag\n\nError indicated by:\n {the schema}\nwith code:",
"Element name 'tags' is invalid.\n\nOne of the following is expected:\n - tag\n\nError indicated by:\n {the schema}\nwith code:",
"xml", DiagnosticSeverity.Error)), //
pd(xml2Identifier.getUri(),
d(1, 23, 1, 53, ExternalResourceErrorCode.DownloadingResource,
Expand Down

0 comments on commit 67b1340

Please sign in to comment.