Lines 14-21
Link Here
|
14 |
|
14 |
|
15 |
import org.eclipse.core.resources.IFile; |
15 |
import org.eclipse.core.resources.IFile; |
16 |
import org.eclipse.core.runtime.CoreException; |
16 |
import org.eclipse.core.runtime.CoreException; |
|
|
17 |
import org.eclipse.core.runtime.IProgressMonitor; |
17 |
import org.eclipse.core.runtime.NullProgressMonitor; |
18 |
import org.eclipse.core.runtime.NullProgressMonitor; |
18 |
import org.eclipse.jdt.core.*; |
19 |
import org.eclipse.jdt.core.IClasspathEntry; |
|
|
20 |
import org.eclipse.jdt.core.ICompilationUnit; |
21 |
import org.eclipse.jdt.core.IJavaProject; |
22 |
import org.eclipse.jdt.core.IPackageFragment; |
23 |
import org.eclipse.jdt.core.IPackageFragmentRoot; |
24 |
import org.eclipse.jdt.core.IType; |
25 |
import org.eclipse.jdt.core.JavaCore; |
26 |
import org.eclipse.jdt.core.JavaModelException; |
27 |
import org.eclipse.jdt.core.dom.AST; |
28 |
import org.eclipse.jdt.core.dom.ASTParser; |
19 |
import org.eclipse.jdt.internal.core.SourceType; |
29 |
import org.eclipse.jdt.internal.core.SourceType; |
20 |
|
30 |
|
21 |
/** |
31 |
/** |
Lines 1166-1169
Link Here
|
1166 |
public void testFindSecondaryType_Unknown03() throws JavaModelException, CoreException { |
1176 |
public void testFindSecondaryType_Unknown03() throws JavaModelException, CoreException { |
1167 |
assertTypeUnknown("org.eclipse.jdt.core.test.Unknown"); |
1177 |
assertTypeUnknown("org.eclipse.jdt.core.test.Unknown"); |
1168 |
} |
1178 |
} |
|
|
1179 |
|
1180 |
/** |
1181 |
* @bug 152841: [model] IJavaProject.findType(name, monitor) doesn't find secondary type |
1182 |
* @test Ensure that secondary type is found just after having created the compilation unit |
1183 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=152841" |
1184 |
*/ |
1185 |
public void testBug152841() throws Exception{ |
1186 |
try { |
1187 |
IJavaProject project= createJavaProject("P", new String[] { "src" }, new String[] { "JCL_LIB" }, "bin"); |
1188 |
IPackageFragmentRoot root = (IPackageFragmentRoot) project.getChildren()[0]; |
1189 |
IPackageFragment pack= root.createPackageFragment("p", true, null); |
1190 |
|
1191 |
String source= "package p;\n" + |
1192 |
"//use Object\n" + |
1193 |
"class A {\n" + |
1194 |
" public void foo(){};\n" + |
1195 |
"}"; |
1196 |
pack.createCompilationUnit("A.java", source, true, null); |
1197 |
|
1198 |
source= "package p;\n" + |
1199 |
"\n" + |
1200 |
"class Test{\n" + |
1201 |
" void test(){\n" + |
1202 |
" A a= new A();\n" + |
1203 |
" test(a);\n" + |
1204 |
" }\n" + |
1205 |
" void test(Object o){\n" + |
1206 |
" o.hashCode();\n" + |
1207 |
" }\n" + |
1208 |
"}"; |
1209 |
ICompilationUnit cu= pack.createCompilationUnit("Test.java", source, true, null); |
1210 |
|
1211 |
ASTParser parser= ASTParser.newParser(AST.JLS3); |
1212 |
parser.setSource(cu); |
1213 |
parser.setResolveBindings(true); |
1214 |
parser.createAST(null); |
1215 |
|
1216 |
source= "package p;\n" + |
1217 |
"//use C\n" + |
1218 |
"interface I{}\n" + |
1219 |
"class C implements I{\n" + |
1220 |
"}\n" + |
1221 |
"class B extends C{\n" + |
1222 |
"}\n" + |
1223 |
"class A extends B{" + |
1224 |
"}\n" + |
1225 |
"class Test{\n" + |
1226 |
" void f(){\n" + |
1227 |
" A c= new A();\n" + |
1228 |
" c.toString();\n" + |
1229 |
" }\n" + |
1230 |
"}"; |
1231 |
|
1232 |
ICompilationUnit unit= pack.createCompilationUnit("I.java", source, true, null); |
1233 |
IType type= project.findType("p.I", (IProgressMonitor) null); |
1234 |
assertNotNull(type); |
1235 |
|
1236 |
// C exists |
1237 |
assertTrue(unit.getType("C").exists()); |
1238 |
|
1239 |
// but can't be found |
1240 |
type= project.findType("p.C", (IProgressMonitor) null); |
1241 |
assertNotNull(type); |
1242 |
} |
1243 |
finally { |
1244 |
deleteProject("P"); |
1245 |
} |
1246 |
} |
1169 |
} |
1247 |
} |