Create from usage: Fixed an overly restrictive assertion.
This commit is contained in:
@@ -570,8 +570,7 @@ public class CreateMethodFromUsageFix extends CreateFromUsageFixBase {
|
|||||||
if (possibleClassDescriptor != null) {
|
if (possibleClassDescriptor != null) {
|
||||||
String className = DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(possibleClassDescriptor.getDefaultType());
|
String className = DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(possibleClassDescriptor.getDefaultType());
|
||||||
DeclarationDescriptor namespaceDescriptor = possibleClassDescriptor.getContainingDeclaration();
|
DeclarationDescriptor namespaceDescriptor = possibleClassDescriptor.getContainingDeclaration();
|
||||||
assert namespaceDescriptor instanceof NamespaceDescriptor;
|
String namespace = renderDescriptor(namespaceDescriptor, true);
|
||||||
String namespace = ((NamespaceDescriptor) namespaceDescriptor).getFqName().getFqName();
|
|
||||||
String option = className + " (" + namespace + ")";
|
String option = className + " (" + namespace + ")";
|
||||||
options.add(option);
|
options.add(option);
|
||||||
optionToTypeMap.put(option, ownerTypeCandidate);
|
optionToTypeMap.put(option, ownerTypeCandidate);
|
||||||
@@ -1025,14 +1024,16 @@ public class CreateMethodFromUsageFix extends CreateFromUsageFixBase {
|
|||||||
if (declarationDescriptor instanceof TypeParameterDescriptor) {
|
if (declarationDescriptor instanceof TypeParameterDescriptor) {
|
||||||
String replacement = typeParameterNameMap.get(declarationDescriptor);
|
String replacement = typeParameterNameMap.get(declarationDescriptor);
|
||||||
return replacement == null ? declarationDescriptor.getName().getName() : replacement;
|
return replacement == null ? declarationDescriptor.getName().getName() : replacement;
|
||||||
} else if (declarationDescriptor instanceof ClassDescriptor) {
|
|
||||||
return fq ? DescriptorUtils.getFQName(declarationDescriptor).getFqName() : declarationDescriptor.getName().getName();
|
|
||||||
} else {
|
} else {
|
||||||
assert false : "unexpected descriptor in type";
|
return fq ? DescriptorUtils.getFQName(declarationDescriptor).getFqName() : declarationDescriptor.getName().getName();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static String renderDescriptor(@NotNull DeclarationDescriptor declarationDescriptor, boolean fq) {
|
||||||
|
return renderDescriptor(declarationDescriptor, Collections.<TypeParameterDescriptor, String>emptyMap(), fq);
|
||||||
|
}
|
||||||
|
|
||||||
private static String renderType(@NotNull JetType type, @NotNull Map<TypeParameterDescriptor, String> typeParameterNameMap, boolean fq) {
|
private static String renderType(@NotNull JetType type, @NotNull Map<TypeParameterDescriptor, String> typeParameterNameMap, boolean fq) {
|
||||||
List<TypeProjection> projections = type.getArguments();
|
List<TypeProjection> projections = type.getArguments();
|
||||||
DeclarationDescriptor declarationDescriptor = type.getConstructor().getDeclarationDescriptor();
|
DeclarationDescriptor declarationDescriptor = type.getConstructor().getDeclarationDescriptor();
|
||||||
|
|||||||
Reference in New Issue
Block a user