mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
check valueOf signature before use synthetic javadoc (IDEA-81701)
This commit is contained in:
@@ -759,11 +759,15 @@ public class JavaDocInfoGenerator {
|
||||
private PsiDocComment getMethodDocComment(final PsiMethod method) {
|
||||
final PsiClass parentClass = method.getContainingClass();
|
||||
if (parentClass != null && parentClass.isEnum()) {
|
||||
if (method.getName().equals("values") && method.getParameterList().getParametersCount() == 0) {
|
||||
final PsiParameterList parameterList = method.getParameterList();
|
||||
if (method.getName().equals("values") && parameterList.getParametersCount() == 0) {
|
||||
return loadSyntheticDocComment(method, "/javadoc/EnumValues.java.template");
|
||||
}
|
||||
if (method.getName().equals("valueOf") && method.getParameterList().getParametersCount() == 1) {
|
||||
return loadSyntheticDocComment(method, "/javadoc/EnumValueOf.java.template");
|
||||
if (method.getName().equals("valueOf") && parameterList.getParametersCount() == 1) {
|
||||
final PsiType psiType = parameterList.getParameters()[0].getType();
|
||||
if (psiType.equalsToText(CommonClassNames.JAVA_LANG_STRING)) {
|
||||
return loadSyntheticDocComment(method, "/javadoc/EnumValueOf.java.template");
|
||||
}
|
||||
}
|
||||
}
|
||||
return getDocComment(method);
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<html><head> <style type="text/css"> #error { background-color: #eeeeee; margin-bottom: 10px; } p { margin: 5px 0; } </style></head><body><small><b><a href="psi_element://En"><code>En</code></a></b></small><PRE>static int <b>valueOf</b>(int i)</PRE>
|
||||
myjavadoc
|
||||
<DD><DL><DT><b>Parameters:</b><DD><code>i</code> - </DD></DL></DD><DD><DL><DT><b>Returns:</b><DD></DD></DL></DD></body></html>
|
||||
@@ -0,0 +1,12 @@
|
||||
enum En {
|
||||
;
|
||||
|
||||
/**
|
||||
* myjavadoc
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
static int valueOf(int i) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -50,6 +50,10 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase {
|
||||
public void testClassTypeParameter() throws Exception {
|
||||
verifyJavaDoc(getTestClass());
|
||||
}
|
||||
|
||||
public void testEnumValueOf() throws Exception {
|
||||
doTestMethod();
|
||||
}
|
||||
|
||||
private void doTestField() throws Exception {
|
||||
PsiClass psiClass = getTestClass();
|
||||
|
||||
Reference in New Issue
Block a user