Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 394030 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/generics_in/A_test1121.java (+11 lines)
Added Link Here
1
package generics_in;
2
import java.util.Map;
3
4
public class A_test1121<V> {
5
    public A_test1121(Map<?, ? extends V> c) {
6
        this(/*[*/c.size()/*]*/);
7
    }
8
9
    public A_test1121(int size) {
10
    }
11
}
(-)a/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/generics_in/A_test1122.java (+10 lines)
Added Link Here
1
package generics_in;
2
import java.util.ArrayList;
3
import java.util.List;
4
5
public class A_test1122{
6
	public <E> void foo() {
7
		List<? extends E> t = new ArrayList<E>();
8
		/*[*/t.size();/*]*/
9
	}
10
}
(-)a/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/generics_out/A_test1121.java (+15 lines)
Added Link Here
1
package generics_out;
2
import java.util.Map;
3
4
public class A_test1121<V> {
5
    public A_test1121(Map<?, ? extends V> c) {
6
        this(extracted(c));
7
    }
8
9
	protected static <V> int extracted(Map<?, ? extends V> c) {
10
		return /*[*/c.size()/*]*/;
11
	}
12
13
    public A_test1121(int size) {
14
    }
15
}
(-)a/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/generics_out/A_test1122.java (+14 lines)
Added Link Here
1
package generics_out;
2
import java.util.ArrayList;
3
import java.util.List;
4
5
public class A_test1122{
6
	public <E> void foo() {
7
		List<? extends E> t = new ArrayList<E>();
8
		extracted(t);
9
	}
10
11
	protected <E> void extracted(List<? extends E> t) {
12
		/*[*/t.size();/*]*/
13
	}
14
}
(-)a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests.java (+9 lines)
Lines 14-19 Link Here
14
 *     Benjamin Muskalla <bmuskalla@eclipsesource.com> - [extract method] should declare method static if extracted from anonymous in static method - https://bugs.eclipse.org/bugs/show_bug.cgi?id=152004
14
 *     Benjamin Muskalla <bmuskalla@eclipsesource.com> - [extract method] should declare method static if extracted from anonymous in static method - https://bugs.eclipse.org/bugs/show_bug.cgi?id=152004
15
 *     Benjamin Muskalla <bmuskalla@eclipsesource.com> - [extract method] extracting return value results in compile error - https://bugs.eclipse.org/bugs/show_bug.cgi?id=264606
15
 *     Benjamin Muskalla <bmuskalla@eclipsesource.com> - [extract method] extracting return value results in compile error - https://bugs.eclipse.org/bugs/show_bug.cgi?id=264606
16
 *     Samrat Dhillon <samrat.dhillon@gmail.com> -  [extract method] Extracted method should be declared static if extracted expression is also used in another static method https://bugs.eclipse.org/bugs/show_bug.cgi?id=393098
16
 *     Samrat Dhillon <samrat.dhillon@gmail.com> -  [extract method] Extracted method should be declared static if extracted expression is also used in another static method https://bugs.eclipse.org/bugs/show_bug.cgi?id=393098
17
 *     Samrat Dhillon <samrat.dhillon@gmail.com> -  [extract method] Extracting expression of parameterized type that is passed as argument to this constructor yields compilation error https://bugs.eclipse.org/bugs/show_bug.cgi?id=394030
17
 *******************************************************************************/
18
 *******************************************************************************/
18
package org.eclipse.jdt.ui.tests.refactoring;
19
package org.eclipse.jdt.ui.tests.refactoring;
19
20
Lines 2072-2077 Link Here
2072
	public void test1120() throws Exception {
2073
	public void test1120() throws Exception {
2073
		genericTest(); //https://bugs.eclipse.org/bugs/show_bug.cgi?id=369295
2074
		genericTest(); //https://bugs.eclipse.org/bugs/show_bug.cgi?id=369295
2074
	}
2075
	}
2076
	
2077
	public void test1121() throws Exception {
2078
		genericTest();
2079
	}
2080
	
2081
	public void test1122() throws Exception {
2082
		genericTest();
2083
	}
2075
2084
2076
	//---- Test enums ---------------------------------
2085
	//---- Test enums ---------------------------------
2077
2086
(-)a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractMethodRefactoring.java (-5 / +23 lines)
Lines 11-16 Link Here
11
 *     Benjamin Muskalla <bmuskalla@eclipsesource.com> - [extract method] Extract method and continue https://bugs.eclipse.org/bugs/show_bug.cgi?id=48056
11
 *     Benjamin Muskalla <bmuskalla@eclipsesource.com> - [extract method] Extract method and continue https://bugs.eclipse.org/bugs/show_bug.cgi?id=48056
12
 *     Benjamin Muskalla <bmuskalla@eclipsesource.com> - [extract method] should declare method static if extracted from anonymous in static method - https://bugs.eclipse.org/bugs/show_bug.cgi?id=152004
12
 *     Benjamin Muskalla <bmuskalla@eclipsesource.com> - [extract method] should declare method static if extracted from anonymous in static method - https://bugs.eclipse.org/bugs/show_bug.cgi?id=152004
13
 *     Samrat Dhillon <samrat.dhillon@gmail.com> -  [extract method] Extracted method should be declared static if extracted expression is also used in another static method https://bugs.eclipse.org/bugs/show_bug.cgi?id=393098
13
 *     Samrat Dhillon <samrat.dhillon@gmail.com> -  [extract method] Extracted method should be declared static if extracted expression is also used in another static method https://bugs.eclipse.org/bugs/show_bug.cgi?id=393098
14
 *     Samrat Dhillon <samrat.dhillon@gmail.com> -  [extract method] Extracting expression of parameterized type that is passed as argument to this constructor yields compilation error https://bugs.eclipse.org/bugs/show_bug.cgi?id=394030
14
 *******************************************************************************/
15
 *******************************************************************************/
15
package org.eclipse.jdt.internal.corext.refactoring.code;
16
package org.eclipse.jdt.internal.corext.refactoring.code;
16
17
Lines 1002-1008 Link Here
1002
			}
1003
			}
1003
		}
1004
		}
1004
1005
1005
		ITypeBinding[] typeVariables= computeLocalTypeVariables();
1006
		ITypeBinding[] typeVariables= computeLocalTypeVariables(modifiers);
1006
		List<TypeParameter> typeParameters= result.typeParameters();
1007
		List<TypeParameter> typeParameters= result.typeParameters();
1007
		for (int i= 0; i < typeVariables.length; i++) {
1008
		for (int i= 0; i < typeVariables.length; i++) {
1008
			TypeParameter parameter= fAST.newTypeParameter();
1009
			TypeParameter parameter= fAST.newTypeParameter();
Lines 1041-1060 Link Here
1041
		return result;
1042
		return result;
1042
	}
1043
	}
1043
1044
1044
	private ITypeBinding[] computeLocalTypeVariables() {
1045
	private ITypeBinding[] computeLocalTypeVariables(int modifier) {
1045
		List<ITypeBinding> result= new ArrayList<ITypeBinding>(Arrays.asList(fAnalyzer.getTypeVariables()));
1046
		List<ITypeBinding> result= new ArrayList<ITypeBinding>(Arrays.asList(fAnalyzer.getTypeVariables()));
1046
		for (int i= 0; i < fParameterInfos.size(); i++) {
1047
		for (int i= 0; i < fParameterInfos.size(); i++) {
1047
			ParameterInfo info= fParameterInfos.get(i);
1048
			ParameterInfo info= fParameterInfos.get(i);
1048
			processVariable(result, info.getOldBinding());
1049
			processVariable(result, info.getOldBinding(), modifier);
1049
		}
1050
		}
1050
		IVariableBinding[] methodLocals= fAnalyzer.getMethodLocals();
1051
		IVariableBinding[] methodLocals= fAnalyzer.getMethodLocals();
1051
		for (int i= 0; i < methodLocals.length; i++) {
1052
		for (int i= 0; i < methodLocals.length; i++) {
1052
			processVariable(result, methodLocals[i]);
1053
			processVariable(result, methodLocals[i], modifier);
1053
		}
1054
		}
1054
		return result.toArray(new ITypeBinding[result.size()]);
1055
		return result.toArray(new ITypeBinding[result.size()]);
1055
	}
1056
	}
1056
1057
1057
	private void processVariable(List<ITypeBinding> result, IVariableBinding variable) {
1058
	private void processVariable(List<ITypeBinding> result, IVariableBinding variable, int modifier) {
1058
		if (variable == null)
1059
		if (variable == null)
1059
			return;
1060
			return;
1060
		ITypeBinding binding= variable.getType();
1061
		ITypeBinding binding= variable.getType();
Lines 1066-1073 Link Here
1066
					ASTNode decl= fRoot.findDeclaringNode(arg);
1067
					ASTNode decl= fRoot.findDeclaringNode(arg);
1067
					if (decl != null && decl.getParent() instanceof MethodDeclaration) {
1068
					if (decl != null && decl.getParent() instanceof MethodDeclaration) {
1068
						result.add(arg);
1069
						result.add(arg);
1070
					}else{
1071
						if(decl != null && decl.getParent() instanceof TypeDeclaration && Modifier.isStatic(modifier)){
1072
							result.add(arg);
1073
						}
1074
					}
1075
				}else{
1076
					ITypeBinding bound =  arg.getBound();
1077
					if(arg.isWildcardType() && bound!=null && !result.contains(bound)){
1078
						ASTNode decl= fRoot.findDeclaringNode(bound);
1079
						if (decl != null && decl.getParent() instanceof MethodDeclaration) {
1080
							result.add(bound);
1081
						}else{
1082
							if(decl != null && decl.getParent() instanceof TypeDeclaration && Modifier.isStatic(modifier)){
1083
								result.add(bound);
1084
							}
1085
						}
1069
					}
1086
					}
1070
				}
1087
				}
1088
1071
			}
1089
			}
1072
		}
1090
		}
1073
	}
1091
	}

Return to bug 394030