-
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.
DTD hover/completion support for documentation
Fixes #585 Signed-off-by: Seiphon Wang <[email protected]>
- Loading branch information
1 parent
082780c
commit b0dbc6b
Showing
7 changed files
with
1,055 additions
and
8 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
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.