View | Details | Raw Unified | Return to bug 244549
Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/LocalVariable.java (-1 / +1 lines)
Lines 228-234 Link Here
228
		buff.append(JEM_COUNT);
228
		buff.append(JEM_COUNT);
229
		buff.append(this.nameEnd);
229
		buff.append(this.nameEnd);
230
		buff.append(JEM_COUNT);
230
		buff.append(JEM_COUNT);
231
		buff.append(this.typeSignature);
231
		escapeMementoName(buff, this.typeSignature);
232
		if (this.occurrenceCount > 1) {
232
		if (this.occurrenceCount > 1) {
233
			buff.append(JEM_COUNT);
233
			buff.append(JEM_COUNT);
234
			buff.append(this.occurrenceCount);
234
			buff.append(this.occurrenceCount);
(-)src/org/eclipse/jdt/core/tests/model/MementoTests.java (-8 / +32 lines)
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.

Return to bug 244549