javadoc: process {@inheritDoc} for throws tags correctly (IDEA-62524)

This commit is contained in:
anna
2011-12-13 10:51:29 +01:00
parent fec375a9c2
commit b4523b4b7a
6 changed files with 62 additions and 3 deletions
@@ -1297,8 +1297,8 @@ public class JavaDocInfoGenerator {
}
@SuppressWarnings({"HardCodedStringLiteral"})
private void generateThrowsSection(StringBuilder buffer, PsiMethod method, final PsiDocComment comment) {
PsiDocTag[] localTags = getThrowsTags(comment);
private void generateThrowsSection(StringBuilder buffer, final PsiMethod method, final PsiDocComment comment) {
final PsiDocTag[] localTags = getThrowsTags(comment);
LinkedList<Pair<PsiDocTag, InheritDocProvider<PsiDocTag>>> collectedTags =
new LinkedList<Pair<PsiDocTag, InheritDocProvider<PsiDocTag>>>();
@@ -1317,7 +1317,18 @@ public class JavaDocInfoGenerator {
}
}
collectedTags.addFirst(new Pair<PsiDocTag, InheritDocProvider<PsiDocTag>>(localTags[i], ourEmptyProvider));
final Pair<PsiDocTag, InheritDocProvider<PsiDocTag>> tag = findInheritDocTag(method, exceptionLocator(valueElement.getText()));
collectedTags.addFirst(new Pair<PsiDocTag, InheritDocProvider<PsiDocTag>>(localTags[i], new InheritDocProvider<PsiDocTag>() {
@Override
public Pair<PsiDocTag, InheritDocProvider<PsiDocTag>> getInheritDoc() {
return tag;
}
@Override
public PsiClass getElement() {
return method.getContainingClass();
}
}));
}
}
@@ -0,0 +1,2 @@
<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://InheritedDocInThrows"><code>InheritedDocInThrows</code></a></b></small><PRE>void&nbsp;<b>foo</b>()
throws&nbsp;<a href="psi_element://java.io.IOException"><code>IOException</code></a></PRE><DD><DL><DT><b>Overrides:</b><DD><a href="psi_element://A#foo()"><code>foo</code></a> in class <a href="psi_element://A"><code>A</code></a></DD></DL></DD><DD><DL><DT><b>Throws:</b><DD><a href="psi_element://java.io.IOException"><code>IOException</code></a> - la-la-la</DD></DL></DD></body></html>
@@ -0,0 +1,18 @@
import java.io.IOException;
class InheritedDocInThrows extends A{
/**
* @throws IOException {@inheritDoc}
*/
void foo() throws IOException {
super.foo();
}
}
class A {
/**
* @throws IOException la-la-la
*/
void foo() throws IOException {
}
}
@@ -0,0 +1,2 @@
<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://InheritedDocInThrows1"><code>InheritedDocInThrows1</code></a></b></small><PRE>void&nbsp;<b>foo</b>()
throws&nbsp;<a href="psi_element://java.io.IOException"><code>IOException</code></a></PRE><DD><DL><DT><b>Overrides:</b><DD><a href="psi_element://A#foo()"><code>foo</code></a> in class <a href="psi_element://A"><code>A</code></a></DD></DL></DD><DD><DL><DT><b>Throws:</b><DD><a href="psi_element://java.io.IOException"><code>IOException</code></a> - comment</DD></DL></DD></body></html>
@@ -0,0 +1,18 @@
import java.io.IOException;
class InheritedDocInThrows1 extends A{
/**
* @throws java.io.IOException comment
*/
void foo() throws IOException {
super.foo();
}
}
class A {
/**
* @throws java.io.IOException la-la-la
*/
void foo() throws IOException {
}
}
@@ -33,6 +33,14 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase {
public void testMethodTypeParameter() throws Exception {
doTestMethod();
}
public void testInheritedDocInThrows() throws Exception {
doTestMethod();
}
public void testInheritedDocInThrows1() throws Exception {
doTestMethod();
}
public void testClassTypeParameter() throws Exception {
verifyJavaDoc(getTestClass());