|
Removed
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2000, 2011 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.wst.jsdt.core.tests.model; |
| 12 |
|
| 13 |
import java.io.File; |
| 14 |
import java.io.FileOutputStream; |
| 15 |
import java.io.IOException; |
| 16 |
import java.util.HashMap; |
| 17 |
import java.util.Map; |
| 18 |
import java.util.StringTokenizer; |
| 19 |
|
| 20 |
import junit.framework.ComparisonFailure; |
| 21 |
import junit.framework.Test; |
| 22 |
|
| 23 |
import org.eclipse.core.resources.IFile; |
| 24 |
import org.eclipse.core.resources.IProject; |
| 25 |
import org.eclipse.core.resources.IWorkspaceRunnable; |
| 26 |
import org.eclipse.core.runtime.CoreException; |
| 27 |
import org.eclipse.core.runtime.IPath; |
| 28 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 29 |
import org.eclipse.core.runtime.Path; |
| 30 |
import org.eclipse.wst.jsdt.core.IAccessRule; |
| 31 |
import org.eclipse.wst.jsdt.core.IIncludePathAttribute; |
| 32 |
import org.eclipse.wst.jsdt.core.IIncludePathEntry; |
| 33 |
import org.eclipse.wst.jsdt.core.IJavaScriptProject; |
| 34 |
import org.eclipse.wst.jsdt.core.IJavaScriptUnit; |
| 35 |
import org.eclipse.wst.jsdt.core.IJsGlobalScopeContainer; |
| 36 |
import org.eclipse.wst.jsdt.core.JavaScriptCore; |
| 37 |
import org.eclipse.wst.jsdt.internal.codeassist.RelevanceConstants; |
| 38 |
|
| 39 |
public class CompletionTests2 extends ModifyingResourceTests implements RelevanceConstants { |
| 40 |
|
| 41 |
public static final String DEFUALT_JSDTSCOPE = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + |
| 42 |
"<classpath>\n" + |
| 43 |
" <classpathentry kind=\"src\" path=\"\"/>\n" + |
| 44 |
" <classpathentry kind=\"con\" path=\"org.eclipse.wst.jsdt.launching.JRE_CONTAINER\"/>\n"+ |
| 45 |
" <classpathentry kind=\"output\" path=\"\"/>\n"+ |
| 46 |
"</classpath>"; |
| 47 |
/* |
| 48 |
.project = DEFAULT_PROJECT_LEFT + project name + DEFAULT_PROJECT_RIGHT; |
| 49 |
*/ |
| 50 |
public static final String DEFAULT_PROJECT_LEFT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + |
| 51 |
"<projectDescription>\n" + |
| 52 |
" <name>"; |
| 53 |
|
| 54 |
|
| 55 |
public static final String DEFAULT_PROJECT_RIGHT ="</name>\n" + |
| 56 |
" <comment></comment>\n" + |
| 57 |
" <projects>\n" + |
| 58 |
" </projects>\n"+ |
| 59 |
" <buildSpec>\n"+ |
| 60 |
" <buildCommand>\n"+ |
| 61 |
" <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>\n"+ |
| 62 |
" <arguments>\n"+ |
| 63 |
" </arguments>\n"+ |
| 64 |
" </buildCommand>\n"+ |
| 65 |
" </buildSpec>\n"+ |
| 66 |
" <natures>\n"+ |
| 67 |
" <nature>org.eclipse.wst.jsdt.core.jsNature</nature>\n"+ |
| 68 |
" </natures>\n" + |
| 69 |
"</projectDescription>"; |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
public static class CompletionContainerInitializer implements ContainerInitializer.ITestInitializer { |
| 76 |
|
| 77 |
public static class DefaultContainer implements IJsGlobalScopeContainer { |
| 78 |
char[][] libPaths; |
| 79 |
boolean[] areExported; |
| 80 |
String[] forbiddenReferences; |
| 81 |
public DefaultContainer(char[][] libPaths, boolean[] areExported, String[] forbiddenReferences) { |
| 82 |
this.libPaths = libPaths; |
| 83 |
this.areExported = areExported; |
| 84 |
this.forbiddenReferences = forbiddenReferences; |
| 85 |
} |
| 86 |
/** |
| 87 |
* @deprecated Use {@link #getIncludepathEntries()} instead |
| 88 |
*/ |
| 89 |
public IIncludePathEntry[] getClasspathEntries() { |
| 90 |
return getIncludepathEntries(); |
| 91 |
} |
| 92 |
public IIncludePathEntry[] getIncludepathEntries() { |
| 93 |
int length = this.libPaths.length; |
| 94 |
IIncludePathEntry[] entries = new IIncludePathEntry[length]; |
| 95 |
for (int j = 0; j < length; j++) { |
| 96 |
IPath path = new Path(new String(this.libPaths[j])); |
| 97 |
boolean isExported = this.areExported[j]; |
| 98 |
|
| 99 |
IAccessRule[] accessRules; |
| 100 |
if(forbiddenReferences != null && forbiddenReferences[j]!= null && forbiddenReferences[j].length() != 0) { |
| 101 |
StringTokenizer tokenizer = new StringTokenizer(forbiddenReferences[j], ";"); |
| 102 |
int count = tokenizer.countTokens(); |
| 103 |
accessRules = new IAccessRule[count]; |
| 104 |
String token = null; |
| 105 |
for (int i = 0; i < count; i++) { |
| 106 |
token = tokenizer.nextToken(); |
| 107 |
accessRules[i] = JavaScriptCore.newAccessRule(new Path(token), IAccessRule.K_NON_ACCESSIBLE); |
| 108 |
} |
| 109 |
} else { |
| 110 |
accessRules = new IAccessRule[0]; |
| 111 |
} |
| 112 |
if (path.segmentCount() == 1) { |
| 113 |
entries[j] = JavaScriptCore.newProjectEntry(path, accessRules, true, new IIncludePathAttribute[0], isExported); |
| 114 |
} else { |
| 115 |
entries[j] = JavaScriptCore.newLibraryEntry(path, null, null, accessRules, new IIncludePathAttribute[0], isExported); |
| 116 |
} |
| 117 |
} |
| 118 |
return entries; |
| 119 |
} |
| 120 |
public String getDescription() { |
| 121 |
return "Test container"; |
| 122 |
} |
| 123 |
public int getKind() { |
| 124 |
return IJsGlobalScopeContainer.K_APPLICATION; |
| 125 |
} |
| 126 |
public IPath getPath() { |
| 127 |
return new Path("org.eclipse.wst.jsdt.core.tests.model.TEST_CONTAINER"); |
| 128 |
} |
| 129 |
/* (non-Javadoc) |
| 130 |
* @see org.eclipse.wst.jsdt.core.IJsGlobalScopeContainer#resolvedLibraryImport(java.lang.String) |
| 131 |
*/ |
| 132 |
public String[] resolvedLibraryImport(String a) { |
| 133 |
return new String[] {a}; |
| 134 |
} |
| 135 |
} |
| 136 |
|
| 137 |
Map containerValues; |
| 138 |
CoreException exception; |
| 139 |
|
| 140 |
public CompletionContainerInitializer(String projectName, String[] libPaths, boolean[] areExported) { |
| 141 |
this(projectName, libPaths, areExported, null); |
| 142 |
} |
| 143 |
public CompletionContainerInitializer(String projectName, String[] libPaths, boolean[] areExported, String[] forbiddenRefrences) { |
| 144 |
containerValues = new HashMap(); |
| 145 |
|
| 146 |
int libPathsLength = libPaths.length; |
| 147 |
char[][] charLibPaths = new char[libPathsLength][]; |
| 148 |
for (int i = 0; i < libPathsLength; i++) { |
| 149 |
charLibPaths[i] = libPaths[i].toCharArray(); |
| 150 |
} |
| 151 |
containerValues.put( |
| 152 |
projectName, |
| 153 |
newContainer(charLibPaths, areExported, forbiddenRefrences) |
| 154 |
); |
| 155 |
} |
| 156 |
protected DefaultContainer newContainer(final char[][] libPaths, final boolean[] areExperted, final String[] forbiddenRefrences) { |
| 157 |
return new DefaultContainer(libPaths, areExperted, forbiddenRefrences); |
| 158 |
} |
| 159 |
public boolean allowFailureContainer() { |
| 160 |
return true; |
| 161 |
} |
| 162 |
public void initialize(IPath containerPath, IJavaScriptProject project) throws CoreException { |
| 163 |
if (containerValues == null) return; |
| 164 |
try { |
| 165 |
JavaScriptCore.setJsGlobalScopeContainer( |
| 166 |
containerPath, |
| 167 |
new IJavaScriptProject[] {project}, |
| 168 |
new IJsGlobalScopeContainer[] {(IJsGlobalScopeContainer)containerValues.get(project.getElementName())}, |
| 169 |
null); |
| 170 |
} catch (CoreException e) { |
| 171 |
this.exception = e; |
| 172 |
throw e; |
| 173 |
} |
| 174 |
} |
| 175 |
} |
| 176 |
public CompletionTests2(String name) { |
| 177 |
super(name); |
| 178 |
} |
| 179 |
public void setUpSuite() throws Exception { |
| 180 |
super.setUpSuite(); |
| 181 |
|
| 182 |
setUpJavaProject("Completion"); |
| 183 |
} |
| 184 |
public void tearDownSuite() throws Exception { |
| 185 |
deleteProject("Completion"); |
| 186 |
|
| 187 |
super.tearDownSuite(); |
| 188 |
} |
| 189 |
|
| 190 |
protected static void assertResults(String expected, String actual) { |
| 191 |
try { |
| 192 |
assertEquals(expected, actual); |
| 193 |
} catch(ComparisonFailure c) { |
| 194 |
System.out.println(actual); |
| 195 |
System.out.println(); |
| 196 |
throw c; |
| 197 |
} |
| 198 |
} |
| 199 |
static { |
| 200 |
// TESTS_NAMES = new String[] { "testBug96950" }; |
| 201 |
} |
| 202 |
public static Test suite() { |
| 203 |
return buildModelTestSuite(CompletionTests2.class); |
| 204 |
} |
| 205 |
|
| 206 |
File createFile(File parent, String name, String content) throws IOException { |
| 207 |
File file = new File(parent, name); |
| 208 |
FileOutputStream out = new FileOutputStream(file); |
| 209 |
out.write(content.getBytes()); |
| 210 |
out.close(); |
| 211 |
return file; |
| 212 |
} |
| 213 |
File createDirectory(File parent, String name) { |
| 214 |
File dir = new File(parent, name); |
| 215 |
dir.mkdirs(); |
| 216 |
return dir; |
| 217 |
} |
| 218 |
/** |
| 219 |
* Test for bug 29832 |
| 220 |
*/ |
| 221 |
public void testBug29832() throws Exception { |
| 222 |
try { |
| 223 |
// create variable |
| 224 |
// JavaScriptCore.setClasspathVariables( |
| 225 |
// new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"}, |
| 226 |
// new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()}, |
| 227 |
// null); |
| 228 |
|
| 229 |
// create P1 |
| 230 |
// IFile f = getFile("/Completion/lib.jar"); |
| 231 |
IFile f = getFile("/Completion/ZZZ.js"); |
| 232 |
|
| 233 |
|
| 234 |
IJavaScriptProject p = this.createJavaProject( |
| 235 |
"P1", |
| 236 |
new String[]{"/"}, |
| 237 |
new String[]{}); |
| 238 |
IFile libFile = this.createFile("/P1/ZZZ.js", f.getContents()); |
| 239 |
this.addLibraryEntry(p, libFile.getLocation().toString(), true); |
| 240 |
|
| 241 |
// create P2 |
| 242 |
this.createJavaProject( |
| 243 |
"P2", |
| 244 |
new String[]{"/"}, |
| 245 |
new String[]{}, |
| 246 |
new String[]{"/P1"}); |
| 247 |
this.createFile( |
| 248 |
"/P2/X.js", |
| 249 |
"function testZZZClass {\n"+ |
| 250 |
" var z = new ZZZ();\n"+ |
| 251 |
" z;\n" + |
| 252 |
"}"); |
| 253 |
|
| 254 |
waitUntilIndexesReady(); |
| 255 |
|
| 256 |
// do completion |
| 257 |
CompletionTestsRequestor requestor = new CompletionTestsRequestor(); |
| 258 |
IJavaScriptUnit cu= getCompilationUnit("P2", "", "", "X.js"); |
| 259 |
|
| 260 |
String str = cu.getSource(); |
| 261 |
String completeBehind = "z"; |
| 262 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 263 |
cu.codeComplete(cursorLocation, requestor); |
| 264 |
|
| 265 |
// assertEquals( |
| 266 |
// "element:ZZZ completion:pz.ZZZ relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED), |
| 267 |
// requestor.getResults()); |
| 268 |
assertEquals( |
| 269 |
"element:ZZZ completion:ZZZ relevance:" +(R_DEFAULT+R_RESOLVED+R_INTERESTING+R_NON_RESTRICTED) + "\n"+ |
| 270 |
"element:ZZZ_FUNCTION completion:ZZZ_FUNCTION() relevance:11\n" + |
| 271 |
"element:ZZZ_FUNCTION completion:ZZZ_FUNCTION() relevance:11\n" + |
| 272 |
"element:z completion:z relevance:"+ (R_DEFAULT+R_RESOLVED+R_INTERESTING+R_CASE+R_EXACT_NAME+R_UNQUALIFIED+R_NON_RESTRICTED), |
| 273 |
requestor.getResults()); |
| 274 |
|
| 275 |
// delete P1 |
| 276 |
p.getProject().delete(true, false, null); |
| 277 |
|
| 278 |
// create P1 |
| 279 |
File dest = getWorkspaceRoot().getLocation().toFile(); |
| 280 |
File pro = this.createDirectory(dest, "P1"); |
| 281 |
File proSet = this.createDirectory(pro,".settings"); |
| 282 |
|
| 283 |
this.createFile(proSet, ".jsdtscope", DEFUALT_JSDTSCOPE); |
| 284 |
|
| 285 |
|
| 286 |
// "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + |
| 287 |
// "<classpath>\n" + |
| 288 |
// " <classpathentry kind=\"src\" path=\"\"/>\n" + |
| 289 |
// " <classpathentry kind=\"var\" path=\"JCL_LIB\" sourcepath=\"JCL_SRC\" rootpath=\"JCL_SRCROOT\"/>\n" + |
| 290 |
// " <classpathentry kind=\"output\" path=\"bin\"/>\n" + |
| 291 |
// "</classpath>"); |
| 292 |
|
| 293 |
this.createFile(pro, ".project", DEFAULT_PROJECT_LEFT + "org.eclipse.wst.jsdt.core" + DEFAULT_PROJECT_RIGHT); |
| 294 |
// "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + |
| 295 |
// "<projectDescription>\n" + |
| 296 |
// " <name>org.eclipse.wst.jsdt.core</name>\n" + |
| 297 |
// " <comment></comment>\n" + |
| 298 |
// " <projects>\n" + |
| 299 |
// " </projects>\n" + |
| 300 |
// " <buildSpec>\n" + |
| 301 |
// " <buildCommand>\n" + |
| 302 |
// " <name>org.eclipse.wst.jsdt.core.javabuilder</name>\n" + |
| 303 |
// " <arguments>\n" + |
| 304 |
// " </arguments>\n" + |
| 305 |
// " </buildCommand>\n" + |
| 306 |
// " </buildSpec>\n" + |
| 307 |
// " <natures>\n" + |
| 308 |
// " <nature>org.eclipse.wst.jsdt.core.javanature</nature>\n" + |
| 309 |
// " </natures>\n" + |
| 310 |
// "</projectDescription>"); |
| 311 |
|
| 312 |
//File src = this.createDirectory(pro, "src"); |
| 313 |
|
| 314 |
//File pz = this.createDirectory(src, "pz"); |
| 315 |
|
| 316 |
this.createFile(pro,"ZZZ.js","function testZZZClass {\n"+ |
| 317 |
" var z = new ZZZ();\n"+ |
| 318 |
" z;\n" + |
| 319 |
"}"); |
| 320 |
|
| 321 |
final IProject project = getWorkspaceRoot().getProject("P1"); |
| 322 |
IWorkspaceRunnable populate = new IWorkspaceRunnable() { |
| 323 |
public void run(IProgressMonitor monitor) throws CoreException { |
| 324 |
project.create(null); |
| 325 |
project.open(null); |
| 326 |
} |
| 327 |
}; |
| 328 |
getWorkspace().run(populate, null); |
| 329 |
JavaScriptCore.create(project); |
| 330 |
|
| 331 |
waitUntilIndexesReady(); |
| 332 |
|
| 333 |
// do completion |
| 334 |
requestor = new CompletionTestsRequestor(); |
| 335 |
cu.codeComplete(cursorLocation, requestor); |
| 336 |
|
| 337 |
assertEquals( |
| 338 |
"element:z completion:z relevance:"+ (R_DEFAULT+R_INTERESTING+R_CASE+R_EXACT_NAME+R_UNQUALIFIED+R_NON_RESTRICTED) + "\n" + |
| 339 |
"element:z completion:z relevance:"+(R_DEFAULT+R_RESOLVED+R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED), |
| 340 |
requestor.getResults()); |
| 341 |
} finally { |
| 342 |
this.deleteProject("P1"); |
| 343 |
this.deleteProject("P2"); |
| 344 |
} |
| 345 |
} |
| 346 |
/** |
| 347 |
* Test for bug 33560 |
| 348 |
*/ |
| 349 |
public void testBug33560() throws Exception { |
| 350 |
try { |
| 351 |
// create variable |
| 352 |
// JavaScriptCore.setClasspathVariables( |
| 353 |
// new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"}, |
| 354 |
// new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()}, |
| 355 |
// null); |
| 356 |
|
| 357 |
// create P1 |
| 358 |
//IFile f = getFile("/Completion/lib.jar"); |
| 359 |
IFile f = getFile("/Completion/ZZZ.js"); |
| 360 |
IJavaScriptProject p = this.createJavaProject( |
| 361 |
"P1", |
| 362 |
new String[]{"/"}, |
| 363 |
new String[]{});; |
| 364 |
IFile libFile = this.createFile("/P1/ZZZ.js", f.getContents()); |
| 365 |
this.addLibraryEntry(p, libFile.getLocation().toString(), true); |
| 366 |
|
| 367 |
// create P2 |
| 368 |
this.createJavaProject( |
| 369 |
"P2", |
| 370 |
new String[]{"/"}, |
| 371 |
new String[]{}, |
| 372 |
new String[]{"/P1"}); |
| 373 |
|
| 374 |
// create P3 |
| 375 |
this.createJavaProject( |
| 376 |
"P3", |
| 377 |
new String[]{"/"}, |
| 378 |
new String[]{}, |
| 379 |
new String[]{"/P1"}); |
| 380 |
this.createFile( |
| 381 |
"/P3/X.js", |
| 382 |
"function testZZZClass {\n"+ |
| 383 |
" var z = new ZZZ();\n"+ |
| 384 |
" z;\n" + |
| 385 |
"}"); |
| 386 |
|
| 387 |
waitUntilIndexesReady(); |
| 388 |
|
| 389 |
// do completion |
| 390 |
CompletionTestsRequestor requestor = new CompletionTestsRequestor(); |
| 391 |
IJavaScriptUnit cu= getCompilationUnit("P3", "", "", "X.js"); |
| 392 |
|
| 393 |
String str = cu.getSource(); |
| 394 |
String completeBehind = "z"; |
| 395 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 396 |
cu.codeComplete(cursorLocation, requestor); |
| 397 |
assertEquals( |
| 398 |
"element:ZZZ completion:ZZZ relevance:" +(R_DEFAULT+R_RESOLVED+R_INTERESTING+R_NON_RESTRICTED ) + "\n"+ |
| 399 |
"element:ZZZ_FUNCTION completion:ZZZ_FUNCTION() relevance:11\n" + |
| 400 |
"element:ZZZ_FUNCTION completion:ZZZ_FUNCTION() relevance:11\n" + |
| 401 |
"element:z completion:z relevance:"+ (R_DEFAULT+R_RESOLVED+R_INTERESTING+R_CASE+R_EXACT_NAME+R_UNQUALIFIED+R_NON_RESTRICTED), |
| 402 |
requestor.getResults()); |
| 403 |
|
| 404 |
|
| 405 |
// delete P1 |
| 406 |
p.getProject().delete(true, false, null); |
| 407 |
|
| 408 |
// create P1 |
| 409 |
File dest = getWorkspaceRoot().getLocation().toFile(); |
| 410 |
File pro = this.createDirectory(dest, "P1"); |
| 411 |
File proSet = this.createDirectory(pro,".settings"); |
| 412 |
|
| 413 |
this.createFile(proSet, ".jsdtscope", DEFUALT_JSDTSCOPE); |
| 414 |
// this.createFile(pro, ".classpath", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + |
| 415 |
// "<classpath>\n" + |
| 416 |
// " <classpathentry kind=\"src\" path=\"src\"/>\n" + |
| 417 |
// " <classpathentry kind=\"var\" path=\"JCL_LIB\" sourcepath=\"JCL_SRC\" rootpath=\"JCL_SRCROOT\"/>\n" + |
| 418 |
// " <classpathentry kind=\"output\" path=\"bin\"/>\n" + |
| 419 |
// "</classpath>"); |
| 420 |
this.createFile(pro, ".project", DEFAULT_PROJECT_LEFT + "org.eclipse.wst.jsdt.core" + DEFAULT_PROJECT_RIGHT); |
| 421 |
// this.createFile(pro, ".project", |
| 422 |
// "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + |
| 423 |
// "<projectDescription>\n" + |
| 424 |
// " <name>org.eclipse.wst.jsdt.core</name>\n" + |
| 425 |
// " <comment></comment>\n" + |
| 426 |
// " <projects>\n" + |
| 427 |
// " </projects>\n" + |
| 428 |
// " <buildSpec>\n" + |
| 429 |
// " <buildCommand>\n" + |
| 430 |
// " <name>org.eclipse.wst.jsdt.core.javabuilder</name>\n" + |
| 431 |
// " <arguments>\n" + |
| 432 |
// " </arguments>\n" + |
| 433 |
// " </buildCommand>\n" + |
| 434 |
// " </buildSpec>\n" + |
| 435 |
// " <natures>\n" + |
| 436 |
// " <nature>org.eclipse.wst.jsdt.core.javanature</nature>\n" + |
| 437 |
// " </natures>\n" + |
| 438 |
// "</projectDescription>"); |
| 439 |
// |
| 440 |
File src = this.createDirectory(pro, "src"); |
| 441 |
|
| 442 |
File pz = this.createDirectory(src, "pz"); |
| 443 |
|
| 444 |
this.createFile(pro,"ZZZ.js","function testZZZClass {\n"+ |
| 445 |
" var z = new ZZZ();\n"+ |
| 446 |
" z;\n" + |
| 447 |
"}"); |
| 448 |
|
| 449 |
final IProject project = getWorkspaceRoot().getProject("P1"); |
| 450 |
IWorkspaceRunnable populate = new IWorkspaceRunnable() { |
| 451 |
public void run(IProgressMonitor monitor) throws CoreException { |
| 452 |
project.create(null); |
| 453 |
project.open(null); |
| 454 |
} |
| 455 |
}; |
| 456 |
getWorkspace().run(populate, null); |
| 457 |
JavaScriptCore.create(project); |
| 458 |
|
| 459 |
waitUntilIndexesReady(); |
| 460 |
|
| 461 |
// do completion |
| 462 |
requestor = new CompletionTestsRequestor(); |
| 463 |
cu.codeComplete(cursorLocation, requestor); |
| 464 |
|
| 465 |
assertEquals( |
| 466 |
"element:z completion:z relevance:"+ (R_DEFAULT+R_INTERESTING+R_CASE+R_EXACT_NAME+R_UNQUALIFIED+R_NON_RESTRICTED) + "\n" + |
| 467 |
"element:z completion:z relevance:"+(R_DEFAULT+R_RESOLVED+R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED), |
| 468 |
requestor.getResults()); |
| 469 |
} finally { |
| 470 |
this.deleteProject("P1"); |
| 471 |
this.deleteProject("P2"); |
| 472 |
this.deleteProject("P3"); |
| 473 |
} |
| 474 |
} |
| 475 |
/* |
| 476 |
* |
| 477 |
* This tests a project which includes functions and methods marked as "not exported" from another project. This is N/A for JS. |
| 478 |
*/ |
| 479 |
|
| 480 |
//public void testBug79288() throws Exception { |
| 481 |
// try { |
| 482 |
// // create variable |
| 483 |
//// JavaScriptCore.setClasspathVariables( |
| 484 |
//// new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"}, |
| 485 |
//// new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()}, |
| 486 |
//// null); |
| 487 |
// |
| 488 |
// // create P1 |
| 489 |
// this.createJavaProject( |
| 490 |
// "P1", |
| 491 |
// new String[]{"src"}, |
| 492 |
// new String[]{"JCL_LIB"}, |
| 493 |
// "bin"); |
| 494 |
// |
| 495 |
// this.createFolder("/P1/src/a"); |
| 496 |
// this.createFile( |
| 497 |
// "/P1/src/a/XX1.js", |
| 498 |
// "package a;\n"+ |
| 499 |
// "public class XX1 {\n"+ |
| 500 |
// "}"); |
| 501 |
// |
| 502 |
// // create P2 |
| 503 |
// this.createJavaProject( |
| 504 |
// "P2", |
| 505 |
// new String[]{"src"}, |
| 506 |
// new String[]{"JCL_LIB"}, |
| 507 |
// new String[]{"/P1"}, |
| 508 |
// "bin"); |
| 509 |
// |
| 510 |
// this.createFolder("/P2/src/b"); |
| 511 |
// this.createFile( |
| 512 |
// "/P2/src/b/XX2.js", |
| 513 |
// "package b;\n"+ |
| 514 |
// "public class XX2 {\n"+ |
| 515 |
// "}"); |
| 516 |
// |
| 517 |
// // create P3 |
| 518 |
// this.createJavaProject( |
| 519 |
// "P3", |
| 520 |
// new String[]{"src"}, |
| 521 |
// new String[]{"JCL_LIB"}, |
| 522 |
// new String[]{"/P2"}, |
| 523 |
// "bin"); |
| 524 |
// |
| 525 |
// this.createFile( |
| 526 |
// "/P3/src/YY.js", |
| 527 |
// "public class YY {\n"+ |
| 528 |
// " vois foo(){\n"+ |
| 529 |
// " XX\n"+ |
| 530 |
// " }\n"+ |
| 531 |
// "}"); |
| 532 |
// |
| 533 |
// waitUntilIndexesReady(); |
| 534 |
// |
| 535 |
// // do completion |
| 536 |
// CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); |
| 537 |
// IJavaScriptUnit cu= getCompilationUnit("P3", "src", "", "YY.js"); |
| 538 |
// |
| 539 |
// String str = cu.getSource(); |
| 540 |
// String completeBehind = "XX"; |
| 541 |
// int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 542 |
// cu.codeComplete(cursorLocation, requestor); |
| 543 |
// |
| 544 |
// assertResults( |
| 545 |
// "XX2[TYPE_REF]{b.XX2, b, Lb.XX2;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", |
| 546 |
// requestor.getResults()); |
| 547 |
// } finally { |
| 548 |
// this.deleteProject("P1"); |
| 549 |
// this.deleteProject("P2"); |
| 550 |
// this.deleteProject("P3"); |
| 551 |
// } |
| 552 |
//} |
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
//public void testBug91772() throws Exception { |
| 558 |
// try { |
| 559 |
// // create variable |
| 560 |
//// JavaScriptCore.setClasspathVariables( |
| 561 |
//// new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"}, |
| 562 |
//// new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()}, |
| 563 |
//// null); |
| 564 |
// |
| 565 |
// // create P1 |
| 566 |
// this.createJavaProject( |
| 567 |
// "P1", |
| 568 |
// new String[]{"src"}, |
| 569 |
// new String[]{"JCL_LIB"}, |
| 570 |
// "bin"); |
| 571 |
// |
| 572 |
// this.createFolder("/P1/src/a"); |
| 573 |
// this.createFile( |
| 574 |
// "/P1/src/a/XX1.js", |
| 575 |
// "package a;\n"+ |
| 576 |
// "public class XX1 {\n"+ |
| 577 |
// "}"); |
| 578 |
// |
| 579 |
// // create P2 |
| 580 |
// ContainerInitializer.setInitializer(new CompletionContainerInitializer("P2", new String[] {"/P1"}, new boolean[] {true})); |
| 581 |
// String[] classLib = new String[]{"JCL_LIB"}; |
| 582 |
// int classLibLength = classLib.length; |
| 583 |
// String[] lib = new String[classLibLength + 1]; |
| 584 |
// System.arraycopy(classLib, 0, lib, 0, classLibLength); |
| 585 |
// lib[classLibLength] = "org.eclipse.wst.jsdt.core.tests.model.TEST_CONTAINER"; |
| 586 |
// this.createJavaProject( |
| 587 |
// "P2", |
| 588 |
// new String[]{"src"}, |
| 589 |
// lib, |
| 590 |
// "bin"); |
| 591 |
// |
| 592 |
// this.createFolder("/P2/src/b"); |
| 593 |
// this.createFile( |
| 594 |
// "/P2/src/b/XX2.js", |
| 595 |
// "package b;\n"+ |
| 596 |
// "public class XX2 {\n"+ |
| 597 |
// "}"); |
| 598 |
// |
| 599 |
// // create P3 |
| 600 |
// this.createJavaProject( |
| 601 |
// "P3", |
| 602 |
// new String[]{"src"}, |
| 603 |
// new String[]{"JCL_LIB"}, |
| 604 |
// new String[]{"/P2"}, |
| 605 |
// "bin"); |
| 606 |
// |
| 607 |
// this.createFile( |
| 608 |
// "/P3/src/YY.js", |
| 609 |
// "public class YY {\n"+ |
| 610 |
// " vois foo(){\n"+ |
| 611 |
// " XX\n"+ |
| 612 |
// " }\n"+ |
| 613 |
// "}"); |
| 614 |
// |
| 615 |
// waitUntilIndexesReady(); |
| 616 |
// |
| 617 |
// // do completion |
| 618 |
// CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); |
| 619 |
// IJavaScriptUnit cu= getCompilationUnit("P3", "src", "", "YY.js"); |
| 620 |
// |
| 621 |
// String str = cu.getSource(); |
| 622 |
// String completeBehind = "XX"; |
| 623 |
// int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 624 |
// cu.codeComplete(cursorLocation, requestor); |
| 625 |
// |
| 626 |
// assertResults( |
| 627 |
// "XX1[TYPE_REF]{a.XX1, a, La.XX1;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + |
| 628 |
// "XX2[TYPE_REF]{b.XX2, b, Lb.XX2;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", |
| 629 |
// requestor.getResults()); |
| 630 |
// } finally { |
| 631 |
// this.deleteProject("P1"); |
| 632 |
// this.deleteProject("P2"); |
| 633 |
// this.deleteProject("P3"); |
| 634 |
// |
| 635 |
// |
| 636 |
// // TODO the following code is not the correct way to remove the container |
| 637 |
// // Cleanup caches |
| 638 |
// JavaModelManager manager = JavaModelManager.getJavaModelManager(); |
| 639 |
// manager.containers = new HashMap(5); |
| 640 |
// manager.variables = new HashMap(5); |
| 641 |
// } |
| 642 |
//} |
| 643 |
//public void testBug93891() throws Exception { |
| 644 |
// Hashtable oldOptions = JavaScriptCore.getOptions(); |
| 645 |
// try { |
| 646 |
// Hashtable options = new Hashtable(oldOptions); |
| 647 |
// options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.ERROR); |
| 648 |
// options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.ENABLED); |
| 649 |
// options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED); |
| 650 |
// JavaScriptCore.setOptions(options); |
| 651 |
// |
| 652 |
// // create variable |
| 653 |
//// JavaScriptCore.setClasspathVariables( |
| 654 |
//// new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"}, |
| 655 |
//// new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()}, |
| 656 |
//// null); |
| 657 |
// |
| 658 |
// // create P1 |
| 659 |
// this.createJavaProject( |
| 660 |
// "P1", |
| 661 |
// new String[]{"src"}, |
| 662 |
// new String[]{"JCL_LIB"}, |
| 663 |
// "bin"); |
| 664 |
// |
| 665 |
// this.createFolder("/P1/src/a"); |
| 666 |
// this.createFile( |
| 667 |
// "/P1/src/a/XX1.js", |
| 668 |
// "package a;\n"+ |
| 669 |
// "public class XX1 {\n"+ |
| 670 |
// "}"); |
| 671 |
// |
| 672 |
// this.createFolder("/P1/src/b"); |
| 673 |
// this.createFile( |
| 674 |
// "/P1/src/b/XX2.js", |
| 675 |
// "package b;\n"+ |
| 676 |
// "public class XX2 {\n"+ |
| 677 |
// "}"); |
| 678 |
// |
| 679 |
// // create P2 |
| 680 |
// ContainerInitializer.setInitializer(new CompletionContainerInitializer("P2", new String[] {"/P1"}, new boolean[] {true}, new String[]{"a/*"})); |
| 681 |
// String[] classLib = new String[]{"JCL_LIB"}; |
| 682 |
// int classLibLength = classLib.length; |
| 683 |
// String[] lib = new String[classLibLength + 1]; |
| 684 |
// System.arraycopy(classLib, 0, lib, 0, classLibLength); |
| 685 |
// lib[classLibLength] = "org.eclipse.wst.jsdt.core.tests.model.TEST_CONTAINER"; |
| 686 |
// this.createJavaProject( |
| 687 |
// "P2", |
| 688 |
// new String[]{"src"}, |
| 689 |
// lib, |
| 690 |
// "bin"); |
| 691 |
// |
| 692 |
// this.createFolder("/P2/src/b"); |
| 693 |
// this.createFile( |
| 694 |
// "/P2/src/YY.js", |
| 695 |
// "public class YY {\n"+ |
| 696 |
// " void foo() {\n"+ |
| 697 |
// " XX\n"+ |
| 698 |
// " }\n"+ |
| 699 |
// "}"); |
| 700 |
// |
| 701 |
// waitUntilIndexesReady(); |
| 702 |
// |
| 703 |
// // do completion |
| 704 |
// CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); |
| 705 |
// IJavaScriptUnit cu= getCompilationUnit("P2", "src", "", "YY.js"); |
| 706 |
// |
| 707 |
// String str = cu.getSource(); |
| 708 |
// String completeBehind = "XX"; |
| 709 |
// int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 710 |
// cu.codeComplete(cursorLocation, requestor); |
| 711 |
// |
| 712 |
// assertResults( |
| 713 |
// "XX2[TYPE_REF]{b.XX2, b, Lb.XX2;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", |
| 714 |
// requestor.getResults()); |
| 715 |
// } finally { |
| 716 |
// this.deleteProject("P1"); |
| 717 |
// this.deleteProject("P2"); |
| 718 |
// |
| 719 |
// // TODO the following code is not the correct way to remove the container |
| 720 |
// // Cleanup caches |
| 721 |
// JavaModelManager manager = JavaModelManager.getJavaModelManager(); |
| 722 |
// manager.containers = new HashMap(5); |
| 723 |
// manager.variables = new HashMap(5); |
| 724 |
// |
| 725 |
// JavaScriptCore.setOptions(oldOptions); |
| 726 |
// } |
| 727 |
//} |
| 728 |
//public void testAccessRestriction1() throws Exception { |
| 729 |
// Hashtable oldOptions = JavaScriptCore.getOptions(); |
| 730 |
// try { |
| 731 |
// Hashtable options = new Hashtable(oldOptions); |
| 732 |
// options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.IGNORE); |
| 733 |
// options.put(JavaScriptCore.COMPILER_PB_DISCOURAGED_REFERENCE, JavaScriptCore.IGNORE); |
| 734 |
// options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.DISABLED); |
| 735 |
// options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED); |
| 736 |
// JavaScriptCore.setOptions(options); |
| 737 |
// |
| 738 |
// // create variable |
| 739 |
//// JavaScriptCore.setClasspathVariables( |
| 740 |
//// new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"}, |
| 741 |
//// new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()}, |
| 742 |
//// null); |
| 743 |
// |
| 744 |
// // create P1 |
| 745 |
// this.createJavaProject( |
| 746 |
// "P1", |
| 747 |
// new String[]{"src"}, |
| 748 |
// new String[]{"JCL_LIB"}, |
| 749 |
// "bin"); |
| 750 |
// |
| 751 |
// this.createFolder("/P1/src/a"); |
| 752 |
// this.createFile( |
| 753 |
// "/P1/src/a/XX1.js", |
| 754 |
// "package a;\n"+ |
| 755 |
// "public class XX1 {\n"+ |
| 756 |
// "}"); |
| 757 |
// |
| 758 |
// this.createFolder("/P1/src/b"); |
| 759 |
// this.createFile( |
| 760 |
// "/P1/src/b/XX2.js", |
| 761 |
// "package b;\n"+ |
| 762 |
// "public class XX2 {\n"+ |
| 763 |
// "}"); |
| 764 |
// |
| 765 |
// // create P2 |
| 766 |
// this.createJavaProject( |
| 767 |
// "P2", |
| 768 |
// new String[]{"src"}, |
| 769 |
// new String[]{"JCL_LIB"}, |
| 770 |
// new String[]{"/P1"}, |
| 771 |
// "bin"); |
| 772 |
// this.createFile( |
| 773 |
// "/P2/src/YY.js", |
| 774 |
// "public class YY {\n"+ |
| 775 |
// " void foo() {\n"+ |
| 776 |
// " XX\n"+ |
| 777 |
// " }\n"+ |
| 778 |
// "}"); |
| 779 |
// |
| 780 |
// waitUntilIndexesReady(); |
| 781 |
// |
| 782 |
// // do completion |
| 783 |
// CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); |
| 784 |
// IJavaScriptUnit cu= getCompilationUnit("P2", "src", "", "YY.js"); |
| 785 |
// |
| 786 |
// String str = cu.getSource(); |
| 787 |
// String completeBehind = "XX"; |
| 788 |
// int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 789 |
// cu.codeComplete(cursorLocation, requestor); |
| 790 |
// |
| 791 |
// assertResults( |
| 792 |
// "XX1[TYPE_REF]{a.XX1, a, La.XX1;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + |
| 793 |
// "XX2[TYPE_REF]{b.XX2, b, Lb.XX2;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", |
| 794 |
// requestor.getResults()); |
| 795 |
// } finally { |
| 796 |
// this.deleteProject("P1"); |
| 797 |
// this.deleteProject("P2"); |
| 798 |
// JavaScriptCore.setOptions(oldOptions); |
| 799 |
// } |
| 800 |
//} |
| 801 |
// |
| 802 |
//public void testAccessRestriction2() throws Exception { |
| 803 |
// Hashtable oldOptions = JavaScriptCore.getOptions(); |
| 804 |
// try { |
| 805 |
// Hashtable options = new Hashtable(oldOptions); |
| 806 |
// options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.IGNORE); |
| 807 |
// options.put(JavaScriptCore.COMPILER_PB_DISCOURAGED_REFERENCE, JavaScriptCore.IGNORE); |
| 808 |
// options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.DISABLED); |
| 809 |
// options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED); |
| 810 |
// JavaScriptCore.setOptions(options); |
| 811 |
// |
| 812 |
// // create variable |
| 813 |
//// JavaScriptCore.setClasspathVariables( |
| 814 |
//// new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"}, |
| 815 |
//// new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()}, |
| 816 |
//// null); |
| 817 |
// |
| 818 |
// // create P1 |
| 819 |
// this.createJavaProject( |
| 820 |
// "P1", |
| 821 |
// new String[]{"src"}, |
| 822 |
// new String[]{"JCL_LIB"}, |
| 823 |
// "bin"); |
| 824 |
// |
| 825 |
// this.createFolder("/P1/src/a"); |
| 826 |
// this.createFile( |
| 827 |
// "/P1/src/a/XX1.js", |
| 828 |
// "package a;\n"+ |
| 829 |
// "public class XX1 {\n"+ |
| 830 |
// "}"); |
| 831 |
// |
| 832 |
// this.createFolder("/P1/src/b"); |
| 833 |
// this.createFile( |
| 834 |
// "/P1/src/b/XX2.js", |
| 835 |
// "package b;\n"+ |
| 836 |
// "public class XX2 {\n"+ |
| 837 |
// "}"); |
| 838 |
// |
| 839 |
// // create P2 |
| 840 |
// this.createJavaProject( |
| 841 |
// "P2", |
| 842 |
// new String[]{"src"}, |
| 843 |
// new String[]{"JCL_LIB"}, |
| 844 |
// null, |
| 845 |
// null, |
| 846 |
// new String[]{"/P1"}, |
| 847 |
// new String[][]{{}}, |
| 848 |
// new String[][]{{"a/*"}}, |
| 849 |
// new boolean[]{false}, |
| 850 |
// "bin", |
| 851 |
// null, |
| 852 |
// null, |
| 853 |
// null, |
| 854 |
// "1.4"); |
| 855 |
// this.createFile( |
| 856 |
// "/P2/src/YY.js", |
| 857 |
// "public class YY {\n"+ |
| 858 |
// " void foo() {\n"+ |
| 859 |
// " XX\n"+ |
| 860 |
// " }\n"+ |
| 861 |
// "}"); |
| 862 |
// |
| 863 |
// waitUntilIndexesReady(); |
| 864 |
// |
| 865 |
// // do completion |
| 866 |
// CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); |
| 867 |
// IJavaScriptUnit cu= getCompilationUnit("P2", "src", "", "YY.js"); |
| 868 |
// |
| 869 |
// String str = cu.getSource(); |
| 870 |
// String completeBehind = "XX"; |
| 871 |
// int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 872 |
// cu.codeComplete(cursorLocation, requestor); |
| 873 |
// |
| 874 |
// assertResults( |
| 875 |
// "XX1[TYPE_REF]{a.XX1, a, La.XX1;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + |
| 876 |
// "XX2[TYPE_REF]{b.XX2, b, Lb.XX2;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", |
| 877 |
// requestor.getResults()); |
| 878 |
// } finally { |
| 879 |
// this.deleteProject("P1"); |
| 880 |
// this.deleteProject("P2"); |
| 881 |
// JavaScriptCore.setOptions(oldOptions); |
| 882 |
// } |
| 883 |
//} |
| 884 |
//public void testAccessRestriction3() throws Exception { |
| 885 |
// Hashtable oldOptions = JavaScriptCore.getOptions(); |
| 886 |
// try { |
| 887 |
// Hashtable options = new Hashtable(oldOptions); |
| 888 |
// options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.ERROR); |
| 889 |
// options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.DISABLED); |
| 890 |
// options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED); |
| 891 |
// JavaScriptCore.setOptions(options); |
| 892 |
// |
| 893 |
// // create variable |
| 894 |
//// JavaScriptCore.setClasspathVariables( |
| 895 |
//// new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"}, |
| 896 |
//// new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()}, |
| 897 |
//// null); |
| 898 |
// |
| 899 |
// // create P1 |
| 900 |
// this.createJavaProject( |
| 901 |
// "P1", |
| 902 |
// new String[]{"src"}, |
| 903 |
// new String[]{"JCL_LIB"}, |
| 904 |
// "bin"); |
| 905 |
// |
| 906 |
// this.createFolder("/P1/src/a"); |
| 907 |
// this.createFile( |
| 908 |
// "/P1/src/a/XX1.js", |
| 909 |
// "package a;\n"+ |
| 910 |
// "public class XX1 {\n"+ |
| 911 |
// "}"); |
| 912 |
// |
| 913 |
// this.createFolder("/P1/src/b"); |
| 914 |
// this.createFile( |
| 915 |
// "/P1/src/b/XX2.js", |
| 916 |
// "package b;\n"+ |
| 917 |
// "public class XX2 {\n"+ |
| 918 |
// "}"); |
| 919 |
// |
| 920 |
// // create P2 |
| 921 |
// this.createJavaProject( |
| 922 |
// "P2", |
| 923 |
// new String[]{"src"}, |
| 924 |
// new String[]{"JCL_LIB"}, |
| 925 |
// null, |
| 926 |
// null, |
| 927 |
// new String[]{"/P1"}, |
| 928 |
// new String[][]{{}}, |
| 929 |
// new String[][]{{"a/*"}}, |
| 930 |
// new boolean[]{false}, |
| 931 |
// "bin", |
| 932 |
// null, |
| 933 |
// null, |
| 934 |
// null, |
| 935 |
// "1.4"); |
| 936 |
// this.createFile( |
| 937 |
// "/P2/src/YY.js", |
| 938 |
// "public class YY {\n"+ |
| 939 |
// " void foo() {\n"+ |
| 940 |
// " XX\n"+ |
| 941 |
// " }\n"+ |
| 942 |
// "}"); |
| 943 |
// |
| 944 |
// waitUntilIndexesReady(); |
| 945 |
// |
| 946 |
// // do completion |
| 947 |
// CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); |
| 948 |
// IJavaScriptUnit cu= getCompilationUnit("P2", "src", "", "YY.js"); |
| 949 |
// |
| 950 |
// String str = cu.getSource(); |
| 951 |
// String completeBehind = "XX"; |
| 952 |
// int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 953 |
// cu.codeComplete(cursorLocation, requestor); |
| 954 |
// |
| 955 |
// assertResults( |
| 956 |
// "XX1[TYPE_REF]{a.XX1, a, La.XX1;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE) + "}\n" + |
| 957 |
// "XX2[TYPE_REF]{b.XX2, b, Lb.XX2;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", |
| 958 |
// requestor.getResults()); |
| 959 |
// } finally { |
| 960 |
// this.deleteProject("P1"); |
| 961 |
// this.deleteProject("P2"); |
| 962 |
// JavaScriptCore.setOptions(oldOptions); |
| 963 |
// } |
| 964 |
//} |
| 965 |
//public void testAccessRestriction4() throws Exception { |
| 966 |
// Hashtable oldOptions = JavaScriptCore.getOptions(); |
| 967 |
// try { |
| 968 |
// Hashtable options = new Hashtable(oldOptions); |
| 969 |
// options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.IGNORE); |
| 970 |
// options.put(JavaScriptCore.COMPILER_PB_DISCOURAGED_REFERENCE, JavaScriptCore.IGNORE); |
| 971 |
// options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.ENABLED); |
| 972 |
// options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED); |
| 973 |
// JavaScriptCore.setOptions(options); |
| 974 |
// |
| 975 |
// // create variable |
| 976 |
//// JavaScriptCore.setClasspathVariables( |
| 977 |
//// new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"}, |
| 978 |
//// new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()}, |
| 979 |
//// null); |
| 980 |
// |
| 981 |
// // create P1 |
| 982 |
// this.createJavaProject( |
| 983 |
// "P1", |
| 984 |
// new String[]{"src"}, |
| 985 |
// new String[]{"JCL_LIB"}, |
| 986 |
// "bin"); |
| 987 |
// |
| 988 |
// this.createFolder("/P1/src/a"); |
| 989 |
// this.createFile( |
| 990 |
// "/P1/src/a/XX1.js", |
| 991 |
// "package a;\n"+ |
| 992 |
// "public class XX1 {\n"+ |
| 993 |
// "}"); |
| 994 |
// |
| 995 |
// this.createFolder("/P1/src/b"); |
| 996 |
// this.createFile( |
| 997 |
// "/P1/src/b/XX2.js", |
| 998 |
// "package b;\n"+ |
| 999 |
// "public class XX2 {\n"+ |
| 1000 |
// "}"); |
| 1001 |
// |
| 1002 |
// // create P2 |
| 1003 |
// this.createJavaProject( |
| 1004 |
// "P2", |
| 1005 |
// new String[]{"src"}, |
| 1006 |
// new String[]{"JCL_LIB"}, |
| 1007 |
// null, |
| 1008 |
// null, |
| 1009 |
// new String[]{"/P1"}, |
| 1010 |
// new String[][]{{}}, |
| 1011 |
// new String[][]{{"a/*"}}, |
| 1012 |
// new boolean[]{false}, |
| 1013 |
// "bin", |
| 1014 |
// null, |
| 1015 |
// null, |
| 1016 |
// null, |
| 1017 |
// "1.4"); |
| 1018 |
// this.createFile( |
| 1019 |
// "/P2/src/YY.js", |
| 1020 |
// "public class YY {\n"+ |
| 1021 |
// " void foo() {\n"+ |
| 1022 |
// " XX\n"+ |
| 1023 |
// " }\n"+ |
| 1024 |
// "}"); |
| 1025 |
// |
| 1026 |
// waitUntilIndexesReady(); |
| 1027 |
// |
| 1028 |
// // do completion |
| 1029 |
// CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); |
| 1030 |
// IJavaScriptUnit cu= getCompilationUnit("P2", "src", "", "YY.js"); |
| 1031 |
// |
| 1032 |
// String str = cu.getSource(); |
| 1033 |
// String completeBehind = "XX"; |
| 1034 |
// int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 1035 |
// cu.codeComplete(cursorLocation, requestor); |
| 1036 |
// |
| 1037 |
// assertResults( |
| 1038 |
// "XX1[TYPE_REF]{a.XX1, a, La.XX1;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + |
| 1039 |
// "XX2[TYPE_REF]{b.XX2, b, Lb.XX2;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", |
| 1040 |
// requestor.getResults()); |
| 1041 |
// } finally { |
| 1042 |
// this.deleteProject("P1"); |
| 1043 |
// this.deleteProject("P2"); |
| 1044 |
// JavaScriptCore.setOptions(oldOptions); |
| 1045 |
// } |
| 1046 |
//} |
| 1047 |
//public void testAccessRestriction5() throws Exception { |
| 1048 |
// Hashtable oldOptions = JavaScriptCore.getOptions(); |
| 1049 |
// try { |
| 1050 |
// Hashtable options = new Hashtable(oldOptions); |
| 1051 |
// options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.ERROR); |
| 1052 |
// options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.ENABLED); |
| 1053 |
// options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED); |
| 1054 |
// JavaScriptCore.setOptions(options); |
| 1055 |
// |
| 1056 |
// // create variable |
| 1057 |
//// JavaScriptCore.setClasspathVariables( |
| 1058 |
//// new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"}, |
| 1059 |
//// new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()}, |
| 1060 |
//// null); |
| 1061 |
// |
| 1062 |
// // create P1 |
| 1063 |
// this.createJavaProject( |
| 1064 |
// "P1", |
| 1065 |
// new String[]{"src"}, |
| 1066 |
// new String[]{"JCL_LIB"}, |
| 1067 |
// "bin"); |
| 1068 |
// |
| 1069 |
// this.createFolder("/P1/src/a"); |
| 1070 |
// this.createFile( |
| 1071 |
// "/P1/src/a/XX1.js", |
| 1072 |
// "package a;\n"+ |
| 1073 |
// "public class XX1 {\n"+ |
| 1074 |
// "}"); |
| 1075 |
// |
| 1076 |
// this.createFolder("/P1/src/b"); |
| 1077 |
// this.createFile( |
| 1078 |
// "/P1/src/b/XX2.js", |
| 1079 |
// "package b;\n"+ |
| 1080 |
// "public class XX2 {\n"+ |
| 1081 |
// "}"); |
| 1082 |
// |
| 1083 |
// // create P2 |
| 1084 |
// this.createJavaProject( |
| 1085 |
// "P2", |
| 1086 |
// new String[]{"src"}, |
| 1087 |
// new String[]{"JCL_LIB"}, |
| 1088 |
// null, |
| 1089 |
// null, |
| 1090 |
// new String[]{"/P1"}, |
| 1091 |
// new String[][]{{}}, |
| 1092 |
// new String[][]{{"a/*"}}, |
| 1093 |
// new boolean[]{false}, |
| 1094 |
// "bin", |
| 1095 |
// null, |
| 1096 |
// null, |
| 1097 |
// null, |
| 1098 |
// "1.4"); |
| 1099 |
// this.createFile( |
| 1100 |
// "/P2/src/YY.js", |
| 1101 |
// "public class YY {\n"+ |
| 1102 |
// " void foo() {\n"+ |
| 1103 |
// " XX\n"+ |
| 1104 |
// " }\n"+ |
| 1105 |
// "}"); |
| 1106 |
// |
| 1107 |
// waitUntilIndexesReady(); |
| 1108 |
// |
| 1109 |
// // do completion |
| 1110 |
// CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); |
| 1111 |
// IJavaScriptUnit cu= getCompilationUnit("P2", "src", "", "YY.js"); |
| 1112 |
// |
| 1113 |
// String str = cu.getSource(); |
| 1114 |
// String completeBehind = "XX"; |
| 1115 |
// int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 1116 |
// cu.codeComplete(cursorLocation, requestor); |
| 1117 |
// |
| 1118 |
// assertResults( |
| 1119 |
// "XX2[TYPE_REF]{b.XX2, b, Lb.XX2;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", |
| 1120 |
// requestor.getResults()); |
| 1121 |
// } finally { |
| 1122 |
// this.deleteProject("P1"); |
| 1123 |
// this.deleteProject("P2"); |
| 1124 |
// JavaScriptCore.setOptions(oldOptions); |
| 1125 |
// } |
| 1126 |
//} |
| 1127 |
//public void testAccessRestriction6() throws Exception { |
| 1128 |
// Hashtable oldOptions = JavaScriptCore.getOptions(); |
| 1129 |
// try { |
| 1130 |
// Hashtable options = new Hashtable(oldOptions); |
| 1131 |
// options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.ERROR); |
| 1132 |
// options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.ENABLED); |
| 1133 |
// options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED); |
| 1134 |
// JavaScriptCore.setOptions(options); |
| 1135 |
// |
| 1136 |
// // create variable |
| 1137 |
//// JavaScriptCore.setClasspathVariables( |
| 1138 |
//// new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"}, |
| 1139 |
//// new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()}, |
| 1140 |
//// null); |
| 1141 |
// |
| 1142 |
// // create P1 |
| 1143 |
// this.createJavaProject( |
| 1144 |
// "P1", |
| 1145 |
// new String[]{"src"}, |
| 1146 |
// new String[]{"JCL_LIB"}, |
| 1147 |
// "bin"); |
| 1148 |
// |
| 1149 |
// this.createFolder("/P1/src/a"); |
| 1150 |
// this.createFile( |
| 1151 |
// "/P1/src/a/XX1.js", |
| 1152 |
// "package a;\n"+ |
| 1153 |
// "public class XX1 {\n"+ |
| 1154 |
// "}"); |
| 1155 |
// |
| 1156 |
// this.createFolder("/P1/src/b"); |
| 1157 |
// this.createFile( |
| 1158 |
// "/P1/src/b/XX2.js", |
| 1159 |
// "package b;\n"+ |
| 1160 |
// "public class XX2 {\n"+ |
| 1161 |
// "}"); |
| 1162 |
// |
| 1163 |
// this.createFolder("/P1/src/c"); |
| 1164 |
// this.createFile( |
| 1165 |
// "/P1/src/c/XX3.js", |
| 1166 |
// "package c;\n"+ |
| 1167 |
// "public class XX3 {\n"+ |
| 1168 |
// "}"); |
| 1169 |
// |
| 1170 |
// // create P2 |
| 1171 |
// this.createJavaProject( |
| 1172 |
// "P2", |
| 1173 |
// new String[]{"src"}, |
| 1174 |
// new String[]{"JCL_LIB"}, |
| 1175 |
// null, |
| 1176 |
// null, |
| 1177 |
// new String[]{"/P1"}, |
| 1178 |
// new String[][]{{}}, |
| 1179 |
// new String[][]{{"a/*"}}, |
| 1180 |
// new boolean[]{true}, |
| 1181 |
// "bin", |
| 1182 |
// null, |
| 1183 |
// null, |
| 1184 |
// null, |
| 1185 |
// "1.4"); |
| 1186 |
// |
| 1187 |
// // create P3 |
| 1188 |
// this.createJavaProject( |
| 1189 |
// "P3", |
| 1190 |
// new String[]{"src"}, |
| 1191 |
// new String[]{"JCL_LIB"}, |
| 1192 |
// null, |
| 1193 |
// null, |
| 1194 |
// new String[]{"/P2"}, |
| 1195 |
// new String[][]{{}}, |
| 1196 |
// new String[][]{{"b/*"}}, |
| 1197 |
// new boolean[]{false}, |
| 1198 |
// "bin", |
| 1199 |
// null, |
| 1200 |
// null, |
| 1201 |
// null, |
| 1202 |
// "1.4"); |
| 1203 |
// |
| 1204 |
// this.createFile( |
| 1205 |
// "/P3/src/YY.js", |
| 1206 |
// "public class YY {\n"+ |
| 1207 |
// " void foo() {\n"+ |
| 1208 |
// " XX\n"+ |
| 1209 |
// " }\n"+ |
| 1210 |
// "}"); |
| 1211 |
// |
| 1212 |
// waitUntilIndexesReady(); |
| 1213 |
// |
| 1214 |
// // do completion |
| 1215 |
// CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); |
| 1216 |
// IJavaScriptUnit cu= getCompilationUnit("P3", "src", "", "YY.js"); |
| 1217 |
// |
| 1218 |
// String str = cu.getSource(); |
| 1219 |
// String completeBehind = "XX"; |
| 1220 |
// int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 1221 |
// cu.codeComplete(cursorLocation, requestor); |
| 1222 |
// |
| 1223 |
// assertResults( |
| 1224 |
// "XX3[TYPE_REF]{c.XX3, c, Lc.XX3;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", |
| 1225 |
// requestor.getResults()); |
| 1226 |
// } finally { |
| 1227 |
// this.deleteProject("P1"); |
| 1228 |
// this.deleteProject("P2"); |
| 1229 |
// this.deleteProject("P3"); |
| 1230 |
// JavaScriptCore.setOptions(oldOptions); |
| 1231 |
// } |
| 1232 |
//} |
| 1233 |
//public void testAccessRestriction7() throws Exception { |
| 1234 |
// Hashtable oldOptions = JavaScriptCore.getOptions(); |
| 1235 |
// try { |
| 1236 |
// Hashtable options = new Hashtable(oldOptions); |
| 1237 |
// options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.ERROR); |
| 1238 |
// options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.ENABLED); |
| 1239 |
// options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED); |
| 1240 |
// JavaScriptCore.setOptions(options); |
| 1241 |
// |
| 1242 |
// // create variable |
| 1243 |
//// JavaScriptCore.setClasspathVariables( |
| 1244 |
//// new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"}, |
| 1245 |
//// new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()}, |
| 1246 |
//// null); |
| 1247 |
// |
| 1248 |
// // create P1 |
| 1249 |
// this.createJavaProject( |
| 1250 |
// "P1", |
| 1251 |
// new String[]{"src"}, |
| 1252 |
// new String[]{"JCL_LIB"}, |
| 1253 |
// "bin"); |
| 1254 |
// |
| 1255 |
// this.createFolder("/P1/src/a"); |
| 1256 |
// this.createFile( |
| 1257 |
// "/P1/src/a/XX1.js", |
| 1258 |
// "package a;\n"+ |
| 1259 |
// "public class XX1 {\n"+ |
| 1260 |
// "}"); |
| 1261 |
// |
| 1262 |
// this.createFolder("/P1/src/b"); |
| 1263 |
// this.createFile( |
| 1264 |
// "/P1/src/b/XX2.js", |
| 1265 |
// "package b;\n"+ |
| 1266 |
// "public class XX2 {\n"+ |
| 1267 |
// "}"); |
| 1268 |
// |
| 1269 |
// // create P2 |
| 1270 |
// this.createJavaProject( |
| 1271 |
// "P2", |
| 1272 |
// new String[]{"src"}, |
| 1273 |
// new String[]{"JCL_LIB"}, |
| 1274 |
// null, |
| 1275 |
// null, |
| 1276 |
// new String[]{"/P1", "/P3"}, |
| 1277 |
// new String[][]{{}, {}}, |
| 1278 |
// new String[][]{{"a/*"}, {}}, |
| 1279 |
// new boolean[]{false, false}, |
| 1280 |
// "bin", |
| 1281 |
// null, |
| 1282 |
// null, |
| 1283 |
// null, |
| 1284 |
// "1.4"); |
| 1285 |
// this.createFile( |
| 1286 |
// "/P2/src/YY.js", |
| 1287 |
// "public class YY {\n"+ |
| 1288 |
// " void foo() {\n"+ |
| 1289 |
// " XX\n"+ |
| 1290 |
// " }\n"+ |
| 1291 |
// "}"); |
| 1292 |
// |
| 1293 |
// // create P3 |
| 1294 |
// this.createJavaProject( |
| 1295 |
// "P3", |
| 1296 |
// new String[]{"src"}, |
| 1297 |
// new String[]{"JCL_LIB"}, |
| 1298 |
// null, |
| 1299 |
// null, |
| 1300 |
// new String[]{"/P1"}, |
| 1301 |
// new String[][]{{}}, |
| 1302 |
// new String[][]{{}}, |
| 1303 |
// new boolean[]{true}, |
| 1304 |
// "bin", |
| 1305 |
// null, |
| 1306 |
// null, |
| 1307 |
// null, |
| 1308 |
// "1.4"); |
| 1309 |
// |
| 1310 |
// waitUntilIndexesReady(); |
| 1311 |
// |
| 1312 |
// // do completion |
| 1313 |
// CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); |
| 1314 |
// IJavaScriptUnit cu= getCompilationUnit("P2", "src", "", "YY.js"); |
| 1315 |
// |
| 1316 |
// String str = cu.getSource(); |
| 1317 |
// String completeBehind = "XX"; |
| 1318 |
// int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 1319 |
// cu.codeComplete(cursorLocation, requestor); |
| 1320 |
// |
| 1321 |
// assertResults( |
| 1322 |
// "XX2[TYPE_REF]{b.XX2, b, Lb.XX2;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", |
| 1323 |
// requestor.getResults()); |
| 1324 |
// } finally { |
| 1325 |
// this.deleteProject("P1"); |
| 1326 |
// this.deleteProject("P2"); |
| 1327 |
// this.deleteProject("P3"); |
| 1328 |
// JavaScriptCore.setOptions(oldOptions); |
| 1329 |
// } |
| 1330 |
//} |
| 1331 |
//public void testAccessRestriction8() throws Exception { |
| 1332 |
// Hashtable oldOptions = JavaScriptCore.getOptions(); |
| 1333 |
// try { |
| 1334 |
// Hashtable options = new Hashtable(oldOptions); |
| 1335 |
// options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.ERROR); |
| 1336 |
// options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.ENABLED); |
| 1337 |
// options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED); |
| 1338 |
// JavaScriptCore.setOptions(options); |
| 1339 |
// |
| 1340 |
// // create variable |
| 1341 |
//// JavaScriptCore.setClasspathVariables( |
| 1342 |
//// new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"}, |
| 1343 |
//// new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()}, |
| 1344 |
//// null); |
| 1345 |
// |
| 1346 |
// // create P1 |
| 1347 |
// this.createJavaProject( |
| 1348 |
// "P1", |
| 1349 |
// new String[]{"src"}, |
| 1350 |
// new String[]{"JCL_LIB"}, |
| 1351 |
// "bin"); |
| 1352 |
// |
| 1353 |
// this.createFolder("/P1/src/a"); |
| 1354 |
// this.createFile( |
| 1355 |
// "/P1/src/a/XX1.js", |
| 1356 |
// "package a;\n"+ |
| 1357 |
// "public class XX1 {\n"+ |
| 1358 |
// "}"); |
| 1359 |
// |
| 1360 |
// this.createFolder("/P1/src/b"); |
| 1361 |
// this.createFile( |
| 1362 |
// "/P1/src/b/XX2.js", |
| 1363 |
// "package b;\n"+ |
| 1364 |
// "public class XX2 {\n"+ |
| 1365 |
// "}"); |
| 1366 |
// |
| 1367 |
// // create P2 |
| 1368 |
// this.createJavaProject( |
| 1369 |
// "P2", |
| 1370 |
// new String[]{"src"}, |
| 1371 |
// new String[]{"JCL_LIB"}, |
| 1372 |
// null, |
| 1373 |
// null, |
| 1374 |
// new String[]{"/P3", "/P1"}, |
| 1375 |
// new String[][]{{}, {}}, |
| 1376 |
// new String[][]{{}, {"a/*"}}, |
| 1377 |
// new boolean[]{false, false}, |
| 1378 |
// "bin", |
| 1379 |
// null, |
| 1380 |
// null, |
| 1381 |
// null, |
| 1382 |
// "1.4"); |
| 1383 |
// this.createFile( |
| 1384 |
// "/P2/src/YY.js", |
| 1385 |
// "public class YY {\n"+ |
| 1386 |
// " void foo() {\n"+ |
| 1387 |
// " XX\n"+ |
| 1388 |
// " }\n"+ |
| 1389 |
// "}"); |
| 1390 |
// |
| 1391 |
// // create P3 |
| 1392 |
// this.createJavaProject( |
| 1393 |
// "P3", |
| 1394 |
// new String[]{"src"}, |
| 1395 |
// new String[]{"JCL_LIB"}, |
| 1396 |
// null, |
| 1397 |
// null, |
| 1398 |
// new String[]{"/P1"}, |
| 1399 |
// new String[][]{{}}, |
| 1400 |
// new String[][]{{}}, |
| 1401 |
// new boolean[]{true}, |
| 1402 |
// "bin", |
| 1403 |
// null, |
| 1404 |
// null, |
| 1405 |
// null, |
| 1406 |
// "1.4"); |
| 1407 |
// |
| 1408 |
// waitUntilIndexesReady(); |
| 1409 |
// |
| 1410 |
// // do completion |
| 1411 |
// CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); |
| 1412 |
// IJavaScriptUnit cu= getCompilationUnit("P2", "src", "", "YY.js"); |
| 1413 |
// |
| 1414 |
// String str = cu.getSource(); |
| 1415 |
// String completeBehind = "XX"; |
| 1416 |
// int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 1417 |
// cu.codeComplete(cursorLocation, requestor); |
| 1418 |
// |
| 1419 |
// assertResults( |
| 1420 |
// "XX1[TYPE_REF]{a.XX1, a, La.XX1;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + |
| 1421 |
// "XX2[TYPE_REF]{b.XX2, b, Lb.XX2;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", |
| 1422 |
// requestor.getResults()); |
| 1423 |
// } finally { |
| 1424 |
// this.deleteProject("P1"); |
| 1425 |
// this.deleteProject("P2"); |
| 1426 |
// this.deleteProject("P3"); |
| 1427 |
// JavaScriptCore.setOptions(oldOptions); |
| 1428 |
// } |
| 1429 |
//} |
| 1430 |
//public void testAccessRestriction9() throws Exception { |
| 1431 |
// Hashtable oldOptions = JavaScriptCore.getOptions(); |
| 1432 |
// try { |
| 1433 |
// Hashtable options = new Hashtable(oldOptions); |
| 1434 |
// options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.ERROR); |
| 1435 |
// options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.ENABLED); |
| 1436 |
// options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED); |
| 1437 |
// JavaScriptCore.setOptions(options); |
| 1438 |
// |
| 1439 |
// // create variable |
| 1440 |
//// JavaScriptCore.setClasspathVariables( |
| 1441 |
//// new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"}, |
| 1442 |
//// new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()}, |
| 1443 |
//// null); |
| 1444 |
// |
| 1445 |
// // create P1 |
| 1446 |
// this.createJavaProject( |
| 1447 |
// "P1", |
| 1448 |
// new String[]{"src"}, |
| 1449 |
// new String[]{"JCL_LIB"}, |
| 1450 |
// "bin"); |
| 1451 |
// |
| 1452 |
// this.createFolder("/P1/src/p11"); |
| 1453 |
// this.createFile( |
| 1454 |
// "/P1/src/p11/XX11.js", |
| 1455 |
// "package p11;\n"+ |
| 1456 |
// "public class XX11 {\n"+ |
| 1457 |
// "}"); |
| 1458 |
// |
| 1459 |
// this.createFolder("/P1/src/p12"); |
| 1460 |
// this.createFile( |
| 1461 |
// "/P1/src/p12/XX12.js", |
| 1462 |
// "package p12;\n"+ |
| 1463 |
// "public class XX12 {\n"+ |
| 1464 |
// "}"); |
| 1465 |
// |
| 1466 |
// // create P2 |
| 1467 |
// this.createJavaProject( |
| 1468 |
// "P2", |
| 1469 |
// new String[]{"src"}, |
| 1470 |
// new String[]{"JCL_LIB"}, |
| 1471 |
// null, |
| 1472 |
// null, |
| 1473 |
// new String[]{"/P1", "/P3"}, |
| 1474 |
// new String[][]{{}, {}}, |
| 1475 |
// new String[][]{{"p11/*"}, {"p31/*"}}, |
| 1476 |
// new boolean[]{true, true}, |
| 1477 |
// "bin", |
| 1478 |
// null, |
| 1479 |
// null, |
| 1480 |
// null, |
| 1481 |
// "1.4"); |
| 1482 |
// |
| 1483 |
// this.createFolder("/P2/src/p21"); |
| 1484 |
// this.createFile( |
| 1485 |
// "/P2/src/p21/XX21.js", |
| 1486 |
// "package p21;\n"+ |
| 1487 |
// "public class XX21 {\n"+ |
| 1488 |
// "}"); |
| 1489 |
// |
| 1490 |
// this.createFolder("/P2/src/p22"); |
| 1491 |
// this.createFile( |
| 1492 |
// "/P2/src/p22/XX22.js", |
| 1493 |
// "package p22;\n"+ |
| 1494 |
// "public class XX22 {\n"+ |
| 1495 |
// "}"); |
| 1496 |
// |
| 1497 |
// // create P3 |
| 1498 |
// this.createJavaProject( |
| 1499 |
// "P3", |
| 1500 |
// new String[]{"src"}, |
| 1501 |
// new String[]{"JCL_LIB"}, |
| 1502 |
// null, |
| 1503 |
// null, |
| 1504 |
// new String[]{"/P1"}, |
| 1505 |
// new String[][]{{}}, |
| 1506 |
// new String[][]{{"p12/*"}}, |
| 1507 |
// new boolean[]{true}, |
| 1508 |
// "bin", |
| 1509 |
// null, |
| 1510 |
// null, |
| 1511 |
// null, |
| 1512 |
// "1.4"); |
| 1513 |
// |
| 1514 |
// this.createFolder("/P3/src/p31"); |
| 1515 |
// this.createFile( |
| 1516 |
// "/P3/src/p31/XX31.js", |
| 1517 |
// "package p31;\n"+ |
| 1518 |
// "public class XX31 {\n"+ |
| 1519 |
// "}"); |
| 1520 |
// |
| 1521 |
// this.createFolder("/P3/src/p32"); |
| 1522 |
// this.createFile( |
| 1523 |
// "/P3/src/p32/XX32.js", |
| 1524 |
// "package p32;\n"+ |
| 1525 |
// "public class XX32 {\n"+ |
| 1526 |
// "}"); |
| 1527 |
// |
| 1528 |
// // create PX |
| 1529 |
// this.createJavaProject( |
| 1530 |
// "PX", |
| 1531 |
// new String[]{"src"}, |
| 1532 |
// new String[]{"JCL_LIB"}, |
| 1533 |
// null, |
| 1534 |
// null, |
| 1535 |
// new String[]{"/P2"}, |
| 1536 |
// null, |
| 1537 |
// null, |
| 1538 |
// new boolean[]{false}, |
| 1539 |
// "bin", |
| 1540 |
// null, |
| 1541 |
// null, |
| 1542 |
// null, |
| 1543 |
// "1.4"); |
| 1544 |
// |
| 1545 |
// this.createFile( |
| 1546 |
// "/PX/src/X.js", |
| 1547 |
// "public class X {\n"+ |
| 1548 |
// " void foo() {\n"+ |
| 1549 |
// " XX\n"+ |
| 1550 |
// " }\n"+ |
| 1551 |
// "}"); |
| 1552 |
// |
| 1553 |
// waitUntilIndexesReady(); |
| 1554 |
// |
| 1555 |
// // do completion |
| 1556 |
// CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); |
| 1557 |
// IJavaScriptUnit cu= getCompilationUnit("PX", "src", "", "X.js"); |
| 1558 |
// |
| 1559 |
// String str = cu.getSource(); |
| 1560 |
// String completeBehind = "XX"; |
| 1561 |
// int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 1562 |
// cu.codeComplete(cursorLocation, requestor); |
| 1563 |
// |
| 1564 |
// assertResults( |
| 1565 |
// "XX12[TYPE_REF]{p12.XX12, p12, Lp12.XX12;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + |
| 1566 |
// "XX21[TYPE_REF]{p21.XX21, p21, Lp21.XX21;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + |
| 1567 |
// "XX22[TYPE_REF]{p22.XX22, p22, Lp22.XX22;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + |
| 1568 |
// "XX32[TYPE_REF]{p32.XX32, p32, Lp32.XX32;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", |
| 1569 |
// requestor.getResults()); |
| 1570 |
// } finally { |
| 1571 |
// this.deleteProject("P1"); |
| 1572 |
// this.deleteProject("P2"); |
| 1573 |
// this.deleteProject("P3"); |
| 1574 |
// this.deleteProject("PX"); |
| 1575 |
// JavaScriptCore.setOptions(oldOptions); |
| 1576 |
// } |
| 1577 |
//} |
| 1578 |
//public void testAccessRestriction10() throws Exception { |
| 1579 |
// Hashtable oldOptions = JavaScriptCore.getOptions(); |
| 1580 |
// try { |
| 1581 |
// Hashtable options = new Hashtable(oldOptions); |
| 1582 |
// options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.ERROR); |
| 1583 |
// options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.DISABLED); |
| 1584 |
// options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED); |
| 1585 |
// JavaScriptCore.setOptions(options); |
| 1586 |
// |
| 1587 |
// // create variable |
| 1588 |
//// JavaScriptCore.setClasspathVariables( |
| 1589 |
//// new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"}, |
| 1590 |
//// new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()}, |
| 1591 |
//// null); |
| 1592 |
// |
| 1593 |
// // create P1 |
| 1594 |
// this.createJavaProject( |
| 1595 |
// "P1", |
| 1596 |
// new String[]{"src"}, |
| 1597 |
// new String[]{"JCL_LIB"}, |
| 1598 |
// "bin"); |
| 1599 |
// |
| 1600 |
// this.createFolder("/P1/src/p11"); |
| 1601 |
// this.createFile( |
| 1602 |
// "/P1/src/p11/XX11.js", |
| 1603 |
// "package p11;\n"+ |
| 1604 |
// "public class XX11 {\n"+ |
| 1605 |
// "}"); |
| 1606 |
// |
| 1607 |
// this.createFolder("/P1/src/p12"); |
| 1608 |
// this.createFile( |
| 1609 |
// "/P1/src/p12/XX12.js", |
| 1610 |
// "package p12;\n"+ |
| 1611 |
// "public class XX12 {\n"+ |
| 1612 |
// "}"); |
| 1613 |
// |
| 1614 |
// // create P2 |
| 1615 |
// this.createJavaProject( |
| 1616 |
// "P2", |
| 1617 |
// new String[]{"src"}, |
| 1618 |
// new String[]{"JCL_LIB"}, |
| 1619 |
// null, |
| 1620 |
// null, |
| 1621 |
// new String[]{"/P1", "/P3"}, |
| 1622 |
// new String[][]{{}, {}}, |
| 1623 |
// new String[][]{{"p11/*"}, {"p31/*"}}, |
| 1624 |
// new boolean[]{true, true}, |
| 1625 |
// "bin", |
| 1626 |
// null, |
| 1627 |
// null, |
| 1628 |
// null, |
| 1629 |
// "1.4"); |
| 1630 |
// |
| 1631 |
// this.createFolder("/P2/src/p21"); |
| 1632 |
// this.createFile( |
| 1633 |
// "/P2/src/p21/XX21.js", |
| 1634 |
// "package p21;\n"+ |
| 1635 |
// "public class XX21 {\n"+ |
| 1636 |
// "}"); |
| 1637 |
// |
| 1638 |
// this.createFolder("/P2/src/p22"); |
| 1639 |
// this.createFile( |
| 1640 |
// "/P2/src/p22/XX22.js", |
| 1641 |
// "package p22;\n"+ |
| 1642 |
// "public class XX22 {\n"+ |
| 1643 |
// "}"); |
| 1644 |
// |
| 1645 |
// // create P3 |
| 1646 |
// this.createJavaProject( |
| 1647 |
// "P3", |
| 1648 |
// new String[]{"src"}, |
| 1649 |
// new String[]{"JCL_LIB"}, |
| 1650 |
// null, |
| 1651 |
// null, |
| 1652 |
// new String[]{"/P1"}, |
| 1653 |
// new String[][]{{}}, |
| 1654 |
// new String[][]{{"p12/*"}}, |
| 1655 |
// new boolean[]{true}, |
| 1656 |
// "bin", |
| 1657 |
// null, |
| 1658 |
// null, |
| 1659 |
// null, |
| 1660 |
// "1.4"); |
| 1661 |
// |
| 1662 |
// this.createFolder("/P3/src/p31"); |
| 1663 |
// this.createFile( |
| 1664 |
// "/P3/src/p31/XX31.js", |
| 1665 |
// "package p31;\n"+ |
| 1666 |
// "public class XX31 {\n"+ |
| 1667 |
// "}"); |
| 1668 |
// |
| 1669 |
// this.createFolder("/P3/src/p32"); |
| 1670 |
// this.createFile( |
| 1671 |
// "/P3/src/p32/XX32.js", |
| 1672 |
// "package p32;\n"+ |
| 1673 |
// "public class XX32 {\n"+ |
| 1674 |
// "}"); |
| 1675 |
// |
| 1676 |
// // create PX |
| 1677 |
// this.createJavaProject( |
| 1678 |
// "PX", |
| 1679 |
// new String[]{"src"}, |
| 1680 |
// new String[]{"JCL_LIB"}, |
| 1681 |
// null, |
| 1682 |
// null, |
| 1683 |
// new String[]{"/P2"}, |
| 1684 |
// null, |
| 1685 |
// null, |
| 1686 |
// new boolean[]{false}, |
| 1687 |
// "bin", |
| 1688 |
// null, |
| 1689 |
// null, |
| 1690 |
// null, |
| 1691 |
// "1.4"); |
| 1692 |
// |
| 1693 |
// this.createFile( |
| 1694 |
// "/PX/src/X.js", |
| 1695 |
// "public class X {\n"+ |
| 1696 |
// " void foo() {\n"+ |
| 1697 |
// " XX\n"+ |
| 1698 |
// " }\n"+ |
| 1699 |
// "}"); |
| 1700 |
// |
| 1701 |
// waitUntilIndexesReady(); |
| 1702 |
// |
| 1703 |
// // do completion |
| 1704 |
// CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); |
| 1705 |
// IJavaScriptUnit cu= getCompilationUnit("PX", "src", "", "X.js"); |
| 1706 |
// |
| 1707 |
// String str = cu.getSource(); |
| 1708 |
// String completeBehind = "XX"; |
| 1709 |
// int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 1710 |
// cu.codeComplete(cursorLocation, requestor); |
| 1711 |
// |
| 1712 |
// assertResults( |
| 1713 |
// "XX11[TYPE_REF]{p11.XX11, p11, Lp11.XX11;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE) + "}\n" + |
| 1714 |
// "XX31[TYPE_REF]{p31.XX31, p31, Lp31.XX31;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE) + "}\n" + |
| 1715 |
// "XX12[TYPE_REF]{p12.XX12, p12, Lp12.XX12;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + |
| 1716 |
// "XX21[TYPE_REF]{p21.XX21, p21, Lp21.XX21;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + |
| 1717 |
// "XX22[TYPE_REF]{p22.XX22, p22, Lp22.XX22;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + |
| 1718 |
// "XX32[TYPE_REF]{p32.XX32, p32, Lp32.XX32;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", |
| 1719 |
// requestor.getResults()); |
| 1720 |
// } finally { |
| 1721 |
// this.deleteProject("P1"); |
| 1722 |
// this.deleteProject("P2"); |
| 1723 |
// this.deleteProject("P3"); |
| 1724 |
// this.deleteProject("PX"); |
| 1725 |
// JavaScriptCore.setOptions(oldOptions); |
| 1726 |
// } |
| 1727 |
//} |
| 1728 |
//public void testAccessRestriction11() throws Exception { |
| 1729 |
// Hashtable oldOptions = JavaScriptCore.getOptions(); |
| 1730 |
// try { |
| 1731 |
// Hashtable options = new Hashtable(oldOptions); |
| 1732 |
// options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.ERROR); |
| 1733 |
// options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.ENABLED); |
| 1734 |
// options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED); |
| 1735 |
// JavaScriptCore.setOptions(options); |
| 1736 |
// |
| 1737 |
// // create variable |
| 1738 |
//// JavaScriptCore.setClasspathVariables( |
| 1739 |
//// new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"}, |
| 1740 |
//// new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()}, |
| 1741 |
//// null); |
| 1742 |
// |
| 1743 |
// // create P1 |
| 1744 |
// this.createJavaProject( |
| 1745 |
// "P1", |
| 1746 |
// new String[]{"src"}, |
| 1747 |
// new String[]{"JCL_LIB"}, |
| 1748 |
// "bin"); |
| 1749 |
// |
| 1750 |
// this.createFolder("/P1/src/x/y/z/p11"); |
| 1751 |
// this.createFile( |
| 1752 |
// "/P1/src/x/y/z/p11/XX11.js", |
| 1753 |
// "package x.y.z.p11;\n"+ |
| 1754 |
// "public class XX11 {\n"+ |
| 1755 |
// "}"); |
| 1756 |
// |
| 1757 |
// this.createFolder("/P1/src/x/y/z/p12"); |
| 1758 |
// this.createFile( |
| 1759 |
// "/P1/src/x/y/z/p12/XX12.js", |
| 1760 |
// "package x.y.z.p12;\n"+ |
| 1761 |
// "public class XX12 {\n"+ |
| 1762 |
// "}"); |
| 1763 |
// |
| 1764 |
// // create P2 |
| 1765 |
// this.createJavaProject( |
| 1766 |
// "P2", |
| 1767 |
// new String[]{"src"}, |
| 1768 |
// new String[]{"JCL_LIB"}, |
| 1769 |
// null, |
| 1770 |
// null, |
| 1771 |
// new String[]{"/P3", "/P1"}, |
| 1772 |
// new String[][]{{}, {}}, |
| 1773 |
// new String[][]{{"x/y/z/p31/*"}, {"x/y/z/p11/*"}}, |
| 1774 |
// new boolean[]{true, true}, |
| 1775 |
// "bin", |
| 1776 |
// null, |
| 1777 |
// null, |
| 1778 |
// null, |
| 1779 |
// "1.4"); |
| 1780 |
// |
| 1781 |
// this.createFolder("/P2/src/x/y/z/p21"); |
| 1782 |
// this.createFile( |
| 1783 |
// "/P2/src/x/y/z/p21/XX21.js", |
| 1784 |
// "package x.y.z.p21;\n"+ |
| 1785 |
// "public class XX21 {\n"+ |
| 1786 |
// "}"); |
| 1787 |
// |
| 1788 |
// this.createFolder("/P2/src/x/y/z/p22"); |
| 1789 |
// this.createFile( |
| 1790 |
// "/P2/src/x/y/z/p22/XX22.js", |
| 1791 |
// "package x.y.z.p22;\n"+ |
| 1792 |
// "public class XX22 {\n"+ |
| 1793 |
// "}"); |
| 1794 |
// |
| 1795 |
// // create P3 |
| 1796 |
// this.createJavaProject( |
| 1797 |
// "P3", |
| 1798 |
// new String[]{"src"}, |
| 1799 |
// new String[]{"JCL_LIB"}, |
| 1800 |
// null, |
| 1801 |
// null, |
| 1802 |
// new String[]{"/P1"}, |
| 1803 |
// new String[][]{{}}, |
| 1804 |
// new String[][]{{"x/y/z/p12/*"}}, |
| 1805 |
// new boolean[]{true}, |
| 1806 |
// "bin", |
| 1807 |
// null, |
| 1808 |
// null, |
| 1809 |
// null, |
| 1810 |
// "1.4"); |
| 1811 |
// |
| 1812 |
// this.createFolder("/P3/src/x/y/z/p31"); |
| 1813 |
// this.createFile( |
| 1814 |
// "/P3/src/x/y/z/p31/XX31.js", |
| 1815 |
// "package x.y.z.p31;\n"+ |
| 1816 |
// "public class XX31 {\n"+ |
| 1817 |
// "}"); |
| 1818 |
// |
| 1819 |
// this.createFolder("/P3/src/x/y/z/p32"); |
| 1820 |
// this.createFile( |
| 1821 |
// "/P3/src/x/y/z/p32/XX32.js", |
| 1822 |
// "package x.y.z.p32;\n"+ |
| 1823 |
// "public class XX32 {\n"+ |
| 1824 |
// "}"); |
| 1825 |
// |
| 1826 |
// // create PX |
| 1827 |
// this.createJavaProject( |
| 1828 |
// "PX", |
| 1829 |
// new String[]{"src"}, |
| 1830 |
// new String[]{"JCL_LIB"}, |
| 1831 |
// null, |
| 1832 |
// null, |
| 1833 |
// new String[]{"/P2"}, |
| 1834 |
// null, |
| 1835 |
// null, |
| 1836 |
// new boolean[]{false}, |
| 1837 |
// "bin", |
| 1838 |
// null, |
| 1839 |
// null, |
| 1840 |
// null, |
| 1841 |
// "1.4"); |
| 1842 |
// |
| 1843 |
// this.createFile( |
| 1844 |
// "/PX/src/X.js", |
| 1845 |
// "public class X {\n"+ |
| 1846 |
// " void foo() {\n"+ |
| 1847 |
// " XX\n"+ |
| 1848 |
// " }\n"+ |
| 1849 |
// "}"); |
| 1850 |
// |
| 1851 |
// waitUntilIndexesReady(); |
| 1852 |
// |
| 1853 |
// // do completion |
| 1854 |
// CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); |
| 1855 |
// IJavaScriptUnit cu= getCompilationUnit("PX", "src", "", "X.js"); |
| 1856 |
// |
| 1857 |
// String str = cu.getSource(); |
| 1858 |
// String completeBehind = "XX"; |
| 1859 |
// int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 1860 |
// cu.codeComplete(cursorLocation, requestor); |
| 1861 |
// |
| 1862 |
// assertResults( |
| 1863 |
// "XX11[TYPE_REF]{x.y.z.p11.XX11, x.y.z.p11, Lx.y.z.p11.XX11;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + |
| 1864 |
// "XX21[TYPE_REF]{x.y.z.p21.XX21, x.y.z.p21, Lx.y.z.p21.XX21;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + |
| 1865 |
// "XX22[TYPE_REF]{x.y.z.p22.XX22, x.y.z.p22, Lx.y.z.p22.XX22;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + |
| 1866 |
// "XX32[TYPE_REF]{x.y.z.p32.XX32, x.y.z.p32, Lx.y.z.p32.XX32;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", |
| 1867 |
// requestor.getResults()); |
| 1868 |
// } finally { |
| 1869 |
// this.deleteProject("P1"); |
| 1870 |
// this.deleteProject("P2"); |
| 1871 |
// this.deleteProject("P3"); |
| 1872 |
// this.deleteProject("PX"); |
| 1873 |
// JavaScriptCore.setOptions(oldOptions); |
| 1874 |
// } |
| 1875 |
//} |
| 1876 |
//public void testAccessRestriction12() throws Exception { |
| 1877 |
// Hashtable oldOptions = JavaScriptCore.getOptions(); |
| 1878 |
// try { |
| 1879 |
// Hashtable options = new Hashtable(oldOptions); |
| 1880 |
// options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.ERROR); |
| 1881 |
// options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.DISABLED); |
| 1882 |
// options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED); |
| 1883 |
// JavaScriptCore.setOptions(options); |
| 1884 |
// |
| 1885 |
// // create variable |
| 1886 |
//// JavaScriptCore.setClasspathVariables( |
| 1887 |
//// new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"}, |
| 1888 |
//// new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()}, |
| 1889 |
//// null); |
| 1890 |
// |
| 1891 |
// // create P1 |
| 1892 |
// this.createJavaProject( |
| 1893 |
// "P1", |
| 1894 |
// new String[]{"src"}, |
| 1895 |
// new String[]{"JCL_LIB"}, |
| 1896 |
// "bin"); |
| 1897 |
// |
| 1898 |
// this.createFolder("/P1/src/p11"); |
| 1899 |
// this.createFile( |
| 1900 |
// "/P1/src/p11/XX11.js", |
| 1901 |
// "package p11;\n"+ |
| 1902 |
// "public class XX11 {\n"+ |
| 1903 |
// "}"); |
| 1904 |
// |
| 1905 |
// this.createFolder("/P1/src/p12"); |
| 1906 |
// this.createFile( |
| 1907 |
// "/P1/src/p12/XX12.js", |
| 1908 |
// "package p12;\n"+ |
| 1909 |
// "public class XX12 {\n"+ |
| 1910 |
// "}"); |
| 1911 |
// |
| 1912 |
// // create P2 |
| 1913 |
// this.createJavaProject( |
| 1914 |
// "P2", |
| 1915 |
// new String[]{"src"}, |
| 1916 |
// new String[]{"JCL_LIB"}, |
| 1917 |
// null, |
| 1918 |
// null, |
| 1919 |
// new String[]{"/P3", "/P1"}, |
| 1920 |
// new String[][]{{}, {}}, |
| 1921 |
// new String[][]{{"p31/*"}, {"p11/*"}}, |
| 1922 |
// new boolean[]{true, true}, |
| 1923 |
// "bin", |
| 1924 |
// null, |
| 1925 |
// null, |
| 1926 |
// null, |
| 1927 |
// "1.4"); |
| 1928 |
// |
| 1929 |
// this.createFolder("/P2/src/p21"); |
| 1930 |
// this.createFile( |
| 1931 |
// "/P2/src/p21/XX21.js", |
| 1932 |
// "package p21;\n"+ |
| 1933 |
// "public class XX21 {\n"+ |
| 1934 |
// "}"); |
| 1935 |
// |
| 1936 |
// this.createFolder("/P2/src/p22"); |
| 1937 |
// this.createFile( |
| 1938 |
// "/P2/src/p22/XX22.js", |
| 1939 |
// "package p22;\n"+ |
| 1940 |
// "public class XX22 {\n"+ |
| 1941 |
// "}"); |
| 1942 |
// |
| 1943 |
// // create P3 |
| 1944 |
// this.createJavaProject( |
| 1945 |
// "P3", |
| 1946 |
// new String[]{"src"}, |
| 1947 |
// new String[]{"JCL_LIB"}, |
| 1948 |
// null, |
| 1949 |
// null, |
| 1950 |
// new String[]{"/P1"}, |
| 1951 |
// new String[][]{{}}, |
| 1952 |
// new String[][]{{"p12/*"}}, |
| 1953 |
// new boolean[]{true}, |
| 1954 |
// "bin", |
| 1955 |
// null, |
| 1956 |
// null, |
| 1957 |
// null, |
| 1958 |
// "1.4"); |
| 1959 |
// |
| 1960 |
// this.createFolder("/P3/src/p31"); |
| 1961 |
// this.createFile( |
| 1962 |
// "/P3/src/p31/XX31.js", |
| 1963 |
// "package p31;\n"+ |
| 1964 |
// "public class XX31 {\n"+ |
| 1965 |
// "}"); |
| 1966 |
// |
| 1967 |
// this.createFolder("/P3/src/p32"); |
| 1968 |
// this.createFile( |
| 1969 |
// "/P3/src/p32/XX32.js", |
| 1970 |
// "package p32;\n"+ |
| 1971 |
// "public class XX32 {\n"+ |
| 1972 |
// "}"); |
| 1973 |
// |
| 1974 |
// // create PX |
| 1975 |
// this.createJavaProject( |
| 1976 |
// "PX", |
| 1977 |
// new String[]{"src"}, |
| 1978 |
// new String[]{"JCL_LIB"}, |
| 1979 |
// null, |
| 1980 |
// null, |
| 1981 |
// new String[]{"/P2"}, |
| 1982 |
// null, |
| 1983 |
// null, |
| 1984 |
// new boolean[]{false}, |
| 1985 |
// "bin", |
| 1986 |
// null, |
| 1987 |
// null, |
| 1988 |
// null, |
| 1989 |
// "1.4"); |
| 1990 |
// |
| 1991 |
// this.createFile( |
| 1992 |
// "/PX/src/X.js", |
| 1993 |
// "public class X {\n"+ |
| 1994 |
// " void foo() {\n"+ |
| 1995 |
// " XX\n"+ |
| 1996 |
// " }\n"+ |
| 1997 |
// "}"); |
| 1998 |
// |
| 1999 |
// waitUntilIndexesReady(); |
| 2000 |
// |
| 2001 |
// // do completion |
| 2002 |
// CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); |
| 2003 |
// IJavaScriptUnit cu= getCompilationUnit("PX", "src", "", "X.js"); |
| 2004 |
// |
| 2005 |
// String str = cu.getSource(); |
| 2006 |
// String completeBehind = "XX"; |
| 2007 |
// int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 2008 |
// cu.codeComplete(cursorLocation, requestor); |
| 2009 |
// |
| 2010 |
// assertResults( |
| 2011 |
// "XX12[TYPE_REF]{p12.XX12, p12, Lp12.XX12;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE) + "}\n" + |
| 2012 |
// "XX31[TYPE_REF]{p31.XX31, p31, Lp31.XX31;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE) + "}\n" + |
| 2013 |
// "XX11[TYPE_REF]{p11.XX11, p11, Lp11.XX11;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + |
| 2014 |
// "XX21[TYPE_REF]{p21.XX21, p21, Lp21.XX21;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + |
| 2015 |
// "XX22[TYPE_REF]{p22.XX22, p22, Lp22.XX22;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + |
| 2016 |
// "XX32[TYPE_REF]{p32.XX32, p32, Lp32.XX32;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", |
| 2017 |
// requestor.getResults()); |
| 2018 |
// } finally { |
| 2019 |
// this.deleteProject("P1"); |
| 2020 |
// this.deleteProject("P2"); |
| 2021 |
// this.deleteProject("P3"); |
| 2022 |
// this.deleteProject("PX"); |
| 2023 |
// JavaScriptCore.setOptions(oldOptions); |
| 2024 |
// } |
| 2025 |
//} |
| 2026 |
//public void testAccessRestriction13() throws Exception { |
| 2027 |
// Hashtable oldOptions = JavaScriptCore.getOptions(); |
| 2028 |
// try { |
| 2029 |
// Hashtable options = new Hashtable(oldOptions); |
| 2030 |
// options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.WARNING); |
| 2031 |
// options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.ENABLED); |
| 2032 |
// options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED); |
| 2033 |
// JavaScriptCore.setOptions(options); |
| 2034 |
// |
| 2035 |
// // create variable |
| 2036 |
//// JavaScriptCore.setClasspathVariables( |
| 2037 |
//// new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"}, |
| 2038 |
//// new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()}, |
| 2039 |
//// null); |
| 2040 |
// |
| 2041 |
// // create P1 |
| 2042 |
// this.createJavaProject( |
| 2043 |
// "P1", |
| 2044 |
// new String[]{"src"}, |
| 2045 |
// new String[]{"JCL_LIB"}, |
| 2046 |
// "bin"); |
| 2047 |
// |
| 2048 |
// this.createFolder("/P1/src/a"); |
| 2049 |
// this.createFile( |
| 2050 |
// "/P1/src/a/XX1.js", |
| 2051 |
// "package a;\n"+ |
| 2052 |
// "public class XX1 {\n"+ |
| 2053 |
// "}"); |
| 2054 |
// |
| 2055 |
// this.createFolder("/P1/src/b"); |
| 2056 |
// this.createFile( |
| 2057 |
// "/P1/src/b/XX2.js", |
| 2058 |
// "package b;\n"+ |
| 2059 |
// "public class XX2 {\n"+ |
| 2060 |
// "}"); |
| 2061 |
// |
| 2062 |
// // create P2 |
| 2063 |
// this.createJavaProject( |
| 2064 |
// "P2", |
| 2065 |
// new String[]{"src"}, |
| 2066 |
// new String[]{"JCL_LIB"}, |
| 2067 |
// null, |
| 2068 |
// null, |
| 2069 |
// new String[]{"/P1"}, |
| 2070 |
// new String[][]{{}}, |
| 2071 |
// new String[][]{{"a/*"}}, |
| 2072 |
// new boolean[]{false}, |
| 2073 |
// "bin", |
| 2074 |
// null, |
| 2075 |
// null, |
| 2076 |
// null, |
| 2077 |
// "1.4"); |
| 2078 |
// this.createFile( |
| 2079 |
// "/P2/src/YY.js", |
| 2080 |
// "public class YY {\n"+ |
| 2081 |
// " void foo() {\n"+ |
| 2082 |
// " XX\n"+ |
| 2083 |
// " }\n"+ |
| 2084 |
// "}"); |
| 2085 |
// |
| 2086 |
// waitUntilIndexesReady(); |
| 2087 |
// |
| 2088 |
// // do completion |
| 2089 |
// CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); |
| 2090 |
// IJavaScriptUnit cu= getCompilationUnit("P2", "src", "", "YY.js"); |
| 2091 |
// |
| 2092 |
// String str = cu.getSource(); |
| 2093 |
// String completeBehind = "XX"; |
| 2094 |
// int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 2095 |
// cu.codeComplete(cursorLocation, requestor); |
| 2096 |
// |
| 2097 |
// assertResults( |
| 2098 |
// "XX2[TYPE_REF]{b.XX2, b, Lb.XX2;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", |
| 2099 |
// requestor.getResults()); |
| 2100 |
// } finally { |
| 2101 |
// this.deleteProject("P1"); |
| 2102 |
// this.deleteProject("P2"); |
| 2103 |
// JavaScriptCore.setOptions(oldOptions); |
| 2104 |
// } |
| 2105 |
//} |
| 2106 |
//public void testAccessRestriction14() throws Exception { |
| 2107 |
// Hashtable oldOptions = JavaScriptCore.getOptions(); |
| 2108 |
// try { |
| 2109 |
// Hashtable options = new Hashtable(oldOptions); |
| 2110 |
// options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.WARNING); |
| 2111 |
// options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.ENABLED); |
| 2112 |
// options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.ENABLED); |
| 2113 |
// JavaScriptCore.setOptions(options); |
| 2114 |
// |
| 2115 |
// // create variable |
| 2116 |
//// JavaScriptCore.setClasspathVariables( |
| 2117 |
//// new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"}, |
| 2118 |
//// new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()}, |
| 2119 |
//// null); |
| 2120 |
// |
| 2121 |
// // create P1 |
| 2122 |
// this.createJavaProject( |
| 2123 |
// "P1", |
| 2124 |
// new String[]{"src"}, |
| 2125 |
// new String[]{"JCL_LIB"}, |
| 2126 |
// "bin"); |
| 2127 |
// |
| 2128 |
// this.createFolder("/P1/src/a"); |
| 2129 |
// this.createFile( |
| 2130 |
// "/P1/src/a/XX1.js", |
| 2131 |
// "package a;\n"+ |
| 2132 |
// "public class XX1 {\n"+ |
| 2133 |
// "}"); |
| 2134 |
// |
| 2135 |
// this.createFolder("/P1/src/b"); |
| 2136 |
// this.createFile( |
| 2137 |
// "/P1/src/b/XX2.js", |
| 2138 |
// "package b;\n"+ |
| 2139 |
// "public class XX2 {\n"+ |
| 2140 |
// "}"); |
| 2141 |
// |
| 2142 |
// // create P2 |
| 2143 |
// this.createJavaProject( |
| 2144 |
// "P2", |
| 2145 |
// new String[]{"src"}, |
| 2146 |
// new String[]{"JCL_LIB"}, |
| 2147 |
// null, |
| 2148 |
// null, |
| 2149 |
// new String[]{"/P1"}, |
| 2150 |
// new String[][]{{}}, |
| 2151 |
// new String[][]{{"a/*"}}, |
| 2152 |
// new boolean[]{false}, |
| 2153 |
// "bin", |
| 2154 |
// null, |
| 2155 |
// null, |
| 2156 |
// null, |
| 2157 |
// "1.4"); |
| 2158 |
// this.createFile( |
| 2159 |
// "/P2/src/YY.js", |
| 2160 |
// "public class YY {\n"+ |
| 2161 |
// " void foo() {\n"+ |
| 2162 |
// " XX\n"+ |
| 2163 |
// " }\n"+ |
| 2164 |
// "}"); |
| 2165 |
// |
| 2166 |
// waitUntilIndexesReady(); |
| 2167 |
// |
| 2168 |
// // do completion |
| 2169 |
// CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); |
| 2170 |
// IJavaScriptUnit cu= getCompilationUnit("P2", "src", "", "YY.js"); |
| 2171 |
// |
| 2172 |
// String str = cu.getSource(); |
| 2173 |
// String completeBehind = "XX"; |
| 2174 |
// int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 2175 |
// cu.codeComplete(cursorLocation, requestor); |
| 2176 |
// |
| 2177 |
// assertResults( |
| 2178 |
// "XX2[TYPE_REF]{b.XX2, b, Lb.XX2;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", |
| 2179 |
// requestor.getResults()); |
| 2180 |
// } finally { |
| 2181 |
// this.deleteProject("P1"); |
| 2182 |
// this.deleteProject("P2"); |
| 2183 |
// JavaScriptCore.setOptions(oldOptions); |
| 2184 |
// } |
| 2185 |
//} |
| 2186 |
//public void testAccessRestrictionX() throws Exception { |
| 2187 |
// Hashtable oldOptions = JavaScriptCore.getOptions(); |
| 2188 |
// try { |
| 2189 |
// Hashtable options = new Hashtable(oldOptions); |
| 2190 |
// options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.ERROR); |
| 2191 |
// options.put(JavaScriptCore.CODEASSIST_RESTRICTIONS_CHECK, JavaScriptCore.DISABLED); |
| 2192 |
// JavaScriptCore.setOptions(options); |
| 2193 |
// |
| 2194 |
// // create variable |
| 2195 |
// JavaScriptCore.setClasspathVariables( |
| 2196 |
// new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"}, |
| 2197 |
// new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()}, |
| 2198 |
// null); |
| 2199 |
// |
| 2200 |
// // create P1 |
| 2201 |
// this.createJavaProject( |
| 2202 |
// "P1", |
| 2203 |
// new String[]{"src"}, |
| 2204 |
// new String[]{"JCL_LIB"}, |
| 2205 |
// "bin"); |
| 2206 |
// |
| 2207 |
// this.createFolder("/P1/src/a"); |
| 2208 |
// this.createFile( |
| 2209 |
// "/P1/src/a/XX1.js", |
| 2210 |
// "package a;\n"+ |
| 2211 |
// "public class XX1 {\n"+ |
| 2212 |
// " public void foo() {\n"+ |
| 2213 |
// " }\n"+ |
| 2214 |
// "}"); |
| 2215 |
// |
| 2216 |
// // create P2 |
| 2217 |
// this.createJavaProject( |
| 2218 |
// "P2", |
| 2219 |
// new String[]{"src"}, |
| 2220 |
// new String[]{"JCL_LIB"}, |
| 2221 |
// null, |
| 2222 |
// null, |
| 2223 |
// new String[]{"/P1"}, |
| 2224 |
// new String[][]{{}}, |
| 2225 |
// new String[][]{{"a/*"}}, |
| 2226 |
// new boolean[]{false}, |
| 2227 |
// "bin", |
| 2228 |
// null, |
| 2229 |
// null, |
| 2230 |
// null, |
| 2231 |
// "1.4"); |
| 2232 |
// this.createFile( |
| 2233 |
// "/P2/src/YY.js", |
| 2234 |
// "public class YY {\n"+ |
| 2235 |
// " void foo() {\n"+ |
| 2236 |
// " a.XX1 x;\n"+ |
| 2237 |
// " x.fo\n"+ |
| 2238 |
// " }\n"+ |
| 2239 |
// "}"); |
| 2240 |
// |
| 2241 |
// waitUntilIndexesReady(); |
| 2242 |
// |
| 2243 |
// // do completion |
| 2244 |
// CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); |
| 2245 |
// IJavaScriptUnit cu= getCompilationUnit("P2", "src", "", "YY.js"); |
| 2246 |
// |
| 2247 |
// String str = cu.getSource(); |
| 2248 |
// String completeBehind = "x.fo"; |
| 2249 |
// int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 2250 |
// cu.codeComplete(cursorLocation, requestor); |
| 2251 |
// |
| 2252 |
// assertResults( |
| 2253 |
// "foo[FUNCTION_REF]{foo(), La.XX1;, ()V, foo, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC) + "}", |
| 2254 |
// requestor.getResults()); |
| 2255 |
// } finally { |
| 2256 |
// this.deleteProject("P1"); |
| 2257 |
// this.deleteProject("P2"); |
| 2258 |
// JavaScriptCore.setOptions(oldOptions); |
| 2259 |
// } |
| 2260 |
//} |
| 2261 |
//public void testBug96950() throws Exception { |
| 2262 |
// try { |
| 2263 |
// // create variable |
| 2264 |
//// JavaScriptCore.setClasspathVariables( |
| 2265 |
//// new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"}, |
| 2266 |
//// new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()}, |
| 2267 |
//// null); |
| 2268 |
// |
| 2269 |
// // create P1 |
| 2270 |
// this.createJavaProject( |
| 2271 |
// "P1", |
| 2272 |
// new String[]{"src"}, |
| 2273 |
// new String[]{"JCL_LIB"}, |
| 2274 |
// "bin"); |
| 2275 |
// this.createFile( |
| 2276 |
// "/P1/src/Taratata.js", |
| 2277 |
// "public class Taratata {\n"+ |
| 2278 |
// "}"); |
| 2279 |
// |
| 2280 |
// // create P2 |
| 2281 |
// this.createJavaProject( |
| 2282 |
// "P2", |
| 2283 |
// new String[]{"src"}, |
| 2284 |
// new String[]{"JCL_LIB"}, |
| 2285 |
// null, |
| 2286 |
// null, |
| 2287 |
// new String[]{"/P1"}, |
| 2288 |
// new String[][]{{}}, |
| 2289 |
// new String[][]{{"**/*"}}, |
| 2290 |
// new boolean[]{false}, |
| 2291 |
// "bin", |
| 2292 |
// null, |
| 2293 |
// null, |
| 2294 |
// null, |
| 2295 |
// "1.4"); |
| 2296 |
// this.createFile( |
| 2297 |
// "/P2/src/BreakRules.js", |
| 2298 |
// "public class BreakRules {\n"+ |
| 2299 |
// " Tara\n"+ |
| 2300 |
// "}"); |
| 2301 |
// |
| 2302 |
// waitUntilIndexesReady(); |
| 2303 |
// |
| 2304 |
// // do completion |
| 2305 |
// CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); |
| 2306 |
// IJavaScriptUnit cu= getCompilationUnit("P2", "src", "", "BreakRules.js"); |
| 2307 |
// |
| 2308 |
// String str = cu.getSource(); |
| 2309 |
// String completeBehind = "Tara"; |
| 2310 |
// int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
| 2311 |
// cu.codeComplete(cursorLocation, requestor); |
| 2312 |
// |
| 2313 |
// assertResults( |
| 2314 |
// "Tara[POTENTIAL_METHOD_DECLARATION]{Tara, LBreakRules;, ()V, Tara, "+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}", |
| 2315 |
// requestor.getResults()); |
| 2316 |
// } finally { |
| 2317 |
// this.deleteProject("P1"); |
| 2318 |
// this.deleteProject("P2"); |
| 2319 |
// } |
| 2320 |
//} |
| 2321 |
/** |
| 2322 |
* @bug 162621: [model][delta] Validation errors do not clear after replacing jar file |
| 2323 |
* @test Ensures that changing an internal jar and refreshing takes the change into account |
| 2324 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=162621" |
| 2325 |
*/ |
| 2326 |
//public void testChangeInternalJar() throws CoreException, IOException { |
| 2327 |
// |
| 2328 |
// |
| 2329 |
// IJavaScriptProject p = this.createJavaProject( |
| 2330 |
// "P1", |
| 2331 |
// new String[]{"/"}, |
| 2332 |
// new String[]{}, |
| 2333 |
// ""); |
| 2334 |
// |
| 2335 |
// |
| 2336 |
// |
| 2337 |
// |
| 2338 |
// try { |
| 2339 |
// // Create jar file with a class with 2 methods doXXX |
| 2340 |
// String[] pathAndContents = new String[] { |
| 2341 |
// "pack/Util.js", |
| 2342 |
// "package pack;\n" + |
| 2343 |
// "public class Util {\n" + |
| 2344 |
// " public void doit2A(int x, int y) { }\n" + |
| 2345 |
// " public void doit2B(int x) { }\n" + |
| 2346 |
// "}\n" |
| 2347 |
// }; |
| 2348 |
// addLibrary(jarName, "b162621_src.zip", pathAndContents, JavaScriptCore.VERSION_1_4); |
| 2349 |
// |
| 2350 |
// // Wait a little bit to be sure file system is aware of zip file creation |
| 2351 |
// try { |
| 2352 |
// Thread.sleep(1000); |
| 2353 |
// } |
| 2354 |
// catch (InterruptedException ie) { |
| 2355 |
// // skip |
| 2356 |
// } |
| 2357 |
// |
| 2358 |
// // Create compilation unit in which completion occurs |
| 2359 |
// String path = "/Completion/src/test/Test.js"; |
| 2360 |
// String source = "package test;\n" + |
| 2361 |
// "import pack.*;\n" + |
| 2362 |
// "public class Test {\n" + |
| 2363 |
// " public void foo() {\n" + |
| 2364 |
// " Util test = new Util();\n" + |
| 2365 |
// " test.doit2A(1, 2);\n" + |
| 2366 |
// " }\n" + |
| 2367 |
// "}\n"; |
| 2368 |
// createFolder("/Completion/src/test"); |
| 2369 |
// createFile(path, source); |
| 2370 |
// |
| 2371 |
// // first completion |
| 2372 |
// CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); |
| 2373 |
// IJavaScriptUnit unit = getCompilationUnit(path); |
| 2374 |
// String completeBehind = "test.do"; |
| 2375 |
// int cursorLocation = source.lastIndexOf(completeBehind) + completeBehind.length(); |
| 2376 |
// unit.codeComplete(cursorLocation, requestor); |
| 2377 |
// assertResults( |
| 2378 |
// "doit2A[FUNCTION_REF]{doit2A, Lpack.Util;, (II)V, doit2A, "+(R_DEFAULT + R_CASE + R_INTERESTING + R_NON_RESTRICTED + R_NON_STATIC) + "}\n" + |
| 2379 |
// "doit2B[FUNCTION_REF]{doit2B, Lpack.Util;, (I)V, doit2B, "+(R_DEFAULT + R_CASE + R_INTERESTING + R_NON_RESTRICTED + R_NON_STATIC) + "}", |
| 2380 |
// requestor.getResults()); |
| 2381 |
// |
| 2382 |
// // change class file to add a third doXXX method and refresh |
| 2383 |
// String projectLocation = this.currentProject.getProject().getLocation().toOSString(); |
| 2384 |
// String jarPath = projectLocation + File.separator + jarName; |
| 2385 |
// org.eclipse.wst.jsdt.core.tests.util.Util.createJar(new String[] { |
| 2386 |
// "pack/Util.js", |
| 2387 |
// "package pack;\n" + |
| 2388 |
// "public class Util {\n" + |
| 2389 |
// " public void doit2A(int x, int y) { }\n" + |
| 2390 |
// " public void doit2B(int x) { }\n" + |
| 2391 |
// " public void doit2C(int x) { }\n" + |
| 2392 |
// "}\n" |
| 2393 |
// }, jarPath, "1.4"); |
| 2394 |
// this.currentProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null); |
| 2395 |
// |
| 2396 |
// try { |
| 2397 |
// Thread.sleep(1000); |
| 2398 |
// } |
| 2399 |
// catch (InterruptedException ie) { |
| 2400 |
// // skip |
| 2401 |
// } |
| 2402 |
// |
| 2403 |
// // second completion |
| 2404 |
// requestor = new CompletionTestsRequestor2(); |
| 2405 |
// unit.codeComplete(cursorLocation, requestor); |
| 2406 |
// assertResults( |
| 2407 |
// "doit2A[FUNCTION_REF]{doit2A, Lpack.Util;, (II)V, doit2A, "+(R_DEFAULT + R_CASE + R_INTERESTING + R_NON_RESTRICTED + R_NON_STATIC) + "}\n" + |
| 2408 |
// "doit2B[FUNCTION_REF]{doit2B, Lpack.Util;, (I)V, doit2B, "+(R_DEFAULT + R_CASE + R_INTERESTING + R_NON_RESTRICTED + R_NON_STATIC) + "}\n" + |
| 2409 |
// "doit2C[FUNCTION_REF]{doit2C, Lpack.Util;, (I)V, doit2C, "+(R_DEFAULT + R_CASE + R_INTERESTING + R_NON_RESTRICTED + R_NON_STATIC) + "}", |
| 2410 |
// requestor.getResults()); |
| 2411 |
// } finally { |
| 2412 |
// removeLibraryEntry(this.currentProject, new Path(jarName)); |
| 2413 |
// deleteFile(new File(jarName)); |
| 2414 |
// } |
| 2415 |
//} |
| 2416 |
} |