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

(-)test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests.java (+22 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Benjamin Muskalla <bmuskalla@eclipsesource.com>
11
 *            213519: [extract method] Missing return value, while extractiong code out of a loop
10
 *******************************************************************************/
12
 *******************************************************************************/
11
package org.eclipse.jdt.ui.tests.refactoring;
13
package org.eclipse.jdt.ui.tests.refactoring;
12
14
Lines 1556-1561 Link Here
1556
	public void test728() throws Exception {
1558
	public void test728() throws Exception {
1557
		returnTest();
1559
		returnTest();
1558
	}
1560
	}
1561
	
1562
	// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=213519
1563
	public void test729() throws Exception {
1564
		returnTest();
1565
	}
1566
1567
	// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=213519	
1568
	public void test730() throws Exception {
1569
		returnTest();
1570
	}
1571
	
1572
	// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=213519
1573
	public void test731() throws Exception {
1574
		returnTest();
1575
	}
1576
1577
	// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=213519	
1578
	public void test732() throws Exception {
1579
		returnTest();
1580
	}
1559
1581
1560
	//---- Branch statements
1582
	//---- Branch statements
1561
1583
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/return_out/A_test730.java (+21 lines)
Added Link Here
1
package return_out;
2
3
public class A_test730 {
4
	public void foo(int x) {
5
		do {
6
		} while (x==3);
7
		
8
		int a = 0;
9
		for (int i = 0; i < 3; i++) {
10
			i = extracted(i);
11
		}
12
	}
13
14
	protected int extracted(int i) {
15
		/*[*/g(i++);/*]*/
16
		return i;
17
	}
18
19
	private void g(int i) {}
20
}
21
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/return_in/A_test729.java (+14 lines)
Added Link Here
1
package return_in;
2
3
public class A_test729 {
4
	public void foo(int x) {
5
		while (x==3) {
6
		}
7
		int a = 0;
8
		for (int i = 0; i < 3; i++) {
9
			/*[*/g(i++);/*]*/
10
		}
11
	}
12
13
	private void g(int i) {}
14
}
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/return_out/A_test731.java (+21 lines)
Added Link Here
1
package return_out;
2
3
public class A_test731 {
4
	public void foo(int x) {
5
		for (int i = 0; i < 3; i++) {
6
		}
7
		
8
		int a = 0;
9
		do {
10
			a = extracted(a);
11
		} while (x==3);
12
	}
13
14
	protected int extracted(int a) {
15
		/*[*/g(a++);/*]*/
16
		return a;
17
	}
18
19
	private void g(int i) {}
20
}
21
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/return_in/A_test731.java (+16 lines)
Added Link Here
1
package return_in;
2
3
public class A_test731 {
4
	public void foo(int x) {
5
		for (int i = 0; i < 3; i++) {
6
		}
7
		
8
		int a = 0;
9
		do {
10
			/*[*/g(a++);/*]*/
11
		} while (x==3);
12
	}
13
14
	private void g(int i) {}
15
}
16
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/return_in/A_test732.java (+20 lines)
Added Link Here
1
package return_in;
2
3
import java.util.ArrayList;
4
import java.util.List;
5
6
public class A_test732 {
7
	public void foo(int x) {
8
		List<A_test732> list = new ArrayList<A_test732>();
9
		for (A_test732 t : list) {
10
		}
11
		
12
		int a = 0;
13
		for (int i = 0; i < 3; i++) {
14
			/*[*/g(a++);/*]*/
15
		}
16
	}
17
18
	private void g(int i) {}
19
}
20
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/return_in/A_test730.java (+16 lines)
Added Link Here
1
package return_in;
2
3
public class A_test730 {
4
	public void foo(int x) {
5
		do {
6
		} while (x==3);
7
		
8
		int a = 0;
9
		for (int i = 0; i < 3; i++) {
10
			/*[*/g(i++);/*]*/
11
		}
12
	}
13
14
	private void g(int i) {}
15
}
16
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/return_out/A_test732.java (+25 lines)
Added Link Here
1
package return_out;
2
3
import java.util.ArrayList;
4
import java.util.List;
5
6
public class A_test732 {
7
	public void foo(int x) {
8
		List<A_test732> list = new ArrayList<A_test732>();
9
		for (A_test732 t : list) {
10
		}
11
		
12
		int a = 0;
13
		for (int i = 0; i < 3; i++) {
14
			a = extracted(a);
15
		}
16
	}
17
18
	protected int extracted(int a) {
19
		/*[*/g(a++);/*]*/
20
		return a;
21
	}
22
23
	private void g(int i) {}
24
}
25
(-)core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/flow/InputFlowAnalyzer.java (-3 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-15 Link Here
10
 *     Dmitry Stalnov (dstalnov@fusionone.com) - contributed fix for
10
 *     Dmitry Stalnov (dstalnov@fusionone.com) - contributed fix for
11
 *       o inline call that is used in a field initializer
11
 *       o inline call that is used in a field initializer
12
 *         (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38137)
12
 *         (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38137)
13
 *     Benjamin Muskalla <bmuskalla@eclipsesource.com>
14
 *            213519: [extract method] Missing return value, while extractiong code out of a loop
13
 *******************************************************************************/
15
 *******************************************************************************/
14
package org.eclipse.jdt.internal.corext.refactoring.code.flow;
16
package org.eclipse.jdt.internal.corext.refactoring.code.flow;
15
17
Lines 172-178 Link Here
172
	}
174
	}
173
175
174
	private void createLoopReentranceVisitor(ASTNode node) {
176
	private void createLoopReentranceVisitor(ASTNode node) {
175
		if (fLoopReentranceVisitor == null && fDoLoopReentrance)
177
		if (fLoopReentranceVisitor == null && fDoLoopReentrance && fSelection.coveredBy(node))
176
			fLoopReentranceVisitor= new LoopReentranceVisitor(fFlowContext, fSelection, node);
178
			fLoopReentranceVisitor= new LoopReentranceVisitor(fFlowContext, fSelection, node);
177
	}
179
	}
178
180
Lines 257-263 Link Here
257
	}
259
	}
258
260
259
	private void handleLoopReentrance(ASTNode node) {
261
	private void handleLoopReentrance(ASTNode node) {
260
		if (!fSelection.coveredBy(node) || fLoopReentranceVisitor == null || fLoopReentranceVisitor.getLoopNode() != node)
262
		if (fLoopReentranceVisitor == null || fLoopReentranceVisitor.getLoopNode() != node)
261
			return;
263
			return;
262
264
263
		fLoopReentranceVisitor.process(node);
265
		fLoopReentranceVisitor.process(node);

Return to bug 213519