-
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.
Add support for
textDocument/references
for XML Schema types
Fix #58 Signed-off-by: azerr <[email protected]>
- Loading branch information
1 parent
9d8e118
commit 0eaa022
Showing
19 changed files
with
528 additions
and
59 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
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
50 changes: 50 additions & 0 deletions
50
...rc/main/java/org/eclipse/lsp4xml/extensions/xsd/participants/XSDReferenceParticipant.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,50 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2019 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 | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.lsp4xml.extensions.xsd.participants; | ||
|
||
import java.util.List; | ||
|
||
import org.eclipse.lsp4j.Location; | ||
import org.eclipse.lsp4j.Position; | ||
import org.eclipse.lsp4j.ReferenceContext; | ||
import org.eclipse.lsp4j.jsonrpc.CancelChecker; | ||
import org.eclipse.lsp4xml.dom.DOMAttr; | ||
import org.eclipse.lsp4xml.dom.DOMDocument; | ||
import org.eclipse.lsp4xml.dom.DOMNode; | ||
import org.eclipse.lsp4xml.extensions.xsd.utils.XSDUtils; | ||
import org.eclipse.lsp4xml.services.extensions.AbstractReferenceParticipant; | ||
import org.eclipse.lsp4xml.utils.DOMUtils; | ||
import org.eclipse.lsp4xml.utils.XMLPositionUtility; | ||
|
||
/** | ||
* XSD reference | ||
* | ||
* @author Angelo ZERR | ||
* | ||
*/ | ||
public class XSDReferenceParticipant extends AbstractReferenceParticipant { | ||
|
||
@Override | ||
protected boolean match(DOMDocument document) { | ||
return DOMUtils.isXSD(document); | ||
} | ||
|
||
@Override | ||
protected void findReferences(DOMNode node, Position position, int offset, ReferenceContext context, | ||
List<Location> locations, CancelChecker cancelChecker) { | ||
DOMAttr attr = node.findAttrAt(offset); | ||
if (attr != null) { | ||
node = attr; | ||
} | ||
XSDUtils.collectXSReferenceTypes(node, | ||
(from, to) -> locations.add(XMLPositionUtility.createLocation(from.getNodeAttrValue())), cancelChecker); | ||
} | ||
|
||
} |
Oops, something went wrong.