View | Details | Raw Unified | Return to bug 48056 | Differences between
and this patch

Collapse All | Expand All

(-)core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractMethodAnalyzer.java (-4 / +70 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> - [extract method] Extract method and continue https://bugs.eclipse.org/bugs/show_bug.cgi?id=48056
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.internal.corext.refactoring.code;
12
package org.eclipse.jdt.internal.corext.refactoring.code;
12
13
Lines 25-30 Link Here
25
import org.eclipse.jdt.core.compiler.ITerminalSymbols;
26
import org.eclipse.jdt.core.compiler.ITerminalSymbols;
26
import org.eclipse.jdt.core.dom.AST;
27
import org.eclipse.jdt.core.dom.AST;
27
import org.eclipse.jdt.core.dom.ASTNode;
28
import org.eclipse.jdt.core.dom.ASTNode;
29
import org.eclipse.jdt.core.dom.ASTVisitor;
28
import org.eclipse.jdt.core.dom.AnonymousClassDeclaration;
30
import org.eclipse.jdt.core.dom.AnonymousClassDeclaration;
29
import org.eclipse.jdt.core.dom.Assignment;
31
import org.eclipse.jdt.core.dom.Assignment;
30
import org.eclipse.jdt.core.dom.Block;
32
import org.eclipse.jdt.core.dom.Block;
Lines 32-38 Link Here
32
import org.eclipse.jdt.core.dom.ClassInstanceCreation;
34
import org.eclipse.jdt.core.dom.ClassInstanceCreation;
33
import org.eclipse.jdt.core.dom.CompilationUnit;
35
import org.eclipse.jdt.core.dom.CompilationUnit;
34
import org.eclipse.jdt.core.dom.ConstructorInvocation;
36
import org.eclipse.jdt.core.dom.ConstructorInvocation;
37
import org.eclipse.jdt.core.dom.ContinueStatement;
35
import org.eclipse.jdt.core.dom.DoStatement;
38
import org.eclipse.jdt.core.dom.DoStatement;
39
import org.eclipse.jdt.core.dom.EnhancedForStatement;
36
import org.eclipse.jdt.core.dom.Expression;
40
import org.eclipse.jdt.core.dom.Expression;
37
import org.eclipse.jdt.core.dom.FieldAccess;
41
import org.eclipse.jdt.core.dom.FieldAccess;
38
import org.eclipse.jdt.core.dom.ForStatement;
42
import org.eclipse.jdt.core.dom.ForStatement;
Lines 40-51 Link Here
40
import org.eclipse.jdt.core.dom.ITypeBinding;
44
import org.eclipse.jdt.core.dom.ITypeBinding;
41
import org.eclipse.jdt.core.dom.IVariableBinding;
45
import org.eclipse.jdt.core.dom.IVariableBinding;
42
import org.eclipse.jdt.core.dom.Initializer;
46
import org.eclipse.jdt.core.dom.Initializer;
47
import org.eclipse.jdt.core.dom.LabeledStatement;
43
import org.eclipse.jdt.core.dom.Message;
48
import org.eclipse.jdt.core.dom.Message;
44
import org.eclipse.jdt.core.dom.MethodDeclaration;
49
import org.eclipse.jdt.core.dom.MethodDeclaration;
45
import org.eclipse.jdt.core.dom.Name;
50
import org.eclipse.jdt.core.dom.Name;
46
import org.eclipse.jdt.core.dom.PrimitiveType;
51
import org.eclipse.jdt.core.dom.PrimitiveType;
47
import org.eclipse.jdt.core.dom.QualifiedName;
52
import org.eclipse.jdt.core.dom.QualifiedName;
48
import org.eclipse.jdt.core.dom.SimpleName;
53
import org.eclipse.jdt.core.dom.SimpleName;
54
import org.eclipse.jdt.core.dom.Statement;
49
import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor;
55
import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor;
50
import org.eclipse.jdt.core.dom.SuperConstructorInvocation;
56
import org.eclipse.jdt.core.dom.SuperConstructorInvocation;
51
import org.eclipse.jdt.core.dom.SwitchCase;
57
import org.eclipse.jdt.core.dom.SwitchCase;
Lines 55-60 Link Here
55
import org.eclipse.jdt.core.dom.VariableDeclarationExpression;
61
import org.eclipse.jdt.core.dom.VariableDeclarationExpression;
56
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
62
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
57
import org.eclipse.jdt.core.dom.VariableDeclarationStatement;
63
import org.eclipse.jdt.core.dom.VariableDeclarationStatement;
64
import org.eclipse.jdt.core.dom.WhileStatement;
58
import org.eclipse.jdt.core.dom.rewrite.ImportRewrite;
65
import org.eclipse.jdt.core.dom.rewrite.ImportRewrite;
59
66
60
import org.eclipse.jdt.internal.corext.dom.ASTNodeFactory;
67
import org.eclipse.jdt.internal.corext.dom.ASTNodeFactory;
Lines 110-116 Link Here
110
117
111
	private boolean fForceStatic;
118
	private boolean fForceStatic;
112
	private boolean fIsLastStatementSelected;
119
	private boolean fIsLastStatementSelected;
113
120
	private SimpleName fEnclosingLoopLabel;
121
	
114
	public ExtractMethodAnalyzer(ICompilationUnit unit, Selection selection) throws CoreException {
122
	public ExtractMethodAnalyzer(ICompilationUnit unit, Selection selection) throws CoreException {
115
		super(unit, selection, false);
123
		super(unit, selection, false);
116
	}
124
	}
Lines 314-322 Link Here
314
		fInputFlowInfo= flowAnalyzer.perform(getSelectedNodes());
322
		fInputFlowInfo= flowAnalyzer.perform(getSelectedNodes());
315
323
316
		if (fInputFlowInfo.branches()) {
324
		if (fInputFlowInfo.branches()) {
317
			status.addFatalError(RefactoringCoreMessages.ExtractMethodAnalyzer_branch_mismatch, JavaStatusContext.create(fCUnit, getSelection()));
325
			if (!canHandleBranches()) {
318
			fReturnKind= ERROR;
326
				status.addFatalError(RefactoringCoreMessages.ExtractMethodAnalyzer_branch_mismatch, JavaStatusContext.create(fCUnit, getSelection()));
319
			return status;
327
				fReturnKind= ERROR;
328
				return status;
329
			}
320
		}
330
		}
321
		if (fInputFlowInfo.isValueReturn()) {
331
		if (fInputFlowInfo.isValueReturn()) {
322
			fReturnKind= RETURN_STATEMENT_VALUE;
332
			fReturnKind= RETURN_STATEMENT_VALUE;
Lines 341-346 Link Here
341
		return status;
351
		return status;
342
	}
352
	}
343
353
354
	private boolean canHandleBranches() {
355
		ASTNode[] selectedNodes= getSelectedNodes();
356
		final ASTNode lastSelectedNode= selectedNodes[selectedNodes.length - 1];
357
		Statement body= getParentLoopBody(lastSelectedNode.getParent());
358
		ASTNode lastStatmentInLoop= null;
359
		if (body != null) {
360
			if (body instanceof Block) {
361
				Block block= (Block)body;
362
				lastStatmentInLoop= (ASTNode)block.statements().get(block.statements().size() - 1);
363
			}
364
		}
365
		final boolean continueMatchesLoop[]= new boolean[1];
366
		continueMatchesLoop[0]= false;
367
		for (int i= 0; i < selectedNodes.length; i++) {
368
			final ASTNode astNode= selectedNodes[i];
369
			astNode.accept(new ASTVisitor() {
370
				public void endVisit(ContinueStatement node) {
371
					super.endVisit(node);
372
					final SimpleName label= node.getLabel();
373
					if (label == null) {
374
						continueMatchesLoop[0]= true;
375
					} else if (fEnclosingLoopLabel != null) {
376
						continueMatchesLoop[0]= label.getIdentifier().equals(fEnclosingLoopLabel.getIdentifier());
377
					}
378
				}
379
			});
380
		}
381
		return lastSelectedNode == lastStatmentInLoop && continueMatchesLoop[0] && fReturnValue == null;
382
	}
383
384
	private Statement getParentLoopBody(ASTNode node) {
385
		Statement stmt= null;
386
		ASTNode start= node;
387
		while (start != null
388
				&& !(start instanceof ForStatement)
389
				&& !(start instanceof DoStatement)
390
				&& !(start instanceof WhileStatement)
391
				&& !(start instanceof EnhancedForStatement)) {
392
			start= start.getParent();
393
		}
394
		if (start instanceof ForStatement) {
395
			stmt= ((ForStatement)start).getBody();
396
		} else if (start instanceof DoStatement) {
397
			stmt= ((DoStatement)start).getBody();
398
		} else if (start instanceof WhileStatement) {
399
			stmt= ((WhileStatement)start).getBody();
400
		} else if (start instanceof EnhancedForStatement) {
401
			stmt= ((EnhancedForStatement)start).getBody();
402
		}
403
		if (start.getParent() instanceof LabeledStatement) {
404
			LabeledStatement labeledStatement= (LabeledStatement)start.getParent();
405
			fEnclosingLoopLabel= labeledStatement.getLabel();
406
		}
407
		return stmt;
408
	}
409
344
	private boolean isVoidMethod() {
410
	private boolean isVoidMethod() {
345
		// if we have an initializer
411
		// if we have an initializer
346
		if (fEnclosingMethodBinding == null)
412
		if (fEnclosingMethodBinding == null)
(-)core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractMethodRefactoring.java (+81 lines)
Lines 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Benjamin Muskalla <bmuskalla@eclipsesource.com> - [extract method] Does not replace similar code in parent class of anonymous class - https://bugs.eclipse.org/bugs/show_bug.cgi?id=160853
10
 *     Benjamin Muskalla <bmuskalla@eclipsesource.com> - [extract method] Does not replace similar code in parent class of anonymous class - https://bugs.eclipse.org/bugs/show_bug.cgi?id=160853
11
 *     Benjamin Muskalla <bmuskalla@eclipsesource.com> - [extract method] Extract method and continue https://bugs.eclipse.org/bugs/show_bug.cgi?id=48056
11
 *******************************************************************************/
12
 *******************************************************************************/
12
package org.eclipse.jdt.internal.corext.refactoring.code;
13
package org.eclipse.jdt.internal.corext.refactoring.code;
13
14
Lines 54-69 Link Here
54
import org.eclipse.jdt.core.dom.BodyDeclaration;
55
import org.eclipse.jdt.core.dom.BodyDeclaration;
55
import org.eclipse.jdt.core.dom.ChildListPropertyDescriptor;
56
import org.eclipse.jdt.core.dom.ChildListPropertyDescriptor;
56
import org.eclipse.jdt.core.dom.CompilationUnit;
57
import org.eclipse.jdt.core.dom.CompilationUnit;
58
import org.eclipse.jdt.core.dom.ContinueStatement;
59
import org.eclipse.jdt.core.dom.DoStatement;
60
import org.eclipse.jdt.core.dom.EnhancedForStatement;
57
import org.eclipse.jdt.core.dom.EnumDeclaration;
61
import org.eclipse.jdt.core.dom.EnumDeclaration;
58
import org.eclipse.jdt.core.dom.Expression;
62
import org.eclipse.jdt.core.dom.Expression;
59
import org.eclipse.jdt.core.dom.ExpressionStatement;
63
import org.eclipse.jdt.core.dom.ExpressionStatement;
60
import org.eclipse.jdt.core.dom.FieldAccess;
64
import org.eclipse.jdt.core.dom.FieldAccess;
61
import org.eclipse.jdt.core.dom.FieldDeclaration;
65
import org.eclipse.jdt.core.dom.FieldDeclaration;
66
import org.eclipse.jdt.core.dom.ForStatement;
62
import org.eclipse.jdt.core.dom.IMethodBinding;
67
import org.eclipse.jdt.core.dom.IMethodBinding;
63
import org.eclipse.jdt.core.dom.ITypeBinding;
68
import org.eclipse.jdt.core.dom.ITypeBinding;
64
import org.eclipse.jdt.core.dom.IVariableBinding;
69
import org.eclipse.jdt.core.dom.IVariableBinding;
65
import org.eclipse.jdt.core.dom.Initializer;
70
import org.eclipse.jdt.core.dom.Initializer;
66
import org.eclipse.jdt.core.dom.Javadoc;
71
import org.eclipse.jdt.core.dom.Javadoc;
72
import org.eclipse.jdt.core.dom.LabeledStatement;
67
import org.eclipse.jdt.core.dom.MethodDeclaration;
73
import org.eclipse.jdt.core.dom.MethodDeclaration;
68
import org.eclipse.jdt.core.dom.MethodInvocation;
74
import org.eclipse.jdt.core.dom.MethodInvocation;
69
import org.eclipse.jdt.core.dom.Modifier;
75
import org.eclipse.jdt.core.dom.Modifier;
Lines 77-82 Link Here
77
import org.eclipse.jdt.core.dom.VariableDeclaration;
83
import org.eclipse.jdt.core.dom.VariableDeclaration;
78
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
84
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
79
import org.eclipse.jdt.core.dom.VariableDeclarationStatement;
85
import org.eclipse.jdt.core.dom.VariableDeclarationStatement;
86
import org.eclipse.jdt.core.dom.WhileStatement;
80
import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
87
import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
81
import org.eclipse.jdt.core.dom.rewrite.ImportRewrite;
88
import org.eclipse.jdt.core.dom.rewrite.ImportRewrite;
82
import org.eclipse.jdt.core.dom.rewrite.ListRewrite;
89
import org.eclipse.jdt.core.dom.rewrite.ListRewrite;
Lines 506-511 Link Here
506
			}
513
			}
507
514
508
			replaceDuplicates(result);
515
			replaceDuplicates(result);
516
			replaceBranches(result);
509
517
510
			if (fImportRewriter.hasRecordedChanges()) {
518
			if (fImportRewriter.hasRecordedChanges()) {
511
				TextEdit edit= fImportRewriter.rewriteImports(null);
519
				TextEdit edit= fImportRewriter.rewriteImports(null);
Lines 523-528 Link Here
523
531
524
	}
532
	}
525
533
534
	private void replaceBranches(final CompilationUnitChange result) {
535
		ASTNode[] selectedNodes= fAnalyzer.getSelectedNodes();
536
		for (int i= 0; i < selectedNodes.length; i++) {
537
			final ASTNode astNode= selectedNodes[i];
538
			astNode.accept(new ASTVisitor() {
539
				private boolean inLoop;
540
541
				private List innerLabels= new ArrayList();
542
543
				public boolean visit(ForStatement node) {
544
					inLoop= true;
545
					if (node.getParent() instanceof LabeledStatement) {
546
						LabeledStatement labeledStatement= (LabeledStatement)node.getParent();
547
						final String identifier= labeledStatement.getLabel().getIdentifier();
548
						innerLabels.add(identifier);
549
					}
550
					return super.visit(node);
551
				}
552
553
				public void endVisit(ForStatement node) {
554
					super.endVisit(node);
555
					inLoop= false;
556
				}
557
558
				public boolean visit(WhileStatement node) {
559
					inLoop= true;
560
					return super.visit(node);
561
				}
562
563
				public void endVisit(WhileStatement node) {
564
					super.endVisit(node);
565
					inLoop= false;
566
				}
567
568
				public boolean visit(EnhancedForStatement node) {
569
					inLoop= true;
570
					return super.visit(node);
571
				}
572
573
				public void endVisit(EnhancedForStatement node) {
574
					super.endVisit(node);
575
					inLoop= false;
576
				}
577
578
				public boolean visit(DoStatement node) {
579
					inLoop= true;
580
					return super.visit(node);
581
				}
582
583
				public void endVisit(DoStatement node) {
584
					super.endVisit(node);
585
					inLoop= false;
586
				}
587
588
				public void endVisit(ContinueStatement node) {
589
					final SimpleName label= node.getLabel();
590
					if (!inLoop || (label != null && !innerLabels.contains(label.getIdentifier()))) {
591
						TextEditGroup description= new TextEditGroup(RefactoringCoreMessages.ExtractMethodRefactoring_replace_continue);
592
						result.addTextEditGroup(description);
593
594
						ReturnStatement rs= fAST.newReturnStatement();
595
						IVariableBinding returnValue= fAnalyzer.getReturnValue();
596
						if (returnValue != null) {
597
							rs.setExpression(fAST.newSimpleName(getName(returnValue)));
598
						}
599
600
						new StatementRewrite(fRewriter, new ASTNode[] { node }).replace(new ASTNode[] { rs }, description);
601
					}
602
				}
603
			});
604
		}
605
	}
606
526
	private ExtractMethodDescriptor getRefactoringDescriptor() {
607
	private ExtractMethodDescriptor getRefactoringDescriptor() {
527
		final Map arguments= new HashMap();
608
		final Map arguments= new HashMap();
528
		String project= null;
609
		String project= null;
(-)core refactoring/org/eclipse/jdt/internal/corext/refactoring/refactoring.properties (+1 lines)
Lines 160-165 Link Here
160
ExtractMethodRefactoring_error_nameInUse=''{0}'' is already used as a name in the selected code
160
ExtractMethodRefactoring_error_nameInUse=''{0}'' is already used as a name in the selected code
161
ExtractMethodRefactoring_error_sameParameter=A parameter ''{0}'' already exists
161
ExtractMethodRefactoring_error_sameParameter=A parameter ''{0}'' already exists
162
ExtractMethodRefactoring_visibility_pattern=Declared visibility: ''{0}''
162
ExtractMethodRefactoring_visibility_pattern=Declared visibility: ''{0}''
163
ExtractMethodRefactoring_replace_continue=Replace continue(s) with return.
163
ExtractMethodRefactoring_replace_occurrences=Replace occurrences of statements with method
164
ExtractMethodRefactoring_replace_occurrences=Replace occurrences of statements with method
164
ExtractMethodRefactoring_error_vararg_ordering=The variable arity parameter ''{0}'' cannot be followed by another parameter
165
ExtractMethodRefactoring_error_vararg_ordering=The variable arity parameter ''{0}'' cannot be followed by another parameter
165
ExtractMethodRefactoring_descriptor_description=Extract method ''{0}'' from ''{1}'' to ''{2}''
166
ExtractMethodRefactoring_descriptor_description=Extract method ''{0}'' from ''{1}'' to ''{2}''
(-)core refactoring/org/eclipse/jdt/internal/corext/refactoring/RefactoringCoreMessages.java (+3 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> - [extract method] Extract method and continue https://bugs.eclipse.org/bugs/show_bug.cgi?id=48056
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.internal.corext.refactoring;
12
package org.eclipse.jdt.internal.corext.refactoring;
12
13
Lines 634-639 Link Here
634
635
635
	public static String ExtractMethodRefactoring_organize_imports;
636
	public static String ExtractMethodRefactoring_organize_imports;
636
637
638
	public static String ExtractMethodRefactoring_replace_continue;
639
637
	public static String ExtractMethodRefactoring_replace_occurrences;
640
	public static String ExtractMethodRefactoring_replace_occurrences;
638
641
639
	public static String ExtractMethodRefactoring_substitute_with_call;
642
	public static String ExtractMethodRefactoring_substitute_with_call;
(-)test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests.java (+63 lines)
Lines 10-15 Link Here
10
 *     Benjamin Muskalla <bmuskalla@eclipsesource.com> - [extract method] Does not replace similar code in parent class of anonymous class - https://bugs.eclipse.org/bugs/show_bug.cgi?id=160853
10
 *     Benjamin Muskalla <bmuskalla@eclipsesource.com> - [extract method] Does not replace similar code in parent class of anonymous class - https://bugs.eclipse.org/bugs/show_bug.cgi?id=160853
11
 *     Benjamin Muskalla <bmuskalla@eclipsesource.com> - [extract method] Missing return value, while extracting code out of a loop - https://bugs.eclipse.org/bugs/show_bug.cgi?id=213519
11
 *     Benjamin Muskalla <bmuskalla@eclipsesource.com> - [extract method] Missing return value, while extracting code out of a loop - https://bugs.eclipse.org/bugs/show_bug.cgi?id=213519
12
 *     Benjamin Muskalla <bmuskalla@eclipsesource.com> - [extract method] missing return type when code can throw exception - https://bugs.eclipse.org/bugs/show_bug.cgi?id=97413
12
 *     Benjamin Muskalla <bmuskalla@eclipsesource.com> - [extract method] missing return type when code can throw exception - https://bugs.eclipse.org/bugs/show_bug.cgi?id=97413
13
 *     Benjamin Muskalla <bmuskalla@eclipsesource.com> - [extract method] Extract method and continue https://bugs.eclipse.org/bugs/show_bug.cgi?id=48056
13
 *******************************************************************************/
14
 *******************************************************************************/
14
package org.eclipse.jdt.ui.tests.refactoring;
15
package org.eclipse.jdt.ui.tests.refactoring;
15
16
Lines 651-656 Link Here
651
	public void test196() throws Exception {
652
	public void test196() throws Exception {
652
		invalidSelectionTest();
653
		invalidSelectionTest();
653
	}
654
	}
655
	
656
	//---- continue not possible
657
	
658
	public void test197() throws Exception {
659
		invalidSelectionTest();
660
	}
654
661
655
662
656
663
Lines 1616-1621 Link Here
1616
		branchTest();
1623
		branchTest();
1617
	}
1624
	}
1618
1625
1626
	public void test756() throws Exception {
1627
		branchTest();
1628
	}
1629
1630
	public void test757() throws Exception {
1631
		branchTest();
1632
	}
1633
1634
	public void test758() throws Exception {
1635
		branchTest();
1636
	}
1637
	
1638
	public void test759() throws Exception {
1639
		branchTest();
1640
	}
1641
	
1642
	public void test760() throws Exception {
1643
		branchTest();
1644
	}
1645
	
1646
	public void test761() throws Exception {
1647
		branchTest();
1648
	}
1649
	
1650
	public void test762() throws Exception {
1651
		branchTest();
1652
	}
1653
	
1654
	public void test763() throws Exception {
1655
		branchTest();
1656
	}
1657
	
1658
	public void test764() throws Exception {
1659
		branchTest();
1660
	}
1661
	
1662
	public void test765() throws Exception {
1663
		branchTest();
1664
	}
1665
	
1666
	public void test766() throws Exception {
1667
		branchTest();
1668
	}
1669
	
1670
	public void test767() throws Exception {
1671
		branchTest();
1672
	}
1673
	
1674
	public void test768() throws Exception {
1675
		branchTest();
1676
	}
1677
	
1678
	public void test769() throws Exception {
1679
		branchTest();
1680
	}
1681
	
1619
	//---- Test for CUs with compiler errors
1682
	//---- Test for CUs with compiler errors
1620
1683
1621
	public void test800() throws Exception {
1684
	public void test800() throws Exception {
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_out/A_test768.java (+21 lines)
Added Link Here
1
package branch_out;
2
3
public class A_test768 {
4
5
	public void foo() {
6
		int i = 0;
7
		do {
8
			extracted(i);
9
		} while ( i < 10 );
10
	}
11
12
	protected void extracted(int i) {
13
		/*[*/
14
		if( i == 3 ) {
15
			return;
16
		}
17
		System.out.println();
18
		/*]*/
19
	}
20
}
21
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_in/A_test765.java (+19 lines)
Added Link Here
1
package branch_in;
2
3
public class A_test765 {
4
5
	public void foo() {
6
		int x = 0;
7
		for (int i= 0; i < 3; i++) {
8
			/*[*/
9
			if(i == 2) {
10
				x = (i*3);
11
				continue;
12
			}
13
			System.out.println();
14
			/*]*/
15
		}
16
		System.out.println(x);
17
	}
18
}
19
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_in/A_test763.java (+16 lines)
Added Link Here
1
package branch_in;
2
3
public class A_test763 {
4
5
	public void foo() {
6
		inner: for (int i= 0; i < 3; i++) {
7
			/*[*/
8
			if(i == 2) {
9
				continue inner;
10
			}
11
			System.out.println();
12
			/*]*/
13
		}
14
	}
15
}
16
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_in/A_test766.java (+19 lines)
Added Link Here
1
package branch_in;
2
3
public class A_test766 {
4
5
	public void foo() {
6
		int x = 0;
7
		foo: for (int i= 0; i < 3; i++) {
8
			/*[*/
9
			if(i == 2) {
10
				x = (i*3);
11
				continue;
12
			}
13
			System.out.println();
14
			/*]*/
15
		}
16
		System.out.println(x);
17
	}
18
}
19
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_out/A_test762.java (+24 lines)
Added Link Here
1
package branch_out;
2
3
public class A_test762 {
4
5
	public void foo() {
6
		outer: for (int i= 0; i < 3; i++) {
7
			extracted();
8
		}
9
	}
10
11
	protected void extracted() {
12
		/*[*/
13
		for (int j= 0; j < 3; j++) {
14
			for (int k= 0; k < 3; k++) {
15
				if(j == 3) {
16
					return;
17
				}
18
				System.out.println();
19
			}
20
		}
21
		/*]*/
22
	}
23
}
24
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/invalidSelection/A_test197.java (+18 lines)
Added Link Here
1
package invalidSelection;
2
3
public class A_test197 {
4
5
	public void foo() {
6
		outer: for (int i= 0; i < 3; i++) {
7
			for (int j= 0; j < 3; j++) {
8
				/*[*/
9
				if(j == 3) {
10
					continue outer;
11
				}
12
				System.out.println();
13
				/*]*/
14
			}
15
		}
16
	}
17
}
18
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_out/A_test757.java (+20 lines)
Added Link Here
1
package branch_out;
2
3
public class A_test757 {
4
5
	public void foo() {
6
		extracted();
7
	}
8
9
	protected void extracted() {
10
		/*[*/
11
		for (int i= 0; i < 3; i++) {
12
			if(i == 2) {
13
				continue;
14
			}
15
			System.out.println();
16
		}
17
		/*]*/
18
	}
19
}
20
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_in/A_test759.java (+16 lines)
Added Link Here
1
package branch_in;
2
3
public class A_test759 {
4
5
	public void foo(int a) {
6
		/*[*/
7
		while (a > 0) {
8
			if(a == 3) {
9
				continue;
10
			}
11
			System.out.println();
12
		}
13
		/*]*/
14
	}
15
}
16
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_in/A_test762.java (+20 lines)
Added Link Here
1
package branch_in;
2
3
public class A_test762 {
4
5
	public void foo() {
6
		outer: for (int i= 0; i < 3; i++) {
7
			/*[*/
8
			for (int j= 0; j < 3; j++) {
9
				for (int k= 0; k < 3; k++) {
10
					if(j == 3) {
11
						continue outer;
12
					}
13
					System.out.println();
14
				}
15
			}
16
			/*]*/
17
		}
18
	}
19
}
20
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_out/A_test769.java (+20 lines)
Added Link Here
1
package branch_out;
2
3
public class A_test769 {
4
5
	public void foo(int[] a) {
6
		for(int i : a) {
7
			extracted(i);
8
		}
9
	}
10
11
	protected void extracted(int i) {
12
		/*[*/
13
		if( i == 3 ) {
14
			return;
15
		}
16
		System.out.println();
17
		/*]*/
18
	}
19
}
20
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_out/A_test765.java (+24 lines)
Added Link Here
1
package branch_out;
2
3
public class A_test765 {
4
5
	public void foo() {
6
		int x = 0;
7
		for (int i= 0; i < 3; i++) {
8
			x = extracted(x, i);
9
		}
10
		System.out.println(x);
11
	}
12
13
	protected int extracted(int x, int i) {
14
		/*[*/
15
		if(i == 2) {
16
			x = (i*3);
17
			return x;
18
		}
19
		System.out.println();
20
		/*]*/
21
		return x;
22
	}
23
}
24
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_out/A_test764.java (+24 lines)
Added Link Here
1
package branch_out;
2
3
public class A_test764 {
4
5
	public void foo() {
6
		int x = 0;
7
		for (int i= 0; i < 3; i++) {
8
			x = extracted(x, i);
9
		}
10
		System.out.println(x);
11
	}
12
13
	protected int extracted(int x, int i) {
14
		/*[*/
15
		if(i == 2) {
16
			x = 2;
17
			return x;
18
		}
19
		System.out.println();
20
		/*]*/
21
		return x;
22
	}
23
}
24
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_in/A_test758.java (+18 lines)
Added Link Here
1
package branch_in;
2
3
import java.util.List;
4
5
public class A_test758 {
6
7
	public void foo(List a) {
8
		/*[*/
9
		for (Object x : a) {
10
			if(x == null) {
11
				continue;
12
			}
13
			System.out.println();
14
		}
15
		/*]*/
16
	}
17
}
18
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_out/A_test758.java (+22 lines)
Added Link Here
1
package branch_out;
2
3
import java.util.List;
4
5
public class A_test758 {
6
7
	public void foo(List a) {
8
		extracted(a);
9
	}
10
11
	protected void extracted(List a) {
12
		/*[*/
13
		for (Object x : a) {
14
			if(x == null) {
15
				continue;
16
			}
17
			System.out.println();
18
		}
19
		/*]*/
20
	}
21
}
22
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_out/A_test767.java (+22 lines)
Added Link Here
1
package branch_out;
2
3
public class A_test767 {
4
5
	public void foo() {
6
		for (int i = 0; i < 3; i++) {
7
			extracted();
8
		}
9
	}
10
11
	protected void extracted() {
12
		/*[*/
13
		inner: for (int j = 0; j < 10; j++) {
14
			if (j == 2) {
15
				System.out.println();
16
				continue inner;
17
			}
18
		}
19
		/*]*/
20
	}
21
}
22
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_in/A_test756.java (+16 lines)
Added Link Here
1
package branch_in;
2
3
public class A_test756 {
4
5
	public void foo() {
6
		for (int i= 0; i < 3; i++) {
7
			/*[*/
8
			if(i == 2) {
9
				continue;
10
			}
11
			System.out.println();
12
			/*]*/
13
		}
14
	}
15
}
16
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_in/A_test769.java (+16 lines)
Added Link Here
1
package branch_in;
2
3
public class A_test769 {
4
5
	public void foo(int[] a) {
6
		for(int i : a) {
7
			/*[*/
8
			if( i == 3 ) {
9
				continue;
10
			}
11
			System.out.println();
12
			/*]*/
13
		}
14
	}
15
}
16
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_in/A_test761.java (+18 lines)
Added Link Here
1
package branch_in;
2
3
public class A_test761 {
4
5
	public void foo() {
6
		outer: for (int i= 0; i < 3; i++) {
7
			/*[*/
8
			for (int j= 0; j < 3; j++) {
9
				if(j == 3) {
10
					continue outer;
11
				}
12
				System.out.println();
13
			}
14
			/*]*/
15
		}
16
	}
17
}
18
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_out/A_test763.java (+20 lines)
Added Link Here
1
package branch_out;
2
3
public class A_test763 {
4
5
	public void foo() {
6
		inner: for (int i= 0; i < 3; i++) {
7
			extracted(i);
8
		}
9
	}
10
11
	protected void extracted(int i) {
12
		/*[*/
13
		if(i == 2) {
14
			return;
15
		}
16
		System.out.println();
17
		/*]*/
18
	}
19
}
20
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_out/A_test766.java (+24 lines)
Added Link Here
1
package branch_out;
2
3
public class A_test766 {
4
5
	public void foo() {
6
		int x = 0;
7
		foo: for (int i= 0; i < 3; i++) {
8
			x = extracted(x, i);
9
		}
10
		System.out.println(x);
11
	}
12
13
	protected int extracted(int x, int i) {
14
		/*[*/
15
		if(i == 2) {
16
			x = (i*3);
17
			return x;
18
		}
19
		System.out.println();
20
		/*]*/
21
		return x;
22
	}
23
}
24
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_in/A_test764.java (+19 lines)
Added Link Here
1
package branch_in;
2
3
public class A_test764 {
4
5
	public void foo() {
6
		int x = 0;
7
		for (int i= 0; i < 3; i++) {
8
			/*[*/
9
			if(i == 2) {
10
				x = 2;
11
				continue;
12
			}
13
			System.out.println();
14
			/*]*/
15
		}
16
		System.out.println(x);
17
	}
18
}
19
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_out/A_test761.java (+22 lines)
Added Link Here
1
package branch_out;
2
3
public class A_test761 {
4
5
	public void foo() {
6
		outer: for (int i= 0; i < 3; i++) {
7
			extracted();
8
		}
9
	}
10
11
	protected void extracted() {
12
		/*[*/
13
		for (int j= 0; j < 3; j++) {
14
			if(j == 3) {
15
				return;
16
			}
17
			System.out.println();
18
		}
19
		/*]*/
20
	}
21
}
22
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_in/A_test767.java (+18 lines)
Added Link Here
1
package branch_in;
2
3
public class A_test767 {
4
5
	public void foo() {
6
		for (int i = 0; i < 3; i++) {
7
			/*[*/
8
			inner: for (int j = 0; j < 10; j++) {
9
				if (j == 2) {
10
					System.out.println();
11
					continue inner;
12
				}
13
			}
14
			/*]*/
15
		}
16
	}
17
}
18
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_out/A_test760.java (+20 lines)
Added Link Here
1
package branch_out;
2
3
public class A_test760 {
4
5
	public void foo(int a) {
6
		extracted(a);
7
	}
8
9
	protected void extracted(int a) {
10
		/*[*/
11
		do {
12
			if(a == 3) {
13
				continue;
14
			}
15
			System.out.println();
16
		} while (a > 0);
17
		/*]*/
18
	}
19
}
20
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_in/A_test760.java (+16 lines)
Added Link Here
1
package branch_in;
2
3
public class A_test760 {
4
5
	public void foo(int a) {
6
		/*[*/
7
		do {
8
			if(a == 3) {
9
				continue;
10
			}
11
			System.out.println();
12
		} while (a > 0);
13
		/*]*/
14
	}
15
}
16
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_out/A_test759.java (+20 lines)
Added Link Here
1
package branch_out;
2
3
public class A_test759 {
4
5
	public void foo(int a) {
6
		extracted(a);
7
	}
8
9
	protected void extracted(int a) {
10
		/*[*/
11
		while (a > 0) {
12
			if(a == 3) {
13
				continue;
14
			}
15
			System.out.println();
16
		}
17
		/*]*/
18
	}
19
}
20
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_in/A_test757.java (+16 lines)
Added Link Here
1
package branch_in;
2
3
public class A_test757 {
4
5
	public void foo() {
6
		/*[*/
7
		for (int i= 0; i < 3; i++) {
8
			if(i == 2) {
9
				continue;
10
			}
11
			System.out.println();
12
		}
13
		/*]*/
14
	}
15
}
16
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_in/A_test768.java (+17 lines)
Added Link Here
1
package branch_in;
2
3
public class A_test768 {
4
5
	public void foo() {
6
		int i = 0;
7
		do {
8
			/*[*/
9
			if( i == 3 ) {
10
				continue;
11
			}
12
			System.out.println();
13
			/*]*/
14
		} while ( i < 10 );
15
	}
16
}
17
(-)resources/ExtractMethodWorkSpace/ExtractMethodTests/branch_out/A_test756.java (+20 lines)
Added Link Here
1
package branch_out;
2
3
public class A_test756 {
4
5
	public void foo() {
6
		for (int i= 0; i < 3; i++) {
7
			extracted(i);
8
		}
9
	}
10
11
	protected void extracted(int i) {
12
		/*[*/
13
		if(i == 2) {
14
			return;
15
		}
16
		System.out.println();
17
		/*]*/
18
	}
19
}
20

Return to bug 48056