-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Documentation when hovering object members in Qute
eg. The documentation for `java.lang.String.length()` will be shown when hovering here: ``` {myString.len|gth()} ``` Closes #452 Signed-off-by: David Thompson <[email protected]>
- Loading branch information
1 parent
2da7df2
commit ed5e29a
Showing
38 changed files
with
996 additions
and
49 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
129 changes: 129 additions & 0 deletions
129
...dhat.qute.jdt.test/src/main/java/com/redhat/qute/jdt/template/TemplateGetJavadocTest.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,129 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 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 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package com.redhat.qute.jdt.template; | ||
|
||
import static com.redhat.qute.jdt.QuteProjectTest.getJDTUtils; | ||
import static com.redhat.qute.jdt.QuteProjectTest.loadMavenProject; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.eclipse.core.runtime.NullProgressMonitor; | ||
import org.junit.Test; | ||
|
||
import com.redhat.qute.commons.DocumentFormat; | ||
import com.redhat.qute.commons.QuteJavadocParams; | ||
import com.redhat.qute.jdt.QuteProjectTest.QuteMavenProjectName; | ||
import com.redhat.qute.jdt.QuteSupportForTemplate; | ||
|
||
/** | ||
* Tests for getting the formatted Javadocs for Java members | ||
* | ||
* @author datho7561 | ||
*/ | ||
public class TemplateGetJavadocTest { | ||
|
||
@Test | ||
public void getFieldJavadoc() throws Exception { | ||
loadMavenProject(QuteMavenProjectName.qute_quickstart); | ||
|
||
QuteJavadocParams params = new QuteJavadocParams(// | ||
"org.acme.qute.Item", // | ||
QuteMavenProjectName.qute_quickstart, // | ||
"name", // | ||
"name : java.lang.String", // | ||
DocumentFormat.Markdown); | ||
|
||
String actual = QuteSupportForTemplate.getInstance().getJavadoc(params, getJDTUtils(), new NullProgressMonitor()); | ||
String expected = "The name of the item"; | ||
assertEquals(expected, actual); | ||
} | ||
|
||
@Test | ||
public void getMethodJavadoc() throws Exception { | ||
loadMavenProject(QuteMavenProjectName.qute_quickstart); | ||
|
||
QuteJavadocParams params = new QuteJavadocParams(// | ||
"org.acme.qute.Item", // | ||
QuteMavenProjectName.qute_quickstart, // | ||
"getDerivedItems", // | ||
"getDerivedItems() : org.acme.qute.Item[]", // | ||
DocumentFormat.Markdown); | ||
|
||
String actual = QuteSupportForTemplate.getInstance().getJavadoc(params, getJDTUtils(), new NullProgressMonitor()); | ||
String expected = "Returns the derived items.\n\n * **Returns:**\n \n * the derived items"; | ||
assertEquals(expected, actual); | ||
} | ||
|
||
@Test | ||
public void getFieldJavadocPlainText() throws Exception { | ||
loadMavenProject(QuteMavenProjectName.qute_quickstart); | ||
|
||
QuteJavadocParams params = new QuteJavadocParams(// | ||
"org.acme.qute.Item", // | ||
QuteMavenProjectName.qute_quickstart, // | ||
"name", // | ||
"name : java.lang.String", // | ||
DocumentFormat.PlainText); | ||
|
||
String actual = QuteSupportForTemplate.getInstance().getJavadoc(params, getJDTUtils(), new NullProgressMonitor()); | ||
String expected = " The name of the item "; | ||
assertEquals(expected, actual); | ||
} | ||
|
||
@Test | ||
public void getMethodJavadocPlainText() throws Exception { | ||
loadMavenProject(QuteMavenProjectName.qute_quickstart); | ||
|
||
QuteJavadocParams params = new QuteJavadocParams(// | ||
"org.acme.qute.Item", // | ||
QuteMavenProjectName.qute_quickstart, // | ||
"getDerivedItems", // | ||
"getDerivedItems() : org.acme.qute.Item[]", // | ||
DocumentFormat.PlainText); | ||
|
||
String actual = QuteSupportForTemplate.getInstance().getJavadoc(params, getJDTUtils(), new NullProgressMonitor()); | ||
String expected = " Returns the derived items. \n * Returns:\n - the derived items"; | ||
assertEquals(expected, actual); | ||
} | ||
|
||
@Test | ||
public void getMethodJavadocCyclic() throws Exception { | ||
loadMavenProject(QuteMavenProjectName.qute_quickstart); | ||
|
||
QuteJavadocParams params = new QuteJavadocParams(// | ||
"org.acme.qute.cyclic.ClassC", // | ||
QuteMavenProjectName.qute_quickstart, // | ||
"convert", // | ||
"convert() : java.lang.String", // | ||
DocumentFormat.PlainText); | ||
|
||
String actual = QuteSupportForTemplate.getInstance().getJavadoc(params, getJDTUtils(), new NullProgressMonitor()); | ||
String expected = " cyclic documentation "; | ||
assertEquals(expected, actual); | ||
} | ||
|
||
@Test | ||
public void getMethodJavadocMethodTypeParams() throws Exception { | ||
loadMavenProject(QuteMavenProjectName.qute_quickstart); | ||
|
||
QuteJavadocParams params = new QuteJavadocParams(// | ||
"org.acme.qute.generic.B", // | ||
QuteMavenProjectName.qute_quickstart, // | ||
"get", // | ||
"get(param : B2) : B1", // | ||
DocumentFormat.PlainText); | ||
|
||
String actual = QuteSupportForTemplate.getInstance().getJavadoc(params, getJDTUtils(), new NullProgressMonitor()); | ||
String expected = " some docs "; | ||
assertEquals(expected, actual); | ||
} | ||
|
||
} |
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
42 changes: 42 additions & 0 deletions
42
qute.jdt/com.redhat.qute.jdt/src/main/java/com/redhat/qute/commons/DocumentFormat.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,42 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Red Hat Inc. and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
* which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package com.redhat.qute.commons; | ||
|
||
/** | ||
* Document format. | ||
* | ||
* @author Angelo ZERR | ||
*/ | ||
public enum DocumentFormat { | ||
|
||
PlainText(1), Markdown(2); | ||
|
||
private final int value; | ||
|
||
DocumentFormat(int value) { | ||
this.value = value; | ||
} | ||
|
||
public int getValue() { | ||
return value; | ||
} | ||
|
||
public static DocumentFormat forValue(int value) { | ||
DocumentFormat[] allValues = DocumentFormat.values(); | ||
if (value < 1 || value > allValues.length) | ||
throw new IllegalArgumentException("Illegal enum value: " + value); | ||
return allValues[value - 1]; | ||
} | ||
|
||
} |
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.