|
Lines 16-21
Link Here
|
| 16 |
import java.util.ArrayList; |
16 |
import java.util.ArrayList; |
| 17 |
import java.util.Iterator; |
17 |
import java.util.Iterator; |
| 18 |
import java.util.List; |
18 |
import java.util.List; |
|
|
19 |
import java.util.regex.Pattern; |
| 19 |
|
20 |
|
| 20 |
import org.eclipse.jdt.core.IBuffer; |
21 |
import org.eclipse.jdt.core.IBuffer; |
| 21 |
import org.eclipse.jdt.core.IJavaElement; |
22 |
import org.eclipse.jdt.core.IJavaElement; |
|
Lines 61-66
Link Here
|
| 61 |
*/ |
62 |
*/ |
| 62 |
public class JavadocContentAccess2 { |
63 |
public class JavadocContentAccess2 { |
| 63 |
|
64 |
|
|
|
65 |
/** |
| 66 |
* Pattern that matches Javadocs containing only an inheritDoc tag. |
| 67 |
* The (?s).? at the end is for https://bugs.eclipse.org/bugs/show_bug.cgi?id=232944 . |
| 68 |
*/ |
| 69 |
private static final Pattern ONLY_INHERITDOC_PATTERN= Pattern.compile("/\\*\\*[\\s*]*\\{@inheritDoc\\}[\\s*]*\\*/(?s).?"); //$NON-NLS-1$ |
| 70 |
|
| 64 |
private final IMember fMember; |
71 |
private final IMember fMember; |
| 65 |
private String fSource; |
72 |
private String fSource; |
| 66 |
|
73 |
|
|
Lines 109-118
Link Here
|
| 109 |
ISourceRange javadocRange= member.getJavadocRange(); |
116 |
ISourceRange javadocRange= member.getJavadocRange(); |
| 110 |
if (javadocRange != null) { |
117 |
if (javadocRange != null) { |
| 111 |
String rawJavadoc= buf.getText(javadocRange.getOffset(), javadocRange.getLength()); |
118 |
String rawJavadoc= buf.getText(javadocRange.getOffset(), javadocRange.getLength()); |
| 112 |
String javadoc= javadoc2HTML(member, rawJavadoc); |
119 |
if (!containsOnlyInheritDoc(rawJavadoc)) |
| 113 |
if (!containsOnlyInheritDoc(javadoc)) { |
120 |
return javadoc2HTML(member, rawJavadoc); |
| 114 |
return javadoc; |
|
|
| 115 |
} |
| 116 |
} |
121 |
} |
| 117 |
|
122 |
|
| 118 |
if (allowInherited && (member.getElementType() == IJavaElement.METHOD)) { |
123 |
if (allowInherited && (member.getElementType() == IJavaElement.METHOD)) { |
|
Lines 174-182
Link Here
|
| 174 |
return buf.toString(); |
179 |
return buf.toString(); |
| 175 |
} |
180 |
} |
| 176 |
|
181 |
|
|
|
182 |
/** |
| 183 |
* Checks whether the given string is Javadoc and |
| 184 |
* only contains whitespace and the inheritDoc tag. |
| 185 |
* |
| 186 |
* @param javadoc the string to test |
| 187 |
* @return <code>true</code> if the given string is Javadoc with only an inheritDoc tag |
| 188 |
* @since 3.4 |
| 189 |
*/ |
| 177 |
private static boolean containsOnlyInheritDoc(String javadoc) { |
190 |
private static boolean containsOnlyInheritDoc(String javadoc) { |
| 178 |
//FIXME: improve {@inheritDoc} support |
191 |
//FIXME: improve {@inheritDoc} support: https://bugs.eclipse.org/bugs/show_bug.cgi?id=24227 |
| 179 |
return javadoc != null && javadoc.trim().equals("{@inheritDoc}"); //$NON-NLS-1$ |
192 |
return ONLY_INHERITDOC_PATTERN.matcher(javadoc).matches(); |
| 180 |
} |
193 |
} |
| 181 |
|
194 |
|
| 182 |
private static String findDocInHierarchy(IMethod method, boolean useAttachedJavadoc) throws JavaModelException { |
195 |
private static String findDocInHierarchy(IMethod method, boolean useAttachedJavadoc) throws JavaModelException { |