-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DTD hover/completion support for documentation #592
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
64 changes: 64 additions & 0 deletions
64
...xml/src/test/java/org/eclipse/lsp4xml/extensions/contentmodel/DTDHoverExtensionsTest.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,64 @@ | ||
/** | ||
* Copyright (c) 2018 Angelo ZERR and Liferay Inc. | ||
* 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: | ||
* Angelo Zerr <[email protected]> - initial API and implementation | ||
* Seiphon Wang <[email protected]> | ||
*/ | ||
package org.eclipse.lsp4xml.extensions.contentmodel; | ||
|
||
import org.apache.xerces.impl.XMLEntityManager; | ||
import org.apache.xerces.util.URI.MalformedURIException; | ||
import org.eclipse.lsp4xml.XMLAssert; | ||
import org.eclipse.lsp4xml.commons.BadLocationException; | ||
import org.eclipse.lsp4xml.services.XMLLanguageService; | ||
import org.junit.Test; | ||
|
||
public class DTDHoverExtensionsTest { | ||
|
||
@Test | ||
public void testTagHover() throws BadLocationException, MalformedURIException { | ||
String dtdURI = getDTDFileURI("liferay-service-builder_7_2_0.dtd"); | ||
String xml = "<?xml version=\"1.0\"?>\r\n" + // | ||
"<!DOCTYPE service-builder PUBLIC \"-//Liferay//DTD Service Builder 7.2.0//EN\" \"http://www.liferay.com/dtd/liferay-service-builder_7_2_0.dtd\">" | ||
+ "<service-builder dependency-injector=\"ds\" package-path=\"testSB\"></servi|ce-builder>"; | ||
assertHover(xml,"The service-builder element is the root of the deployment descriptor for" + // | ||
" a Service Builder descriptor that is used to generate services available to" + | ||
" portlets. The Service Builder saves the developer time by generating Spring" + | ||
" utilities, SOAP utilities, and Hibernate persistence classes to ease the" + | ||
" development of services." | ||
+ // | ||
System.lineSeparator() + // | ||
System.lineSeparator() + "Source: [liferay-service-builder_7_2_0.dtd](" + dtdURI + ")", | ||
206); | ||
} | ||
|
||
@Test | ||
public void testAttributeNameHover() throws BadLocationException, MalformedURIException { | ||
String dtdURI = getDTDFileURI("liferay-service-builder_7_2_0.dtd"); | ||
String xml = "<?xml version=\"1.0\"?>\r\n" + // | ||
"<!DOCTYPE service-builder PUBLIC \"-//Liferay//DTD Service Builder 7.2.0//EN\" \"http://www.liferay.com/dtd/liferay-service-builder_7_2_0.dtd\">" | ||
+ "<service-builder dependency-injector=\"ds\" pa|ckage-path=\"testSB\"></service-builder>"; | ||
assertHover(xml, | ||
"The package-path value specifies the package of the generated code." | ||
+ // | ||
System.lineSeparator() + // | ||
System.lineSeparator() + "Source: [liferay-service-builder_7_2_0.dtd](" + dtdURI + ")", | ||
null); | ||
} | ||
|
||
private static void assertHover(String value, String expectedHoverLabel, Integer expectedHoverOffset) | ||
throws BadLocationException { | ||
XMLAssert.assertHover(new XMLLanguageService(), value, "src/test/resources/catalogs/catalog-liferay.xml", null, | ||
expectedHoverLabel, expectedHoverOffset); | ||
} | ||
|
||
private static String getDTDFileURI(String dtdURI) throws MalformedURIException { | ||
return XMLEntityManager.expandSystemId("dtd/" + dtdURI, "src/test/resources/test.xml", true).replace("///", | ||
"/"); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
org.eclipse.lsp4xml/src/test/resources/catalogs/catalog-liferay.xml
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,6 @@ | ||
<?xml version="1.0"?> | ||
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"> | ||
<system | ||
systemId="http://www.liferay.com/dtd/liferay-service-builder_7_2_0.dtd" | ||
uri="../dtd/liferay-service-builder_7_2_0.dtd" /> | ||
</catalog> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a XML catalog. Please update this file with
To check that the XML catalog is working and uses the local liferay-service-builder_7_2_0.dtd, disconnect your Internet and try to execute your test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, just got it. the pr has been updated.