Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2008 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2011 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 10-18
Link Here
|
10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.jdt.core.tests.model; |
11 |
package org.eclipse.jdt.core.tests.model; |
12 |
|
12 |
|
|
|
13 |
import java.io.IOException; |
14 |
|
13 |
import org.eclipse.core.runtime.CoreException; |
15 |
import org.eclipse.core.runtime.CoreException; |
14 |
import org.eclipse.jdt.core.*; |
16 |
import org.eclipse.jdt.core.*; |
15 |
import org.eclipse.jdt.core.tests.util.Util; |
17 |
import org.eclipse.jdt.core.tests.util.Util; |
|
|
18 |
import org.eclipse.jdt.internal.core.LocalVariable; |
16 |
|
19 |
|
17 |
import junit.framework.Test; |
20 |
import junit.framework.Test; |
18 |
|
21 |
|
Lines 95-101
Link Here
|
95 |
} |
98 |
} |
96 |
static { |
99 |
static { |
97 |
// TESTS_NUMBERS = new int[] { 182, 183 }; |
100 |
// TESTS_NUMBERS = new int[] { 182, 183 }; |
98 |
// TESTS_NAMES = new String[] {"test0177"}; |
101 |
// TESTS_NAMES = new String[] {"testParamAnnotations2"}; |
99 |
} |
102 |
} |
100 |
public static Test suite() { |
103 |
public static Test suite() { |
101 |
return buildModelTestSuite(TypeResolveTests.class); |
104 |
return buildModelTestSuite(TypeResolveTests.class); |
Lines 299-302
Link Here
|
299 |
"p4.A.Inner", |
302 |
"p4.A.Inner", |
300 |
types); |
303 |
types); |
301 |
} |
304 |
} |
|
|
305 |
/** |
306 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=334783" |
307 |
*/ |
308 |
public void testParamAnnotations() throws CoreException { |
309 |
try { |
310 |
createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin", "1.5"); |
311 |
String source = "package p;" + |
312 |
"public class X<T> {\n" + |
313 |
" X<String> field;\n" + |
314 |
" @Inject " + |
315 |
" public void Test(@Default String processor) {}" + |
316 |
"}" + |
317 |
"@interface Inject{\n" + |
318 |
"}" + |
319 |
"@interface Default{\n" + |
320 |
"}"; |
321 |
createFolder("/P/src/p"); |
322 |
createFile( |
323 |
"/P/src/p/X.java", |
324 |
source |
325 |
); |
326 |
waitForAutoBuild(); |
327 |
|
328 |
ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java"); |
329 |
IJavaElement[] variable = ((ICodeAssist) unit).codeSelect(source.indexOf("processor"), "processor".length()); |
330 |
|
331 |
assertEquals(1, variable.length); |
332 |
String annotationString = "@Default [in processor [in Test(String) [in X [in X.java [in p [in src [in P]]]]]]]"; |
333 |
assertEquals(annotationString, ((LocalVariable)variable[0]).getAnnotations()[0].toString()); |
334 |
IType type = unit.getType("X"); |
335 |
|
336 |
IMethod method = type.getMethods()[0]; |
337 |
assertEquals(annotationString, method.getParameterAnnotations()[0][0].toString()); |
338 |
} finally { |
339 |
deleteProject("P"); |
340 |
} |
341 |
} |
342 |
/** |
343 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=334783" |
344 |
*/ |
345 |
public void testParamAnnotations2() throws CoreException, IOException { |
346 |
try { |
347 |
IJavaProject project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin", "1.5"); |
348 |
String[] pathAndContents = new String[]{"p/X.java", |
349 |
"package p;" + |
350 |
"public class X<T> {\n" + |
351 |
" X<String> field;\n" + |
352 |
" @Inject " + |
353 |
" public void Test(@Default String processor) {}" + |
354 |
"}" + |
355 |
"@interface Inject{\n" + |
356 |
"}" + |
357 |
"@interface Default{\n" + |
358 |
"}"}; |
359 |
addLibrary(project, "lib334783.jar", "libsrc.zip", pathAndContents, JavaCore.VERSION_1_5); |
360 |
|
361 |
waitForAutoBuild(); |
362 |
IPackageFragmentRoot root = project.getPackageFragmentRoot(getFile("/P/lib334783.jar")); |
363 |
IType type = root.getPackageFragment("p").getClassFile("X.class").getType(); |
364 |
String annotationString = "@p.Default (not open) [in Test(java.lang.String) [in X [in X.class [in p [in lib334783.jar [in P]]]]]]"; |
365 |
|
366 |
IMethod method = type.getMethods()[1]; |
367 |
assertEquals(annotationString, method.getParameterAnnotations()[0][0].toString()); |
368 |
} finally { |
369 |
deleteProject("P"); |
370 |
} |
371 |
} |
302 |
} |
372 |
} |