diff --git a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/extensions/contentmodel/participants/XMLSchemaErrorCode.java b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/extensions/contentmodel/participants/XMLSchemaErrorCode.java index fa8a64a79..7b7a7554e 100644 --- a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/extensions/contentmodel/participants/XMLSchemaErrorCode.java +++ b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/extensions/contentmodel/participants/XMLSchemaErrorCode.java @@ -67,7 +67,8 @@ public enum XMLSchemaErrorCode implements IXMLErrorCode { cvc_minInclusive_valid("cvc-minInclusive-valid"), // https://wiki.xmldation.com/Support/validator/cvc-mininclusive-valid TargetNamespace_2("TargetNamespace.2"), SchemaLocation("SchemaLocation"), - schema_reference_4("schema_reference.4"); // + schema_reference_4("schema_reference.4"), // + src_element_3("src-element.3"); private final String code; @@ -128,6 +129,7 @@ public static Range toLSPRange(XMLLocator location, XMLSchemaErrorCode code, Obj case cvc_complex_type_2_4_f: case cvc_elt_1_a: case cvc_complex_type_4: + case src_element_3: case TargetNamespace_2: return XMLPositionUtility.selectStartTag(offset, document); case cvc_complex_type_3_2_2: { diff --git a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/extensions/xsd/participants/XSDErrorCode.java b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/extensions/xsd/participants/XSDErrorCode.java index 6f8fd3d50..05cb658f0 100644 --- a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/extensions/xsd/participants/XSDErrorCode.java +++ b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/extensions/xsd/participants/XSDErrorCode.java @@ -38,6 +38,7 @@ public enum XSDErrorCode implements IXMLErrorCode { s4s_att_not_allowed("s4s-att-not-allowed"), // s4s_att_invalid_value("s4s-att-invalid-value"), // s4s_elt_character("s4s-elt-character"), // + src_element_3("src-element.3"), src_resolve_4_2("src-resolve.4.2"), // src_resolve("src-resolve"), src_element_2_1("src-element.2.1"); @@ -104,6 +105,7 @@ public static Range toLSPRange(XMLLocator location, XSDErrorCode code, Object[] case s4s_att_must_appear: case s4s_elt_invalid_content_2: case src_element_2_1: + case src_element_3: return XMLPositionUtility.selectStartTag(offset, document); case s4s_att_not_allowed: { String attrName = (String) arguments[1]; diff --git a/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/contentmodel/XMLSchemaDiagnosticsTest.java b/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/contentmodel/XMLSchemaDiagnosticsTest.java index 614c3a7c0..6fba49f2a 100644 --- a/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/contentmodel/XMLSchemaDiagnosticsTest.java +++ b/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/contentmodel/XMLSchemaDiagnosticsTest.java @@ -393,6 +393,15 @@ public void cvc_type_3_1_2() throws Exception { d(4,10,4,17, XMLSchemaErrorCode.cvc_type_3_1_3)); } + @Test + public void testSrcElement3() throws Exception { + String xml = "\r\n" + + " \r\n" + + ""; + testDiagnosticsFor(xml, d(0, 1, 0, 2, XMLSchemaErrorCode.src_element_3)); + } + private static void testDiagnosticsFor(String xml, Diagnostic... expected) { XMLAssert.testDiagnosticsFor(xml, "src/test/resources/catalogs/catalog.xml", expected); } diff --git a/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/xsd/XSDValidationExtensionsTest.java b/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/xsd/XSDValidationExtensionsTest.java index f8db181bb..819f3e047 100644 --- a/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/xsd/XSDValidationExtensionsTest.java +++ b/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/xsd/XSDValidationExtensionsTest.java @@ -202,6 +202,20 @@ public void src_element_2_1() throws BadLocationException { d(5, 17, 5, 27, XSDErrorCode.src_element_2_1)); } + @Test + public void src_element_3() throws BadLocationException { + String xml = "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + ""; + testDiagnosticsFor(xml, d(1, 3, 1, 13, XSDErrorCode.src_element_3)); + } + private static void testDiagnosticsFor(String xml, Diagnostic... expected) throws BadLocationException { XMLAssert.testDiagnosticsFor(xml, null, null, "test.xsd", expected); } diff --git a/org.eclipse.lsp4xml/src/test/resources/xsd/srcElement3.xsd b/org.eclipse.lsp4xml/src/test/resources/xsd/srcElement3.xsd new file mode 100644 index 000000000..abc58aa23 --- /dev/null +++ b/org.eclipse.lsp4xml/src/test/resources/xsd/srcElement3.xsd @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file