forked from eclipse/lemminx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes eclipse#693 Signed-off-by: azerr <[email protected]>
- Loading branch information
1 parent
25cf8e4
commit 31e5fae
Showing
6 changed files
with
79 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,12 +12,15 @@ | |
* Seiphon Wang <[email protected]> | ||
*/ | ||
package org.eclipse.lemminx.extensions.contentmodel; | ||
|
||
import static org.eclipse.lemminx.XMLAssert.r; | ||
import org.apache.xerces.impl.XMLEntityManager; | ||
import org.apache.xerces.util.URI.MalformedURIException; | ||
import org.eclipse.lemminx.XMLAssert; | ||
import org.eclipse.lemminx.commons.BadLocationException; | ||
import org.eclipse.lemminx.extensions.contentmodel.settings.ContentModelSettings; | ||
import org.eclipse.lemminx.services.XMLLanguageService; | ||
import org.eclipse.lemminx.uriresolver.CacheResourcesManager; | ||
import org.eclipse.lsp4j.Range; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class DTDHoverExtensionsTest { | ||
|
@@ -29,14 +32,14 @@ public void testTagHover() throws BadLocationException, MalformedURIException { | |
"<!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" + | ||
" 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); | ||
r(1, 206, 1, 221)); | ||
} | ||
|
||
@Test | ||
|
@@ -48,15 +51,40 @@ public void testAttributeNameHover() throws BadLocationException, MalformedURIEx | |
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) | ||
@Test | ||
public void webXML() throws Exception { | ||
String dtdURI = CacheResourcesManager.getResourceCachePath("http://java.sun.com/dtd/web-app_2_3.dtd").toUri() | ||
.toString().replace("file:///", "file:/"); | ||
String xml = "<!DOCTYPE web-app PUBLIC\n" + // | ||
" \"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN\"\n" + // | ||
" \"http://java.sun.com/dtd/web-app_2_3.dtd\" >\n" + // | ||
"\n" + // | ||
"<web-a|pp>\n" + // | ||
" <display-name>Servlet 2.3 Web Application</display-name>\n" + // | ||
"</web-app>"; | ||
assertHoverWithCache(xml, | ||
"The web-app element is the root of the deployment descriptor for a web application." + // | ||
System.lineSeparator() + // | ||
System.lineSeparator() + "Source: [web-app_2_3.dtd](" + dtdURI + ")", | ||
r(4, 1, 4, 8)); | ||
} | ||
|
||
private static void assertHover(String value, String expectedHoverLabel, Range expectedHoverRange) | ||
throws BadLocationException { | ||
XMLAssert.assertHover(new XMLLanguageService(), value, "src/test/resources/catalogs/catalog-liferay.xml", null, | ||
expectedHoverLabel, expectedHoverOffset); | ||
expectedHoverLabel, expectedHoverRange); | ||
} | ||
|
||
private static void assertHoverWithCache(String value, String expectedHoverLabel, Range expectedHoverRange) throws BadLocationException { | ||
ContentModelSettings settings = new ContentModelSettings(); | ||
settings.setUseCache(true); | ||
XMLAssert.assertHover(new XMLLanguageService(), value, null, null, expectedHoverLabel, expectedHoverRange, settings); | ||
} | ||
|
||
private static String getDTDFileURI(String dtdURI) throws MalformedURIException { | ||
|
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