|
21 | 21 | import com.intellij.refactoring.changeSignature.ParameterInfo;
|
22 | 22 | import org.jetbrains.annotations.NotNull;
|
23 | 23 | import org.jetbrains.annotations.Nullable;
|
| 24 | +import org.jetbrains.jet.lang.descriptors.FunctionDescriptor; |
24 | 25 | import org.jetbrains.jet.lang.psi.JetExpression;
|
25 | 26 | import org.jetbrains.jet.lang.psi.JetFunction;
|
26 | 27 | import org.jetbrains.jet.lang.psi.JetParameter;
|
27 |
| -import org.jetbrains.jet.lang.resolve.BindingContext; |
28 |
| -import org.jetbrains.jet.lang.resolve.name.Name; |
29 |
| -import org.jetbrains.jet.lang.resolve.scopes.JetScope; |
30 | 28 | import org.jetbrains.jet.lang.types.JetType;
|
31 | 29 | import org.jetbrains.jet.lexer.JetTokens;
|
32 |
| -import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage; |
33 | 30 | import org.jetbrains.jet.renderer.DescriptorRenderer;
|
34 | 31 |
|
35 | 32 | import java.util.List;
|
@@ -76,30 +73,20 @@ public String getName() {
|
76 | 73 | }
|
77 | 74 |
|
78 | 75 | public String getInheritedName(boolean isInherited, @Nullable PsiElement inheritedFunction, @NotNull JetMethodDescriptor baseFunction) {
|
79 |
| - if (!(inheritedFunction instanceof JetFunction)) |
80 |
| - return name; |
| 76 | + if (!(isInherited && inheritedFunction instanceof JetFunction)) return name; |
| 77 | + |
| 78 | + FunctionDescriptor baseFunctionDescriptor = baseFunction.getDescriptor(); |
| 79 | + assert baseFunctionDescriptor != null : "No descriptor for " + baseFunction.getMethod().getText(); |
81 | 80 |
|
82 | 81 | JetFunction inheritedJetFunction = (JetFunction) inheritedFunction;
|
83 | 82 | List<JetParameter> inheritedParameters = inheritedJetFunction.getValueParameters();
|
84 | 83 |
|
85 |
| - if (!isInherited || oldIndex < 0 || oldIndex >= baseFunction.getParametersCount() || oldIndex >= inheritedParameters.size()) |
86 |
| - return name; |
87 |
| - |
88 |
| - JetParameterInfo oldParam = baseFunction.getParameters().get(oldIndex); |
89 |
| - JetParameter inheritedParam = inheritedParameters.get(oldIndex); |
90 |
| - String inheritedParamName = inheritedParam.getName(); |
| 84 | + if (oldIndex < 0 || oldIndex >= baseFunction.getParametersCount() || oldIndex >= inheritedParameters.size()) return name; |
91 | 85 |
|
92 |
| - if (oldParam.getName().equals(inheritedParamName)) { |
93 |
| - BindingContext bindingContext = ResolvePackage.analyze(inheritedJetFunction); |
94 |
| - JetScope parametersScope = JetChangeSignatureUsageProcessor.getFunctionBodyScope(inheritedJetFunction, bindingContext); |
| 86 | + String inheritedParamName = inheritedParameters.get(oldIndex).getName(); |
| 87 | + String oldParamName = baseFunctionDescriptor.getValueParameters().get(oldIndex).getName().asString(); |
95 | 88 |
|
96 |
| - if (parametersScope != null && parametersScope.getLocalVariable(Name.identifier(name)) == null) |
97 |
| - return name; |
98 |
| - else |
99 |
| - return inheritedParamName; |
100 |
| - } |
101 |
| - else |
102 |
| - return inheritedParamName; |
| 89 | + return oldParamName.equals(inheritedParamName) ? name : inheritedParamName; |
103 | 90 | }
|
104 | 91 |
|
105 | 92 | @Override
|
|
0 commit comments