-
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/definition
for XML Schema
Fix #148 This PR manage the following definition only in the XML Schema (external definition is not managed): - xs:element/@type -> xs:complexType/@name - xs:extension/@base -> xs:complexType/@name Signed-off-by: azerr <azerr@redhat.com>
- Loading branch information
1 parent
231bf5d
commit 140a8c7
Showing
13 changed files
with
475 additions
and
85 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
57 changes: 57 additions & 0 deletions
57
...c/main/java/org/eclipse/lsp4xml/extensions/xsd/participants/XSDDefinitionParticipant.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,57 @@ | ||
/******************************************************************************* | ||
* 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.LocationLink; | ||
import org.eclipse.lsp4j.Position; | ||
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.AbstractDefinitionParticipant; | ||
import org.eclipse.lsp4xml.utils.DOMUtils; | ||
import org.eclipse.lsp4xml.utils.XMLPositionUtility; | ||
|
||
/** | ||
* XSD definition which manages teh following definition: | ||
* | ||
* <ul> | ||
* <li>xs:element/@type -> xs:complexType/@name</li> * | ||
* <li>xs:extension/@base -> xs:complexType/@name</li> | ||
* </ul> | ||
* | ||
* @author Angelo ZERR | ||
* | ||
*/ | ||
public class XSDDefinitionParticipant extends AbstractDefinitionParticipant { | ||
|
||
@Override | ||
protected boolean match(DOMDocument document) { | ||
return DOMUtils.isXSD(document); | ||
} | ||
|
||
@Override | ||
protected void findDefinition(DOMNode node, Position position, int offset, List<LocationLink> locations, | ||
CancelChecker cancelChecker) { | ||
// - xs:element/@type -> xs:complexType/@name | ||
// - xs:extension/@base -> xs:complexType/@name | ||
DOMAttr attr = node.findAttrAt(offset); | ||
if (XSDUtils.isBoundToComplexTypes(attr)) { | ||
XSDUtils.collectComplexTypes(attr, true, (targetNamespacePrefix, targetAttr) -> { | ||
LocationLink location = XMLPositionUtility.createLocationLink(attr, targetAttr); | ||
locations.add(location); | ||
}); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.