Minor: Rename CreateFunctionFromUsageFix -> CreateCallableFromUsageFix
This commit is contained in:
+1
-1
@@ -38,6 +38,6 @@ public object CreateBinaryOperationActionFactory: JetSingleIntentionActionFactor
|
||||
else -> TypeInfo(callExpr, Variance.OUT_VARIANCE)
|
||||
}
|
||||
val parameters = Collections.singletonList(ParameterInfo(TypeInfo(argumentExpr, Variance.IN_VARIANCE)))
|
||||
return CreateFunctionFromUsageFix(callExpr, FunctionInfo(operationName, receiverType, returnType, Collections.emptyList(), parameters))
|
||||
return CreateCallableFromUsageFix(callExpr, FunctionInfo(operationName, receiverType, returnType, Collections.emptyList(), parameters))
|
||||
}
|
||||
}
|
||||
+10
-10
@@ -15,27 +15,27 @@ import org.jetbrains.jet.lang.psi.JetClassBody
|
||||
import org.jetbrains.jet.plugin.quickfix.createFromUsage.callableBuilder.*
|
||||
import org.jetbrains.jet.lang.psi.JetExpression
|
||||
|
||||
public class CreateFunctionFromUsageFix(
|
||||
public class CreateCallableFromUsageFix(
|
||||
originalExpression: JetExpression,
|
||||
val functionInfo: CallableInfo) : CreateFromUsageFixBase(originalExpression) {
|
||||
val callableInfo: CallableInfo) : CreateFromUsageFixBase(originalExpression) {
|
||||
override fun getText(): String {
|
||||
val key = when (functionInfo.kind) {
|
||||
val key = when (callableInfo.kind) {
|
||||
CallableKind.FUNCTION -> "create.function.from.usage"
|
||||
CallableKind.PROPERTY -> "create.property.from.usage"
|
||||
}
|
||||
return JetBundle.message(key, functionInfo.name)
|
||||
return JetBundle.message(key, callableInfo.name)
|
||||
}
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: JetFile?) {
|
||||
val functionBuilder = CallableBuilderConfiguration(functionInfo, element as JetExpression, file!!, editor!!).createBuilder()
|
||||
val callableBuilder = CallableBuilderConfiguration(callableInfo, element as JetExpression, file!!, editor!!).createBuilder()
|
||||
|
||||
fun runBuilder(placement: CallablePlacement) {
|
||||
functionBuilder.placement = placement
|
||||
CommandProcessor.getInstance().executeCommand(project, { functionBuilder.build() }, getText(), null)
|
||||
callableBuilder.placement = placement
|
||||
CommandProcessor.getInstance().executeCommand(project, { callableBuilder.build() }, getText(), null)
|
||||
}
|
||||
|
||||
val popupTitle = JetBundle.message("choose.target.class.or.trait.title")
|
||||
val receiverTypeCandidates = functionBuilder.computeTypeCandidates(functionInfo.receiverTypeInfo)
|
||||
val receiverTypeCandidates = callableBuilder.computeTypeCandidates(callableInfo.receiverTypeInfo)
|
||||
if (receiverTypeCandidates.isNotEmpty()) {
|
||||
val toPsi: (TypeCandidate) -> JetClassOrObject = {
|
||||
val descriptor = DescriptorUtils.getClassDescriptorForType(it.theType)
|
||||
@@ -46,9 +46,9 @@ public class CreateFunctionFromUsageFix(
|
||||
}
|
||||
}
|
||||
else {
|
||||
assert(functionInfo.receiverTypeInfo is TypeInfo.Empty, "No receiver type candidates: ${element.getText()} in ${file.getText()}")
|
||||
assert(callableInfo.receiverTypeInfo is TypeInfo.Empty, "No receiver type candidates: ${element.getText()} in ${file.getText()}")
|
||||
|
||||
chooseContainerElementIfNecessary(functionInfo.possibleContainers, editor, popupTitle, true, { it }) {
|
||||
chooseContainerElementIfNecessary(callableInfo.possibleContainers, editor, popupTitle, true, { it }) {
|
||||
val container = if (it is JetClassBody) it.getParent() as JetClassOrObject else it
|
||||
runBuilder(CallablePlacement.NoReceiver(container))
|
||||
}
|
||||
+1
-1
@@ -34,6 +34,6 @@ object CreateComponentFunctionActionFactory : JetSingleIntentionActionFactory()
|
||||
val entry = entries[componentNumber]
|
||||
val returnType = TypeInfo(entry, Variance.OUT_VARIANCE)
|
||||
|
||||
return CreateFunctionFromUsageFix(multiDeclaration!!, FunctionInfo(name.getIdentifier(), ownerType, returnType))
|
||||
return CreateCallableFromUsageFix(multiDeclaration!!, FunctionInfo(name.getIdentifier(), ownerType, returnType))
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -97,6 +97,6 @@ object CreateFunctionOrPropertyFromCallActionFactory : JetSingleIntentionActionF
|
||||
else -> return null
|
||||
}
|
||||
|
||||
return CreateFunctionFromUsageFix(callExpr, callableInfo)
|
||||
return CreateCallableFromUsageFix(callExpr, callableInfo)
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -20,6 +20,6 @@ object CreateGetFunctionActionFactory : JetSingleIntentionActionFactory() {
|
||||
}
|
||||
|
||||
val returnType = TypeInfo(accessExpr, Variance.OUT_VARIANCE)
|
||||
return CreateFunctionFromUsageFix(accessExpr, FunctionInfo("get", arrayType, returnType, Collections.emptyList(), parameters))
|
||||
return CreateCallableFromUsageFix(accessExpr, FunctionInfo("get", arrayType, returnType, Collections.emptyList(), parameters))
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -18,6 +18,6 @@ object CreateHasNextFunctionActionFactory : JetSingleIntentionActionFactory() {
|
||||
|
||||
val forExpr = QuickFixUtil.getParentElementOfType(diagnostic, javaClass<JetForExpression>()) ?: return null
|
||||
val returnType = TypeInfo(KotlinBuiltIns.getInstance().getBooleanType(), Variance.OUT_VARIANCE)
|
||||
return CreateFunctionFromUsageFix(forExpr, FunctionInfo("hasNext", ownerType, returnType))
|
||||
return CreateCallableFromUsageFix(forExpr, FunctionInfo("hasNext", ownerType, returnType))
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -30,6 +30,6 @@ object CreateInvokeFunctionActionFactory : JetSingleIntentionActionFactory() {
|
||||
}
|
||||
|
||||
val returnType = TypeInfo(callExpr, Variance.OUT_VARIANCE)
|
||||
return CreateFunctionFromUsageFix(callExpr, FunctionInfo("invoke", receiverType, returnType, Collections.emptyList(), parameters))
|
||||
return CreateCallableFromUsageFix(callExpr, FunctionInfo("invoke", receiverType, returnType, Collections.emptyList(), parameters))
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -32,6 +32,6 @@ object CreateIteratorFunctionActionFactory : JetSingleIntentionActionFactory() {
|
||||
val returnJetTypeArguments = Collections.singletonList(returnJetTypeParameterType)
|
||||
val newReturnJetType = JetTypeImpl(returnJetType.getAnnotations(), returnJetType.getConstructor(), returnJetType.isNullable(), returnJetTypeArguments, returnJetType.getMemberScope())
|
||||
val returnType = TypeInfo(newReturnJetType, Variance.OUT_VARIANCE)
|
||||
return CreateFunctionFromUsageFix(forExpr, FunctionInfo("iterator", iterableType, returnType))
|
||||
return CreateCallableFromUsageFix(forExpr, FunctionInfo("iterator", iterableType, returnType))
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -19,6 +19,6 @@ object CreateNextFunctionActionFactory : JetSingleIntentionActionFactory() {
|
||||
val forExpr = QuickFixUtil.getParentElementOfType(diagnostic, javaClass<JetForExpression>()) ?: return null
|
||||
val variableExpr: JetExpression = ((forExpr.getLoopParameter() ?: forExpr.getMultiParameter()) ?: return null) as JetExpression
|
||||
val returnType = TypeInfo(variableExpr, Variance.OUT_VARIANCE)
|
||||
return CreateFunctionFromUsageFix(forExpr, FunctionInfo("next", ownerType, returnType))
|
||||
return CreateCallableFromUsageFix(forExpr, FunctionInfo("next", ownerType, returnType))
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -28,6 +28,6 @@ object CreateSetFunctionActionFactory : JetSingleIntentionActionFactory() {
|
||||
parameters.add(ParameterInfo(valType, "value"))
|
||||
|
||||
val returnType = TypeInfo(KotlinBuiltIns.getInstance().getUnitType(), Variance.OUT_VARIANCE)
|
||||
return CreateFunctionFromUsageFix(accessExpr, FunctionInfo("set", arrayType, returnType, Collections.emptyList(), parameters))
|
||||
return CreateCallableFromUsageFix(accessExpr, FunctionInfo("set", arrayType, returnType, Collections.emptyList(), parameters))
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -23,6 +23,6 @@ public object CreateUnaryOperationActionFactory: JetSingleIntentionActionFactory
|
||||
|
||||
val receiverType = TypeInfo(receiverExpr, Variance.IN_VARIANCE)
|
||||
val returnType = if (incDec) TypeInfo.ByReceiverType(Variance.OUT_VARIANCE) else TypeInfo(callExpr, Variance.OUT_VARIANCE)
|
||||
return CreateFunctionFromUsageFix(callExpr, FunctionInfo(operationName.asString(), receiverType, returnType))
|
||||
return CreateCallableFromUsageFix(callExpr, FunctionInfo(operationName.asString(), receiverType, returnType))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user