Rename: ClassKind.TRAIT -> ClassKind.INTERFACE
This commit is contained in:
+1
-1
@@ -487,7 +487,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
|||||||
val openMod = if (open) "open " else ""
|
val openMod = if (open) "open " else ""
|
||||||
val innerMod = if (inner) "inner " else ""
|
val innerMod = if (inner) "inner " else ""
|
||||||
val typeParamList = when (kind) {
|
val typeParamList = when (kind) {
|
||||||
ClassKind.PLAIN_CLASS, ClassKind.TRAIT -> "<>"
|
ClassKind.PLAIN_CLASS, ClassKind.INTERFACE -> "<>"
|
||||||
else -> ""
|
else -> ""
|
||||||
}
|
}
|
||||||
psiFactory.createDeclaration<JetClassOrObject>(
|
psiFactory.createDeclaration<JetClassOrObject>(
|
||||||
|
|||||||
+2
-2
@@ -38,12 +38,12 @@ public object CreateClassFromTypeReferenceActionFactory : CreateClassFromUsageFa
|
|||||||
val typeRefParent = element.parent?.parent
|
val typeRefParent = element.parent?.parent
|
||||||
if (typeRefParent is JetConstructorCalleeExpression) return Collections.emptyList()
|
if (typeRefParent is JetConstructorCalleeExpression) return Collections.emptyList()
|
||||||
|
|
||||||
val traitExpected = typeRefParent is JetDelegatorToSuperClass
|
val interfaceExpected = typeRefParent is JetDelegatorToSuperClass
|
||||||
|
|
||||||
val isQualifier = (element.parent as? JetUserType)?.let { it.qualifier == element } ?: false
|
val isQualifier = (element.parent as? JetUserType)?.let { it.qualifier == element } ?: false
|
||||||
|
|
||||||
return when {
|
return when {
|
||||||
traitExpected -> Collections.singletonList(ClassKind.TRAIT)
|
interfaceExpected -> Collections.singletonList(ClassKind.INTERFACE)
|
||||||
else -> ClassKind.values().filter {
|
else -> ClassKind.values().filter {
|
||||||
val noTypeArguments = element.typeArgumentsAsTypes.isEmpty()
|
val noTypeArguments = element.typeArgumentsAsTypes.isEmpty()
|
||||||
when (it) {
|
when (it) {
|
||||||
|
|||||||
+2
-2
@@ -43,7 +43,7 @@ enum class ClassKind(val keyword: String, val description: String) {
|
|||||||
ENUM_CLASS("enum class", "enum"),
|
ENUM_CLASS("enum class", "enum"),
|
||||||
ENUM_ENTRY("", "enum constant"),
|
ENUM_ENTRY("", "enum constant"),
|
||||||
ANNOTATION_CLASS("annotation class", "annotation"),
|
ANNOTATION_CLASS("annotation class", "annotation"),
|
||||||
TRAIT("interface", "interface"),
|
INTERFACE("interface", "interface"),
|
||||||
OBJECT("object", "object"),
|
OBJECT("object", "object"),
|
||||||
DEFAULT("", "") // Used as a placeholder and must be replaced with one of the kinds above
|
DEFAULT("", "") // Used as a placeholder and must be replaced with one of the kinds above
|
||||||
}
|
}
|
||||||
@@ -119,7 +119,7 @@ public class CreateClassFromUsageFix<E : JetElement>(
|
|||||||
|
|
||||||
val constructorInfo = PrimaryConstructorInfo(classInfo, expectedTypeInfo)
|
val constructorInfo = PrimaryConstructorInfo(classInfo, expectedTypeInfo)
|
||||||
val builder = CallableBuilderConfiguration(
|
val builder = CallableBuilderConfiguration(
|
||||||
Collections.singletonList(constructorInfo), element as JetElement, file, editor, false, kind == PLAIN_CLASS || kind == TRAIT
|
Collections.singletonList(constructorInfo), element as JetElement, file, editor, false, kind == PLAIN_CLASS || kind == INTERFACE
|
||||||
).createBuilder()
|
).createBuilder()
|
||||||
builder.placement = CallablePlacement.NoReceiver(targetParent)
|
builder.placement = CallablePlacement.NoReceiver(targetParent)
|
||||||
project.executeCommand(text) { builder.build() }
|
project.executeCommand(text) { builder.build() }
|
||||||
|
|||||||
+2
-2
@@ -106,8 +106,8 @@ private fun JetExpression.getInheritableTypeInfo(
|
|||||||
return TypeInfo.ByType(type, Variance.OUT_VARIANCE).noSubstitutions() to { classKind ->
|
return TypeInfo.ByType(type, Variance.OUT_VARIANCE).noSubstitutions() to { classKind ->
|
||||||
when (classKind) {
|
when (classKind) {
|
||||||
ClassKind.ENUM_ENTRY -> isEnum && containingDeclaration == DescriptorToSourceUtils.descriptorToDeclaration(descriptor)
|
ClassKind.ENUM_ENTRY -> isEnum && containingDeclaration == DescriptorToSourceUtils.descriptorToDeclaration(descriptor)
|
||||||
ClassKind.TRAIT -> containingDeclaration !is PsiClass
|
ClassKind.INTERFACE -> containingDeclaration !is PsiClass
|
||||||
|| (descriptor as? ClassDescriptor)?.getKind() == ClassDescriptorKind.INTERFACE
|
|| (descriptor as? ClassDescriptor)?.getKind() == ClassDescriptorKind.INTERFACE
|
||||||
else -> canHaveSubtypes
|
else -> canHaveSubtypes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user