Extract Function: Do not report "non-denotable type" message on error types
This commit is contained in:
@@ -53,6 +53,7 @@ fun getFunctionForExtractedFragment(
|
|||||||
ErrorMessage.NO_CONTAINER -> "Cannot perform an action at this breakpoint ${breakpointFile.getName()}:${breakpointLine}"
|
ErrorMessage.NO_CONTAINER -> "Cannot perform an action at this breakpoint ${breakpointFile.getName()}:${breakpointLine}"
|
||||||
ErrorMessage.SUPER_CALL -> "Cannot perform an action for expression with super call"
|
ErrorMessage.SUPER_CALL -> "Cannot perform an action for expression with super call"
|
||||||
ErrorMessage.DENOTABLE_TYPES -> "Cannot perform an action because following types are unavailable from debugger scope"
|
ErrorMessage.DENOTABLE_TYPES -> "Cannot perform an action because following types are unavailable from debugger scope"
|
||||||
|
ErrorMessage.ERROR_TYPES -> "Cannot perform an action because this code fragment contains erroneous types"
|
||||||
ErrorMessage.MULTIPLE_OUTPUT -> "Cannot perform an action because this code fragment changes more than one variable"
|
ErrorMessage.MULTIPLE_OUTPUT -> "Cannot perform an action because this code fragment changes more than one variable"
|
||||||
ErrorMessage.DECLARATIONS_OUT_OF_SCOPE,
|
ErrorMessage.DECLARATIONS_OUT_OF_SCOPE,
|
||||||
ErrorMessage.OUTPUT_AND_EXIT_POINT,
|
ErrorMessage.OUTPUT_AND_EXIT_POINT,
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ declarations.will.move.out.of.scope=Following declarations won't be available ou
|
|||||||
cannot.extract.super.call=Cannot extract super-call
|
cannot.extract.super.call=Cannot extract super-call
|
||||||
cannot.refactor.expression.should.have.inferred.type=Expression should have inferred type
|
cannot.refactor.expression.should.have.inferred.type=Expression should have inferred type
|
||||||
cannot.refactor.synthesized.function=Cannot refactor synthesized function ''{0}''
|
cannot.refactor.synthesized.function=Cannot refactor synthesized function ''{0}''
|
||||||
|
error.types.in.generated.function=Cannot generate function with erroneous return type
|
||||||
|
|
||||||
error.wrong.caret.position.function.or.constructor.name=The caret should be positioned at the name of the function or constructor to be refactored.
|
error.wrong.caret.position.function.or.constructor.name=The caret should be positioned at the name of the function or constructor to be refactored.
|
||||||
error.cant.refactor.vararg.functions=Can't refactor the function with variable arguments
|
error.cant.refactor.vararg.functions=Can't refactor the function with variable arguments
|
||||||
|
|||||||
@@ -180,6 +180,7 @@ class AnalysisResult (
|
|||||||
NO_CONTAINER
|
NO_CONTAINER
|
||||||
SUPER_CALL
|
SUPER_CALL
|
||||||
DENOTABLE_TYPES
|
DENOTABLE_TYPES
|
||||||
|
ERROR_TYPES
|
||||||
MULTIPLE_OUTPUT
|
MULTIPLE_OUTPUT
|
||||||
OUTPUT_AND_EXIT_POINT
|
OUTPUT_AND_EXIT_POINT
|
||||||
MULTIPLE_EXIT_POINTS
|
MULTIPLE_EXIT_POINTS
|
||||||
@@ -200,6 +201,7 @@ class AnalysisResult (
|
|||||||
NO_CONTAINER -> "cannot.refactor.no.container"
|
NO_CONTAINER -> "cannot.refactor.no.container"
|
||||||
SUPER_CALL -> "cannot.extract.super.call"
|
SUPER_CALL -> "cannot.extract.super.call"
|
||||||
DENOTABLE_TYPES -> "parameter.types.are.not.denotable"
|
DENOTABLE_TYPES -> "parameter.types.are.not.denotable"
|
||||||
|
ERROR_TYPES -> "error.types.in.generated.function"
|
||||||
MULTIPLE_OUTPUT -> "selected.code.fragment.has.multiple.output.values"
|
MULTIPLE_OUTPUT -> "selected.code.fragment.has.multiple.output.values"
|
||||||
OUTPUT_AND_EXIT_POINT -> "selected.code.fragment.has.output.values.and.exit.points"
|
OUTPUT_AND_EXIT_POINT -> "selected.code.fragment.has.output.values.and.exit.points"
|
||||||
MULTIPLE_EXIT_POINTS -> "selected.code.fragment.has.multiple.exit.points"
|
MULTIPLE_EXIT_POINTS -> "selected.code.fragment.has.multiple.exit.points"
|
||||||
|
|||||||
+9
-2
@@ -210,7 +210,11 @@ private fun ExtractionData.analyzeControlFlow(
|
|||||||
|
|
||||||
val typeOfDefaultFlow = defaultExits.getResultType(pseudocode, bindingContext, options)
|
val typeOfDefaultFlow = defaultExits.getResultType(pseudocode, bindingContext, options)
|
||||||
val returnValueType = valuedReturnExits.getResultType(pseudocode, bindingContext, options)
|
val returnValueType = valuedReturnExits.getResultType(pseudocode, bindingContext, options)
|
||||||
val defaultControlFlow = DefaultControlFlow(if (returnValueType.isMeaningful()) returnValueType else typeOfDefaultFlow, declarationsToCopy)
|
|
||||||
|
val defaultReturnType = if (returnValueType.isMeaningful()) returnValueType else typeOfDefaultFlow
|
||||||
|
if (defaultReturnType.isError()) return Pair(DefaultControlFlow(DEFAULT_RETURN_TYPE, declarationsToCopy), ErrorMessage.ERROR_TYPES)
|
||||||
|
|
||||||
|
val defaultControlFlow = DefaultControlFlow(defaultReturnType, declarationsToCopy)
|
||||||
|
|
||||||
if (declarationsToReport.isNotEmpty()) {
|
if (declarationsToReport.isNotEmpty()) {
|
||||||
val localVarStr = declarationsToReport.map { it.renderForMessage(bindingContext)!! }.distinct().sort()
|
val localVarStr = declarationsToReport.map { it.renderForMessage(bindingContext)!! }.distinct().sort()
|
||||||
@@ -357,6 +361,9 @@ private fun JetType.processTypeIfExtractable(
|
|||||||
typeToCheck.canBeReferencedViaImport() ->
|
typeToCheck.canBeReferencedViaImport() ->
|
||||||
extractable
|
extractable
|
||||||
|
|
||||||
|
typeToCheck.isError() ->
|
||||||
|
false
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
nonDenotableTypes.add(typeToCheck)
|
nonDenotableTypes.add(typeToCheck)
|
||||||
false
|
false
|
||||||
@@ -756,7 +763,7 @@ fun ExtractionDescriptor.getFunctionText(
|
|||||||
}
|
}
|
||||||
|
|
||||||
with(controlFlow.returnType) {
|
with(controlFlow.returnType) {
|
||||||
if (isDefault()) builder.noReturnType() else builder.returnType(descriptorRenderer.renderType(this))
|
if (isDefault() || isError()) builder.noReturnType() else builder.returnType(descriptorRenderer.renderType(this))
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.typeConstraints(typeParameters.flatMap { it.originalConstraints }.map { it.getText()!! })
|
builder.typeConstraints(typeParameters.flatMap { it.originalConstraints }.map { it.getText()!! })
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
Cannot extract method since following types are not denotable in the target scope: [ERROR : <ERROR FUNCTION RETURN TYPE>]
|
Cannot generate function with erroneous return type
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
Cannot extract method since following types are not denotable in the target scope: [ERROR : <ERROR FUNCTION RETURN TYPE>]
|
Cannot generate function with erroneous return type
|
||||||
Reference in New Issue
Block a user