Lines 470-475
Link Here
|
470 |
/** |
470 |
/** |
471 |
* Tests that a local variable can be persisted and restored using its memento. |
471 |
* Tests that a local variable can be persisted and restored using its memento. |
472 |
*/ |
472 |
*/ |
|
|
473 |
public void testLocalVariableMemento2() throws JavaModelException { |
474 |
IType type = getClassFile("/P/src/p/X.class").getType(); |
475 |
IMethod method = type.getMethod("foo", new String[]{"I"}); |
476 |
|
477 |
ILocalVariable localVar = new LocalVariable((JavaElement)method, "var", 1, 2, 3, 4, "Z", null); |
478 |
assertMemento( |
479 |
"=P/src<p(X.class[X~foo~I@var!1!2!3!4!Z", |
480 |
localVar); |
481 |
} |
482 |
/** |
483 |
* Tests that a local variable can be persisted and restored using its memento. |
484 |
*/ |
473 |
public void testLocalVariableMemento3() { |
485 |
public void testLocalVariableMemento3() { |
474 |
IType type = getCompilationUnit("/P/src/p/X.java").getType("X"); |
486 |
IType type = getCompilationUnit("/P/src/p/X.java").getType("X"); |
475 |
IInitializer initializer = type.getInitializer(1); |
487 |
IInitializer initializer = type.getInitializer(1); |
Lines 481-495
Link Here
|
481 |
} |
493 |
} |
482 |
/** |
494 |
/** |
483 |
* Tests that a local variable can be persisted and restored using its memento. |
495 |
* Tests that a local variable can be persisted and restored using its memento. |
|
|
496 |
* (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=244549 ) |
484 |
*/ |
497 |
*/ |
485 |
public void testLocalVariableMemento2() throws JavaModelException { |
498 |
public void testLocalVariableMemento4() throws Exception { |
486 |
IType type = getClassFile("/P/src/p/X.class").getType(); |
499 |
try { |
487 |
IMethod method = type.getMethod("foo", new String[]{"I"}); |
500 |
createJavaProject("P1", new String[] {"src"}, new String[] {getExternalJCLPathString("1.5")}, "bin", "1.5"); |
488 |
|
501 |
createFile( |
489 |
ILocalVariable localVar = new LocalVariable((JavaElement)method, "var", 1, 2, 3, 4, "Z", null); |
502 |
"/P1/src/X.java", |
490 |
assertMemento( |
503 |
"public class X<T> {\n" + |
491 |
"=P/src<p(X.class[X~foo~I@var!1!2!3!4!Z", |
504 |
" void foo() {\n" + |
492 |
localVar); |
505 |
" X<String> var = null;\n" + |
|
|
506 |
" }\n" + |
507 |
"}" |
508 |
); |
509 |
ILocalVariable localVar = getLocalVariable(getCompilationUnit("/P1/src/X.java"), "var", "var"); |
510 |
String memento = localVar.getHandleIdentifier(); |
511 |
IJavaElement restored = JavaCore.create(memento); |
512 |
String restoredMemento = restored.getHandleIdentifier(); |
513 |
assertEquals("Unexpected restored memento", memento, restoredMemento); |
514 |
} finally { |
515 |
deleteProject("P1"); |
516 |
} |
493 |
} |
517 |
} |
494 |
/** |
518 |
/** |
495 |
* Tests that a package declaration can be persisted and restored using its memento. |
519 |
* Tests that a package declaration can be persisted and restored using its memento. |