-
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 <azerr@redhat.com>
- Loading branch information
1 parent
fe2ec42
commit 3c84a1d
Showing
5 changed files
with
124 additions
and
2 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
43 changes: 43 additions & 0 deletions
43
org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/services/XMLTypeDefinition.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,43 @@ | ||
/******************************************************************************* | ||
* 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.services; | ||
|
||
import java.util.ArrayList; | ||
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.DOMDocument; | ||
import org.eclipse.lsp4xml.services.extensions.ITypeDefinitionParticipant; | ||
import org.eclipse.lsp4xml.services.extensions.XMLExtensionsRegistry; | ||
|
||
/** | ||
* XML type definition support. | ||
* | ||
*/ | ||
class XMLTypeDefinition { | ||
|
||
private final XMLExtensionsRegistry extensionsRegistry; | ||
|
||
public XMLTypeDefinition(XMLExtensionsRegistry extensionsRegistry) { | ||
this.extensionsRegistry = extensionsRegistry; | ||
} | ||
|
||
public List<? extends LocationLink> findTypeDefinition(DOMDocument document, Position position, | ||
CancelChecker cancelChecker) { | ||
List<LocationLink> locations = new ArrayList<>(); | ||
for (ITypeDefinitionParticipant participant : extensionsRegistry.getTypeDefinitionParticipants()) { | ||
participant.findTypeDefinition(document, position, locations, cancelChecker); | ||
} | ||
return locations; | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
...xml/src/main/java/org/eclipse/lsp4xml/services/extensions/ITypeDefinitionParticipant.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,36 @@ | ||
/******************************************************************************* | ||
* 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.services.extensions; | ||
|
||
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.DOMDocument; | ||
|
||
/** | ||
* Type Definition participant API. | ||
* | ||
*/ | ||
public interface ITypeDefinitionParticipant { | ||
|
||
/** | ||
* Find type definition. | ||
* | ||
* @param document | ||
* @param position | ||
* @param locations | ||
* @param cancelChecker | ||
*/ | ||
void findTypeDefinition(DOMDocument document, Position position, List<LocationLink> locations, | ||
CancelChecker cancelChecker); | ||
|
||
} |
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