Lines 20-25
Link Here
|
20 |
|
20 |
|
21 |
import org.eclipse.core.resources.IFile; |
21 |
import org.eclipse.core.resources.IFile; |
22 |
import org.eclipse.core.resources.IProject; |
22 |
import org.eclipse.core.resources.IProject; |
|
|
23 |
import org.eclipse.core.resources.IResource; |
23 |
import org.eclipse.core.resources.IWorkspaceRunnable; |
24 |
import org.eclipse.core.resources.IWorkspaceRunnable; |
24 |
import org.eclipse.core.runtime.CoreException; |
25 |
import org.eclipse.core.runtime.CoreException; |
25 |
import org.eclipse.core.runtime.IPath; |
26 |
import org.eclipse.core.runtime.IPath; |
Lines 2249-2252
Link Here
|
2249 |
this.deleteProject("P2"); |
2250 |
this.deleteProject("P2"); |
2250 |
} |
2251 |
} |
2251 |
} |
2252 |
} |
|
|
2253 |
/** |
2254 |
* @bug 162621: [model][delta] Validation errors do not clear after replacing jar file |
2255 |
* @test Ensures that changing an internal jar and refreshing takes the change into account |
2256 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=162621" |
2257 |
*/ |
2258 |
public void testChangeInternalJar() throws CoreException, IOException { |
2259 |
String jarName = "b162621.jar"; |
2260 |
try { |
2261 |
// Create jar file with a class with 2 methods doXXX |
2262 |
String[] pathAndContents = new String[] { |
2263 |
"pack/Util.java", |
2264 |
"package pack;\n" + |
2265 |
"public class Util {\n" + |
2266 |
" public void doit2A(int x, int y) { }\n" + |
2267 |
" public void doit2B(int x) { }\n" + |
2268 |
"}\n" |
2269 |
}; |
2270 |
addLibrary(jarName, "b162621_src.zip", pathAndContents, JavaCore.VERSION_1_4); |
2271 |
|
2272 |
// Create compilation unit in which completion occurs |
2273 |
String path = "/Completion/src/test/Test.java"; |
2274 |
String source = "package test;\n" + |
2275 |
"import pack.*;\n" + |
2276 |
"public class Test {\n" + |
2277 |
" public void foo() {\n" + |
2278 |
" Util test = new Util();\n" + |
2279 |
" test.doit2A(1, 2);\n" + |
2280 |
" }\n" + |
2281 |
"}\n"; |
2282 |
createFolder("/Completion/src/test"); |
2283 |
createFile(path, source); |
2284 |
|
2285 |
// first completion |
2286 |
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); |
2287 |
ICompilationUnit unit = getCompilationUnit(path); |
2288 |
String completeBehind = "test.do"; |
2289 |
int cursorLocation = source.lastIndexOf(completeBehind) + completeBehind.length(); |
2290 |
unit.codeComplete(cursorLocation, requestor); |
2291 |
assertResults( |
2292 |
"doit2A[METHOD_REF]{doit2A, Lpack.Util;, (II)V, doit2A, "+(R_DEFAULT + R_CASE + R_INTERESTING + R_NON_RESTRICTED + R_NON_STATIC) + "}\n" + |
2293 |
"doit2B[METHOD_REF]{doit2B, Lpack.Util;, (I)V, doit2B, "+(R_DEFAULT + R_CASE + R_INTERESTING + R_NON_RESTRICTED + R_NON_STATIC) + "}", |
2294 |
requestor.getResults()); |
2295 |
|
2296 |
// change class file to add a third doXXX method and refresh |
2297 |
String projectLocation = this.currentProject.getProject().getLocation().toOSString(); |
2298 |
String jarPath = projectLocation + File.separator + jarName; |
2299 |
org.eclipse.jdt.core.tests.util.Util.createJar(new String[] { |
2300 |
"pack/Util.java", |
2301 |
"package pack;\n" + |
2302 |
"public class Util {\n" + |
2303 |
" public void doit2A(int x, int y) { }\n" + |
2304 |
" public void doit2B(int x) { }\n" + |
2305 |
" public void doit2C(int x) { }\n" + |
2306 |
"}\n" |
2307 |
}, jarPath, "1.4"); |
2308 |
this.currentProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null); |
2309 |
|
2310 |
// second completion |
2311 |
requestor = new CompletionTestsRequestor2(); |
2312 |
unit.codeComplete(cursorLocation, requestor); |
2313 |
assertResults( |
2314 |
"doit2A[METHOD_REF]{doit2A, Lpack.Util;, (II)V, doit2A, "+(R_DEFAULT + R_CASE + R_INTERESTING + R_NON_RESTRICTED + R_NON_STATIC) + "}\n" + |
2315 |
"doit2B[METHOD_REF]{doit2B, Lpack.Util;, (I)V, doit2B, "+(R_DEFAULT + R_CASE + R_INTERESTING + R_NON_RESTRICTED + R_NON_STATIC) + "}\n" + |
2316 |
"doit2C[METHOD_REF]{doit2C, Lpack.Util;, (I)V, doit2C, "+(R_DEFAULT + R_CASE + R_INTERESTING + R_NON_RESTRICTED + R_NON_STATIC) + "}", |
2317 |
requestor.getResults()); |
2318 |
} finally { |
2319 |
removeLibraryEntry(this.currentProject, new Path(jarName)); |
2320 |
deleteFile(new File(jarName)); |
2321 |
} |
2322 |
} |
2252 |
} |
2323 |
} |