Skip to content

Commit

Permalink
XML references linked editing range should not work with DOM document
Browse files Browse the repository at this point in the history
Signed-off-by: azerr <azerr@redhat.com>
  • Loading branch information
azerr authored and datho7561 committed Jan 13, 2023
1 parent 1656689 commit a9473d4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Expand Up @@ -15,6 +15,7 @@

import org.eclipse.lemminx.extensions.references.XMLReferencesPlugin;
import org.eclipse.lemminx.extensions.references.search.SearchEngine;
import org.eclipse.lemminx.extensions.references.search.SearchNode;
import org.eclipse.lemminx.extensions.references.search.SearchQuery;
import org.eclipse.lemminx.extensions.references.search.SearchQueryFactory;
import org.eclipse.lemminx.services.extensions.ILinkedEditingRangesParticipant;
Expand All @@ -39,6 +40,11 @@ public XMLReferencesLinkedEditingRangesParticipant(XMLReferencesPlugin plugin) {
@Override
public void findLinkedEditingRanges(ILinkedEditingRangesRequest request, List<Range> ranges,
CancelChecker cancelChecker) {
if (request.getNode() == null || request.getNode().isOwnerDocument()) {
// Linked editing range should work only for attribute or text node
return;
}

SearchQuery query = SearchQueryFactory.createToQuery(request.getNode(), request.getOffset(),
plugin.getReferencesSettings());
if (query == null) {
Expand Down
Expand Up @@ -97,7 +97,6 @@ public void teiOnXMLId() throws BadLocationException {

@Test
public void docbookOnLinked() throws BadLocationException {
// highlighting on define/@name
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
// + "<!DOCTYPE book PUBLIC \"-//OASIS//DTD DocBook XML V4.4//EN\"
// \"http://www.docbook.org/xml/4.4/docbookx.dtd\">\r\n"
Expand All @@ -117,7 +116,6 @@ public void docbookOnLinked() throws BadLocationException {

@Test
public void docbookOnChapterId() throws BadLocationException {
// highlighting on define/@name
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
// + "<!DOCTYPE book PUBLIC \"-//OASIS//DTD DocBook XML V4.4//EN\"
// \"http://www.docbook.org/xml/4.4/docbookx.dtd\">\r\n"
Expand All @@ -137,6 +135,12 @@ public void docbookOnChapterId() throws BadLocationException {
le(r(4, 23, 4, 32), r(2, 17, 2, 26)));
}

@Test
public void noLinkedEditingRangeForDocument() throws BadLocationException {
String xml = "|<book />";
testLinkedEditingFor(xml, "file:///test/docbook.xml", null);
}

@Test
public void webOnServletMapping() throws BadLocationException {
String xml = "<web-app xmlns=\"http://xmlns.jcp.org/xml/ns/javaee\"\r\n"
Expand Down

0 comments on commit a9473d4

Please sign in to comment.