|
Lines 12-19
Link Here
|
| 12 |
|
12 |
|
| 13 |
import java.io.IOException; |
13 |
import java.io.IOException; |
| 14 |
import java.io.Reader; |
14 |
import java.io.Reader; |
|
|
15 |
import java.io.StringReader; |
| 15 |
import java.net.URISyntaxException; |
16 |
import java.net.URISyntaxException; |
| 16 |
import java.util.ArrayList; |
17 |
import java.util.ArrayList; |
|
|
18 |
import java.util.Arrays; |
| 17 |
import java.util.Iterator; |
19 |
import java.util.Iterator; |
| 18 |
import java.util.List; |
20 |
import java.util.List; |
| 19 |
|
21 |
|
|
Lines 61-66
Link Here
|
| 61 |
*/ |
63 |
*/ |
| 62 |
public class JavadocContentAccess2 { |
64 |
public class JavadocContentAccess2 { |
| 63 |
|
65 |
|
|
|
66 |
private static final char[] INHERIT_DOC_TAG= "@inheritDoc}".toCharArray(); //$NON-NLS-1$ |
| 67 |
|
| 64 |
private final IMember fMember; |
68 |
private final IMember fMember; |
| 65 |
private String fSource; |
69 |
private String fSource; |
| 66 |
|
70 |
|
|
Lines 109-118
Link Here
|
| 109 |
ISourceRange javadocRange= member.getJavadocRange(); |
113 |
ISourceRange javadocRange= member.getJavadocRange(); |
| 110 |
if (javadocRange != null) { |
114 |
if (javadocRange != null) { |
| 111 |
String rawJavadoc= buf.getText(javadocRange.getOffset(), javadocRange.getLength()); |
115 |
String rawJavadoc= buf.getText(javadocRange.getOffset(), javadocRange.getLength()); |
| 112 |
String javadoc= javadoc2HTML(member, rawJavadoc); |
116 |
if (!containsOnlyInheritDoc(rawJavadoc)) |
| 113 |
if (!containsOnlyInheritDoc(javadoc)) { |
117 |
return javadoc2HTML(member, rawJavadoc); |
| 114 |
return javadoc; |
|
|
| 115 |
} |
| 116 |
} |
118 |
} |
| 117 |
|
119 |
|
| 118 |
if (allowInherited && (member.getElementType() == IJavaElement.METHOD)) { |
120 |
if (allowInherited && (member.getElementType() == IJavaElement.METHOD)) { |
|
Lines 174-182
Link Here
|
| 174 |
return buf.toString(); |
176 |
return buf.toString(); |
| 175 |
} |
177 |
} |
| 176 |
|
178 |
|
|
|
179 |
/** |
| 180 |
* Checks whether the given string is Javadoc and |
| 181 |
* only contains whitespace and the inheritDoc tag. |
| 182 |
* |
| 183 |
* @param javadoc the string to test |
| 184 |
* @return <code>true</code> if the given string is Javdoc with only an inheritDoc tag |
| 185 |
* @since 3.4 |
| 186 |
*/ |
| 177 |
private static boolean containsOnlyInheritDoc(String javadoc) { |
187 |
private static boolean containsOnlyInheritDoc(String javadoc) { |
| 178 |
//FIXME: improve {@inheritDoc} support |
188 |
//FIXME: improve {@inheritDoc} support |
| 179 |
return javadoc != null && javadoc.trim().equals("{@inheritDoc}"); //$NON-NLS-1$ |
189 |
|
|
|
190 |
org.eclipse.core.runtime.Assert.isLegal(javadoc != null); |
| 191 |
|
| 192 |
StringReader reader= new StringReader(javadoc); |
| 193 |
int state= 0; |
| 194 |
int ch= 0; |
| 195 |
while (ch != -1) { |
| 196 |
try { |
| 197 |
ch= reader.read(); |
| 198 |
if (ch == -1) |
| 199 |
break; |
| 200 |
|
| 201 |
if (Character.isWhitespace((char) ch)) |
| 202 |
continue; |
| 203 |
|
| 204 |
switch (state) { |
| 205 |
case 0: // expecting '/' -> 1 |
| 206 |
if (ch != '/') |
| 207 |
return false; |
| 208 |
state= 1; |
| 209 |
break; |
| 210 |
case 1: // expecting first '*' -> 2 |
| 211 |
if (ch != '*') |
| 212 |
return false; |
| 213 |
state= 2; |
| 214 |
break; |
| 215 |
case 2: // expecting '*' -> 2 or '{' -> 3 |
| 216 |
if (ch == '*') |
| 217 |
continue; |
| 218 |
if (ch != '{') |
| 219 |
return false; |
| 220 |
int size= INHERIT_DOC_TAG.length; |
| 221 |
char[] result= new char[size]; |
| 222 |
int readCount= reader.read(result, 0, size); |
| 223 |
if (readCount != size || !Arrays.equals(INHERIT_DOC_TAG, result)) |
| 224 |
return false; |
| 225 |
state= 3; |
| 226 |
break; |
| 227 |
case 3: // expecting '*' -> 4 |
| 228 |
if (ch != '*') |
| 229 |
return false; |
| 230 |
state= 4; |
| 231 |
break; |
| 232 |
case 4: // expecting '*' -> 4 or '/' -> 5 |
| 233 |
if (ch == '/') |
| 234 |
state= 5; |
| 235 |
else if (ch != '*') |
| 236 |
return false; |
| 237 |
break; |
| 238 |
default: |
| 239 |
return false; |
| 240 |
} |
| 241 |
} catch (IOException e) { |
| 242 |
return false; |
| 243 |
} |
| 244 |
} |
| 245 |
return true; |
| 180 |
} |
246 |
} |
| 181 |
|
247 |
|
| 182 |
private static String findDocInHierarchy(IMethod method, boolean useAttachedJavadoc) throws JavaModelException { |
248 |
private static String findDocInHierarchy(IMethod method, boolean useAttachedJavadoc) throws JavaModelException { |