|
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2000, 2012 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2013, 2012 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 |
|
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] 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] 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 |
| 13 |
*******************************************************************************/ |
14 |
*******************************************************************************/ |
| 14 |
package org.eclipse.jdt.internal.corext.refactoring.code; |
15 |
package org.eclipse.jdt.internal.corext.refactoring.code; |
| 15 |
|
16 |
|
|
Link Here
|
| 988 |
} |
989 |
} |
| 989 |
} |
990 |
} |
| 990 |
|
991 |
|
| 991 |
ITypeBinding[] typeVariables= computeLocalTypeVariables(); |
992 |
ITypeBinding[] typeVariables= computeLocalTypeVariables(modifiers); |
| 992 |
List<TypeParameter> typeParameters= result.typeParameters(); |
993 |
List<TypeParameter> typeParameters= result.typeParameters(); |
| 993 |
for (int i= 0; i < typeVariables.length; i++) { |
994 |
for (int i= 0; i < typeVariables.length; i++) { |
| 994 |
TypeParameter parameter= fAST.newTypeParameter(); |
995 |
TypeParameter parameter= fAST.newTypeParameter(); |
|
Link Here
|
| 1027 |
return result; |
1028 |
return result; |
| 1028 |
} |
1029 |
} |
| 1029 |
|
1030 |
|
| 1030 |
private ITypeBinding[] computeLocalTypeVariables() { |
1031 |
private ITypeBinding[] computeLocalTypeVariables(int modifier) { |
| 1031 |
List<ITypeBinding> result= new ArrayList<ITypeBinding>(Arrays.asList(fAnalyzer.getTypeVariables())); |
1032 |
List<ITypeBinding> result= new ArrayList<ITypeBinding>(Arrays.asList(fAnalyzer.getTypeVariables())); |
| 1032 |
for (int i= 0; i < fParameterInfos.size(); i++) { |
1033 |
for (int i= 0; i < fParameterInfos.size(); i++) { |
| 1033 |
ParameterInfo info= fParameterInfos.get(i); |
1034 |
ParameterInfo info= fParameterInfos.get(i); |
| 1034 |
processVariable(result, info.getOldBinding()); |
1035 |
processVariable(result, info.getOldBinding(), modifier); |
| 1035 |
} |
1036 |
} |
| 1036 |
IVariableBinding[] methodLocals= fAnalyzer.getMethodLocals(); |
1037 |
IVariableBinding[] methodLocals= fAnalyzer.getMethodLocals(); |
| 1037 |
for (int i= 0; i < methodLocals.length; i++) { |
1038 |
for (int i= 0; i < methodLocals.length; i++) { |
| 1038 |
processVariable(result, methodLocals[i]); |
1039 |
processVariable(result, methodLocals[i], modifier); |
| 1039 |
} |
1040 |
} |
| 1040 |
return result.toArray(new ITypeBinding[result.size()]); |
1041 |
return result.toArray(new ITypeBinding[result.size()]); |
| 1041 |
} |
1042 |
} |
| 1042 |
|
1043 |
|
| 1043 |
private void processVariable(List<ITypeBinding> result, IVariableBinding variable) { |
1044 |
private void processVariable(List<ITypeBinding> result, IVariableBinding variable, int modifier) { |
| 1044 |
if (variable == null) |
1045 |
if (variable == null) |
| 1045 |
return; |
1046 |
return; |
| 1046 |
ITypeBinding binding= variable.getType(); |
1047 |
ITypeBinding binding= variable.getType(); |
|
Link Here
|
| 1053 |
if (decl != null && decl.getParent() instanceof MethodDeclaration) { |
1054 |
if (decl != null && decl.getParent() instanceof MethodDeclaration) { |
| 1054 |
result.add(arg); |
1055 |
result.add(arg); |
| 1055 |
} |
1056 |
} |
|
|
1057 |
if(decl.getParent() instanceof TypeDeclaration && (modifier& Modifier.STATIC)==Modifier.STATIC){ |
| 1058 |
result.add(arg); |
| 1059 |
} |
| 1060 |
} |
| 1061 |
if(arg.isWildcardType() && arg.getBound()!=null && !result.contains(arg.getBound())){ |
| 1062 |
ASTNode decl= fRoot.findDeclaringNode(arg.getBound()); |
| 1063 |
if (decl != null && decl.getParent() instanceof MethodDeclaration) { |
| 1064 |
result.add(arg.getBound()); |
| 1065 |
} |
| 1066 |
if(decl.getParent() instanceof TypeDeclaration && (modifier& Modifier.STATIC)==Modifier.STATIC){ |
| 1067 |
result.add(arg.getBound()); |
| 1068 |
} |
| 1056 |
} |
1069 |
} |
| 1057 |
} |
1070 |
} |
| 1058 |
} |
1071 |
} |