-
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/typeDefinition
from XML to XMLSchema/DTD
Fix #371 Signed-off-by: azerr <[email protected]>
- Loading branch information
1 parent
77f65e1
commit 4f816fe
Showing
26 changed files
with
905 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,4 +107,6 @@ default String getName(String prefix) { | |
|
||
Collection<String> getEnumerationValues(); | ||
|
||
String getDocumentURI(); | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
...e/lsp4xml/extensions/contentmodel/participants/ContentModelTypeDefinitionParticipant.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) 2019 Red Hat, Inc. and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* 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.contentmodel.participants; | ||
|
||
import java.util.List; | ||
|
||
import org.eclipse.lsp4j.LocationLink; | ||
import org.eclipse.lsp4j.jsonrpc.CancelChecker; | ||
import org.eclipse.lsp4xml.dom.DOMAttr; | ||
import org.eclipse.lsp4xml.dom.DOMElement; | ||
import org.eclipse.lsp4xml.dom.DOMNode; | ||
import org.eclipse.lsp4xml.extensions.contentmodel.model.CMDocument; | ||
import org.eclipse.lsp4xml.extensions.contentmodel.model.ContentModelManager; | ||
import org.eclipse.lsp4xml.services.extensions.ITypeDefinitionParticipant; | ||
import org.eclipse.lsp4xml.services.extensions.ITypeDefinitionRequest; | ||
|
||
/** | ||
* Extension to support XML type definition based on content model (XML Schema | ||
* type definition, etc) | ||
*/ | ||
public class ContentModelTypeDefinitionParticipant implements ITypeDefinitionParticipant { | ||
|
||
@Override | ||
public void findTypeDefinition(ITypeDefinitionRequest request, List<LocationLink> locations, | ||
CancelChecker cancelChecker) { | ||
ContentModelManager contentModelManager = request.getComponent(ContentModelManager.class); | ||
DOMNode node = request.getNode(); | ||
if (node == null) { | ||
return; | ||
} | ||
DOMElement element = null; | ||
if (node.isElement()) { | ||
element = (DOMElement) node; | ||
} else if (node.isAttribute()) { | ||
element = ((DOMAttr) node).getOwnerElement(); | ||
} | ||
if (element != null) { | ||
CMDocument cmDocument = contentModelManager.findCMDocument(element.getOwnerDocument(), | ||
element.getNamespaceURI()); | ||
if (cmDocument != null) { | ||
LocationLink location = cmDocument.findTypeLocation(node); | ||
if (location != null) { | ||
locations.add(location); | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
||
} |
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
Oops, something went wrong.