Lines 173-222
Link Here
|
173 |
if ((modifiers & ClassFileConstants.AccSynthetic) != 0) { |
173 |
if ((modifiers & ClassFileConstants.AccSynthetic) != 0) { |
174 |
return this.parameterNames = getRawParameterNames(paramCount); |
174 |
return this.parameterNames = getRawParameterNames(paramCount); |
175 |
} |
175 |
} |
176 |
String javadocContents = null; |
176 |
String javadocContents = null; |
177 |
IType declaringType = this.getDeclaringType(); |
177 |
IType declaringType = this.getDeclaringType(); |
178 |
PerProjectInfo projectInfo = JavaModelManager.getJavaModelManager().getPerProjectInfoCheckExistence(this.getJavaProject().getProject()); |
178 |
PerProjectInfo projectInfo = JavaModelManager.getJavaModelManager().getPerProjectInfoCheckExistence(this.getJavaProject().getProject()); |
179 |
synchronized (projectInfo.javadocCache) { |
179 |
synchronized (projectInfo.javadocCache) { |
180 |
javadocContents = (String) projectInfo.javadocCache.get(declaringType); |
180 |
javadocContents = (String) projectInfo.javadocCache.get(declaringType); |
181 |
if (javadocContents == null) { |
181 |
if (javadocContents == null) { |
182 |
projectInfo.javadocCache.put(declaringType, BinaryType.EMPTY_JAVADOC); |
182 |
projectInfo.javadocCache.put(declaringType, BinaryType.EMPTY_JAVADOC); |
183 |
} |
183 |
} |
184 |
} |
184 |
} |
185 |
if (javadocContents == null) { |
185 |
if (javadocContents == null) { |
186 |
long timeOut = 50; // default value |
186 |
long timeOut = 50; // default value |
187 |
try { |
187 |
try { |
188 |
String option = this.getJavaProject().getOption(JavaCore.TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC, true); |
188 |
String option = this.getJavaProject().getOption(JavaCore.TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC, true); |
189 |
if (option != null) { |
189 |
if (option != null) { |
190 |
timeOut = Long.parseLong(option); |
190 |
timeOut = Long.parseLong(option); |
191 |
} |
191 |
} |
192 |
} catch(NumberFormatException e) { |
192 |
} catch(NumberFormatException e) { |
193 |
// ignore |
193 |
// ignore |
194 |
} |
194 |
} |
195 |
if (timeOut == 0) { |
195 |
if (timeOut == 0) { |
196 |
// don't try to fetch the values |
196 |
// don't try to fetch the values |
197 |
return this.parameterNames = getRawParameterNames(paramCount); |
197 |
return this.parameterNames = getRawParameterNames(paramCount); |
198 |
} |
198 |
} |
199 |
final class ParametersNameCollector { |
199 |
final class ParametersNameCollector { |
200 |
String javadoc; |
200 |
String javadoc; |
201 |
public void setJavadoc(String s) { |
201 |
public void setJavadoc(String s) { |
202 |
this.javadoc = s; |
202 |
this.javadoc = s; |
203 |
} |
203 |
} |
204 |
public String getJavadoc() { |
204 |
public String getJavadoc() { |
205 |
return this.javadoc; |
205 |
return this.javadoc; |
206 |
} |
206 |
} |
207 |
} |
207 |
} |
208 |
/* |
208 |
/* |
209 |
* The declaring type is not in the cache yet. The thread wil retrieve the javadoc contents |
209 |
* The declaring type is not in the cache yet. The thread wil retrieve the javadoc contents |
210 |
*/ |
210 |
*/ |
211 |
final ParametersNameCollector nameCollector = new ParametersNameCollector(); |
211 |
final ParametersNameCollector nameCollector = new ParametersNameCollector(); |
212 |
Thread collect = new Thread() { |
212 |
Thread collect = new Thread() { |
213 |
public void run() { |
213 |
public void run() { |
214 |
try { |
214 |
try { |
215 |
// this call has a side-effect on the per project info cache |
215 |
// this call has a side-effect on the per project info cache |
216 |
nameCollector.setJavadoc(BinaryMethod.this.getAttachedJavadoc(null)); |
216 |
nameCollector.setJavadoc(BinaryMethod.this.getAttachedJavadoc(null)); |
217 |
} catch (JavaModelException e) { |
217 |
} catch (JavaModelException e) { |
218 |
// ignore |
218 |
// ignore |
219 |
} |
219 |
} |
220 |
synchronized(nameCollector) { |
220 |
synchronized(nameCollector) { |
221 |
nameCollector.notify(); |
221 |
nameCollector.notify(); |
222 |
} |
222 |
} |
Lines 231-247
Link Here
|
231 |
} |
231 |
} |
232 |
} |
232 |
} |
233 |
javadocContents = nameCollector.getJavadoc(); |
233 |
javadocContents = nameCollector.getJavadoc(); |
234 |
} else if (javadocContents != BinaryType.EMPTY_JAVADOC){ |
234 |
} else if (javadocContents != BinaryType.EMPTY_JAVADOC){ |
235 |
// need to extract the part relative to the binary method since javadoc contains the javadoc for the declaring type |
235 |
// need to extract the part relative to the binary method since javadoc contains the javadoc for the declaring type |
236 |
try { |
236 |
try { |
237 |
javadocContents = extractJavadoc(declaringType, javadocContents); |
237 |
javadocContents = extractJavadoc(declaringType, javadocContents); |
238 |
} catch(JavaModelException e) { |
238 |
} catch(JavaModelException e) { |
239 |
// ignore |
239 |
// ignore |
240 |
} |
240 |
} |
241 |
} else { |
241 |
} else { |
242 |
// we don't want to set the parameter names |
242 |
// let's see if we can retrieve them from the debug infos |
243 |
return getRawParameterNames(paramCount); |
243 |
char[][] argumentNames = info.getArgumentNames(); |
244 |
} |
244 |
if (argumentNames != null && argumentNames.length == paramCount) { |
|
|
245 |
String[] names = new String[paramCount]; |
246 |
for (int i = 0; i < paramCount; i++) { |
247 |
names[i] = new String(argumentNames[i]); |
248 |
} |
249 |
return this.parameterNames = names; |
250 |
} |
251 |
return getRawParameterNames(paramCount); |
252 |
} |
245 |
if (javadocContents != null && javadocContents != BinaryType.EMPTY_JAVADOC) { |
253 |
if (javadocContents != null && javadocContents != BinaryType.EMPTY_JAVADOC) { |
246 |
final int indexOfOpenParen = javadocContents.indexOf('('); |
254 |
final int indexOfOpenParen = javadocContents.indexOf('('); |
247 |
if (indexOfOpenParen != -1) { |
255 |
if (indexOfOpenParen != -1) { |
Lines 268-273
Link Here
|
268 |
} |
276 |
} |
269 |
} |
277 |
} |
270 |
} |
278 |
} |
|
|
279 |
// let's see if we can retrieve them from the debug infos |
280 |
char[][] argumentNames = info.getArgumentNames(); |
281 |
if (argumentNames != null && argumentNames.length == paramCount) { |
282 |
String[] names = new String[paramCount]; |
283 |
for (int i = 0; i < paramCount; i++) { |
284 |
names[i] = new String(argumentNames[i]); |
285 |
} |
286 |
return this.parameterNames = names; |
287 |
} |
271 |
} |
288 |
} |
272 |
// if still no parameter names, produce fake ones |
289 |
// if still no parameter names, produce fake ones |
273 |
return this.parameterNames = getRawParameterNames(paramCount); |
290 |
return this.parameterNames = getRawParameterNames(paramCount); |