Added
Link Here
|
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2008 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
6 |
* http://www.eclipse.org/legal/epl-v10.html |
7 |
* |
8 |
* Contributors: |
9 |
* IBM Corporation - initial API and implementation |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.jdt.core.tests.model; |
12 |
|
13 |
import org.eclipse.jdt.core.*; |
14 |
|
15 |
import junit.framework.*; |
16 |
|
17 |
public class ResolveTests2 extends ModifyingResourceTests { |
18 |
|
19 |
static { |
20 |
// TESTS_NAMES = new String[] { "testSecondaryTypes" }; |
21 |
} |
22 |
public static Test suite() { |
23 |
return buildModelTestSuite(ResolveTests2.class); |
24 |
} |
25 |
|
26 |
public ResolveTests2(String name) { |
27 |
super(name); |
28 |
} |
29 |
public void setUpSuite() throws Exception { |
30 |
super.setUpSuite(); |
31 |
|
32 |
setUpJavaProject("Resolve"); |
33 |
} |
34 |
public void tearDownSuite() throws Exception { |
35 |
deleteProject("Resolve"); |
36 |
|
37 |
super.tearDownSuite(); |
38 |
} |
39 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=227822 |
40 |
public void testBug227822a() throws Exception { |
41 |
try { |
42 |
// create P1 |
43 |
this.createJavaProject( |
44 |
"P1", |
45 |
new String[]{"src"}, |
46 |
new String[]{}, |
47 |
"bin"); |
48 |
|
49 |
this.createFolder("/P1/src/a"); |
50 |
this.createFile( |
51 |
"/P1/src/a/Test.java", |
52 |
"package a;\n"+ |
53 |
"public class Test {\n" + |
54 |
" java.lang.Object var;\n"+ |
55 |
"}"); |
56 |
|
57 |
waitUntilIndexesReady(); |
58 |
|
59 |
// do code select |
60 |
ICompilationUnit cu= getCompilationUnit("P1", "src", "a", "Test.java"); |
61 |
|
62 |
String str = cu.getSource(); |
63 |
|
64 |
String selection = "java.lang.Object"; |
65 |
int start = str.lastIndexOf(selection); |
66 |
int length = selection.length(); |
67 |
IJavaElement[] elements = cu.codeSelect(start, length); |
68 |
|
69 |
assertElementsEqual( |
70 |
"Unexpected elements", |
71 |
"", |
72 |
elements |
73 |
); |
74 |
} finally { |
75 |
this.deleteProject("P1"); |
76 |
} |
77 |
} |
78 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=227822 |
79 |
public void testBug227822b() throws Exception { |
80 |
try { |
81 |
// create P1 |
82 |
this.createJavaProject( |
83 |
"P1", |
84 |
new String[]{"src"}, |
85 |
new String[]{}, |
86 |
"bin"); |
87 |
|
88 |
this.createFolder("/P1/src/a"); |
89 |
this.createFile( |
90 |
"/P1/src/a/Test.java", |
91 |
"package a;\n"+ |
92 |
"public class Test {\n" + |
93 |
" javaz.lang.Objectz var;\n"+ |
94 |
"}"); |
95 |
|
96 |
waitUntilIndexesReady(); |
97 |
|
98 |
// do code select |
99 |
ICompilationUnit cu= getCompilationUnit("P1", "src", "a", "Test.java"); |
100 |
|
101 |
String str = cu.getSource(); |
102 |
|
103 |
String selection = "javaz.lang.Objectz"; |
104 |
int start = str.lastIndexOf(selection); |
105 |
int length = selection.length(); |
106 |
IJavaElement[] elements = cu.codeSelect(start, length); |
107 |
|
108 |
assertElementsEqual( |
109 |
"Unexpected elements", |
110 |
"", |
111 |
elements |
112 |
); |
113 |
} finally { |
114 |
this.deleteProject("P1"); |
115 |
} |
116 |
} |
117 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=227822 |
118 |
public void testBug227822c() throws Exception { |
119 |
try { |
120 |
// create P1 |
121 |
this.createJavaProject( |
122 |
"P1", |
123 |
new String[]{"src"}, |
124 |
new String[]{}, |
125 |
"bin"); |
126 |
|
127 |
this.createFolder("/P1/src/a"); |
128 |
this.createFile( |
129 |
"/P1/src/a/Test.java", |
130 |
"package a;\n"+ |
131 |
"public class Test {\n" + |
132 |
" java var;\n"+ |
133 |
"}"); |
134 |
|
135 |
waitUntilIndexesReady(); |
136 |
|
137 |
// do code select |
138 |
ICompilationUnit cu= getCompilationUnit("P1", "src", "a", "Test.java"); |
139 |
|
140 |
String str = cu.getSource(); |
141 |
|
142 |
String selection = "java"; |
143 |
int start = str.lastIndexOf(selection); |
144 |
int length = selection.length(); |
145 |
IJavaElement[] elements = cu.codeSelect(start, length); |
146 |
|
147 |
assertElementsEqual( |
148 |
"Unexpected elements", |
149 |
"", |
150 |
elements |
151 |
); |
152 |
} finally { |
153 |
this.deleteProject("P1"); |
154 |
} |
155 |
} |
156 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=227822 |
157 |
public void testBug227822d() throws Exception { |
158 |
try { |
159 |
// create P1 |
160 |
this.createJavaProject( |
161 |
"P1", |
162 |
new String[]{"src"}, |
163 |
new String[]{}, |
164 |
"bin"); |
165 |
|
166 |
this.createFolder("/P1/src/a"); |
167 |
this.createFile( |
168 |
"/P1/src/a/Test.java", |
169 |
"package a;\n"+ |
170 |
"public class Test {\n" + |
171 |
" javaz var;\n"+ |
172 |
"}"); |
173 |
|
174 |
waitUntilIndexesReady(); |
175 |
|
176 |
// do code select |
177 |
ICompilationUnit cu= getCompilationUnit("P1", "src", "a", "Test.java"); |
178 |
|
179 |
String str = cu.getSource(); |
180 |
|
181 |
String selection = "javaz"; |
182 |
int start = str.lastIndexOf(selection); |
183 |
int length = selection.length(); |
184 |
IJavaElement[] elements = cu.codeSelect(start, length); |
185 |
|
186 |
assertElementsEqual( |
187 |
"Unexpected elements", |
188 |
"", |
189 |
elements |
190 |
); |
191 |
} finally { |
192 |
this.deleteProject("P1"); |
193 |
} |
194 |
} |
195 |
} |