Extracted method creating copy of type parameters (to reuse in SignaturesPropagationData).
This commit is contained in:
+2
-13
@@ -34,7 +34,6 @@ import org.jetbrains.jet.lang.types.TypeUtils;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -49,8 +48,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
private JetType altReturnType;
|
||||
private List<TypeParameterDescriptor> altTypeParameters;
|
||||
|
||||
private final Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters =
|
||||
new HashMap<TypeParameterDescriptor, TypeParameterDescriptorImpl>();
|
||||
private Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters;
|
||||
|
||||
public AlternativeMethodSignatureData(
|
||||
@NotNull PsiMethodWrapper method,
|
||||
@@ -70,16 +68,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
Project project = method.getPsiMethod().getProject();
|
||||
altFunDeclaration = JetPsiFactory.createFunction(project, signature);
|
||||
|
||||
for (TypeParameterDescriptor typeParameter : methodTypeParameters) {
|
||||
originalToAltTypeParameters.put(typeParameter,
|
||||
TypeParameterDescriptorImpl.createForFurtherModification(
|
||||
typeParameter.getContainingDeclaration(),
|
||||
typeParameter.getAnnotations(),
|
||||
typeParameter.isReified(),
|
||||
typeParameter.getVariance(),
|
||||
typeParameter.getName(),
|
||||
typeParameter.getIndex()));
|
||||
}
|
||||
originalToAltTypeParameters = SignaturesUtil.recreateTypeParametersAndReturnMapping(methodTypeParameters);
|
||||
|
||||
try {
|
||||
checkForSyntaxErrors(altFunDeclaration);
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.java.kotlinSignature;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptorImpl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class SignaturesUtil {
|
||||
public static Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> recreateTypeParametersAndReturnMapping(
|
||||
@NotNull List<TypeParameterDescriptor> originalParameters
|
||||
) {
|
||||
Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> result = Maps.newHashMap();
|
||||
for (TypeParameterDescriptor typeParameter : originalParameters) {
|
||||
result.put(typeParameter,
|
||||
TypeParameterDescriptorImpl.createForFurtherModification(
|
||||
typeParameter.getContainingDeclaration(),
|
||||
typeParameter.getAnnotations(),
|
||||
typeParameter.isReified(),
|
||||
typeParameter.getVariance(),
|
||||
typeParameter.getName(),
|
||||
typeParameter.getIndex()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private SignaturesUtil() {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user