-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hyperlink to open declared DTD files
Fixes #641 Signed-off-by: azerr <azerr@redhat.com>
- Loading branch information
1 parent
24cd010
commit 5883cae
Showing
7 changed files
with
130 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...emminx/src/test/java/org/eclipse/lemminx/extensions/contentmodel/DTDDocumentLinkTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020 Red Hat Inc. and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.lemminx.extensions.contentmodel; | ||
|
||
import static org.eclipse.lemminx.XMLAssert.dl; | ||
import static org.eclipse.lemminx.XMLAssert.r; | ||
|
||
import org.eclipse.lemminx.XMLAssert; | ||
import org.eclipse.lemminx.commons.BadLocationException; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* DTD document links tests | ||
* | ||
*/ | ||
public class DTDDocumentLinkTest { | ||
|
||
@Test | ||
public void docTypeSYSTEM() throws BadLocationException { | ||
String xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n" + // | ||
"<!DOCTYPE root-element SYSTEM \"../dtd/base.dtd\" [\r\n" + // | ||
"\r\n" + // | ||
"]>\r\n" + // | ||
"<root-element />"; | ||
XMLAssert.testDocumentLinkFor(xml, "src/test/resources/xml/base.xml", | ||
dl(r(1, 31, 1, 46), "src/test/resources/dtd/base.dtd")); | ||
} | ||
|
||
@Test | ||
public void docTypePUBLIC() throws BadLocationException { | ||
String xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n" + // | ||
"<!DOCTYPE root-element PUBLIC \"ABCD\" \"../dtd/base.dtd\" [\r\n" + // | ||
"\r\n" + // | ||
"]>\r\n" + // | ||
"<root-element />"; | ||
XMLAssert.testDocumentLinkFor(xml, "src/test/resources/xml/base.xml", | ||
dl(r(1, 38, 1, 53), "src/test/resources/dtd/base.dtd")); | ||
} | ||
|
||
@Test | ||
public void noLinks() throws BadLocationException { | ||
String xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n" + // | ||
"<!DOCTYPE root-element \"ABCD\" \"../dtd/base.dtd\" [\r\n" + // here it misses PUBLIC | ||
"\r\n" + // | ||
"]>\r\n" + // | ||
"<root-element />"; | ||
XMLAssert.testDocumentLinkFor(xml, "src/test/resources/xml/base.xml"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!ELEMENT root-element (#PCDATA)> | ||
<!ENTITY foo "bar"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!DOCTYPE root-element PUBLIC "ABCD" "../dtd/base.dtd" [ | ||
|
||
]> | ||
<root-element /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!DOCTYPE root-element SYSTEM "../dtd/base.dtd" [ | ||
|
||
]> | ||
<root-element /> |