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

fixed src-import.3.2 XSD error highlighting support #1087

Merged
merged 1 commit into from
Jul 20, 2021
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 @@ -60,7 +60,8 @@ public enum XSDErrorCode implements IXMLErrorCode {
src_resolve_4_2("src-resolve.4.2"), //
src_resolve("src-resolve"), src_element_2_1("src-element.2.1"),
EmptyTargetNamespace("EmptyTargetNamespace"),
src_import_3_1("src-import.3.1");
src_import_3_1("src-import.3.1"),
src_import_3_2("src-import.3.2");

private final String code;

Expand Down Expand Up @@ -177,6 +178,8 @@ public static Range toLSPRange(XMLLocator location, XSDErrorCode code, Object[]
return XMLPositionUtility.selectAttributeValueAt(XSDUtils.NAMESPACE_ATTR, offset, document);
}
}
case src_import_3_2:
return XMLPositionUtility.selectChildNodeAttributeValueFromGivenNameAt(XSDUtils.XS_IMPORT_TAG, XSDUtils.SCHEMA_LOCATION_ATTR, offset, document);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,19 @@ public void src_import_3_1_BadNamespaceWithSchemaContent() throws BadLocationExc
testDiagnosticsFor(xsd, d);
}

@Test
public void src_import_3_2_NoNamespaceFound() throws BadLocationException {
String xsd = "<xs:schema\n" +
"xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\n" +
"targetNamespace=\"http://example.org/my-example\"\n" +
"xmlns:NS=\"http://example.org/my-example\">\n" +
"<xs:import schemaLocation=\"src/test/resources/xsd/baseSchema.xsd\"/>\n" +
"</xs:schema>";

Diagnostic d = d(4, 26, 4, 65, XSDErrorCode.src_import_3_2);
testDiagnosticsFor(xsd, d);
}


private static void testDiagnosticsFor(String xml, Diagnostic... expected) throws BadLocationException {
XMLAssert.testDiagnosticsFor(xml, null, null, "test.xsd", expected);
Expand Down
10 changes: 5 additions & 5 deletions org.eclipse.lemminx/src/test/resources/xsd/baseSchema.xsd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="root-element">

</xs:element>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://foo.bar"
>
<xs:element name="root-element"></xs:element>
</xs:schema>