From 58b82baa2b358d01d1e7d61a444ce30ce8e4bb71 Mon Sep 17 00:00:00 2001 From: Natalia Ukhorskaya Date: Mon, 19 May 2014 20:03:00 +0400 Subject: [PATCH] Remove unnecessary error report from extract function --- .../jet/plugin/debugger/evaluate/KotlinEvaluationBuilder.kt | 1 - .../jet/plugin/refactoring/JetRefactoringBundle.properties | 1 - .../refactoring/extractFunction/ExtractionDescriptor.kt | 2 -- .../refactoring/extractFunction/extractFunctionUtils.kt | 4 +--- 4 files changed, 1 insertion(+), 7 deletions(-) diff --git a/idea/src/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluationBuilder.kt b/idea/src/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluationBuilder.kt index 9ea03fe288b..062b4e59d0e 100644 --- a/idea/src/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluationBuilder.kt +++ b/idea/src/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluationBuilder.kt @@ -316,7 +316,6 @@ private fun getFunctionForExtractedFragment( 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.MULTIPLE_OUTPUT -> "Cannot perform an action because this code fragment changes more than one variable" - ErrorMessage.NON_LOCAL_DECLARATION, ErrorMessage.DECLARATIONS_OUT_OF_SCOPE, ErrorMessage.OUTPUT_AND_EXIT_POINT, ErrorMessage.MULTIPLE_EXIT_POINTS, diff --git a/idea/src/org/jetbrains/jet/plugin/refactoring/JetRefactoringBundle.properties b/idea/src/org/jetbrains/jet/plugin/refactoring/JetRefactoringBundle.properties index 697d86843c6..6a6f680b914 100644 --- a/idea/src/org/jetbrains/jet/plugin/refactoring/JetRefactoringBundle.properties +++ b/idea/src/org/jetbrains/jet/plugin/refactoring/JetRefactoringBundle.properties @@ -16,7 +16,6 @@ selected.code.fragment.has.output.values.and.exit.points=Selected code fragment parameter.types.are.not.denotable=Cannot extract method since following types are not denotable in the target scope: declarations.will.move.out.of.scope=Following declarations won't be available outside of extracted function body: cannot.extract.super.call=Cannot extract super-call -cannot.extract.non.local.declaration.ref=Cannot extract reference to non-local declaration cannot.refactor.expression.should.have.inferred.type=Expression should have inferred type cannot.refactor.synthesized.function=Cannot refactor synthesized function ''{0}'' diff --git a/idea/src/org/jetbrains/jet/plugin/refactoring/extractFunction/ExtractionDescriptor.kt b/idea/src/org/jetbrains/jet/plugin/refactoring/extractFunction/ExtractionDescriptor.kt index 9f587189132..af38383c5e5 100644 --- a/idea/src/org/jetbrains/jet/plugin/refactoring/extractFunction/ExtractionDescriptor.kt +++ b/idea/src/org/jetbrains/jet/plugin/refactoring/extractFunction/ExtractionDescriptor.kt @@ -151,7 +151,6 @@ class AnalysisResult ( NO_EXPRESSION NO_CONTAINER SUPER_CALL - NON_LOCAL_DECLARATION DENOTABLE_TYPES MULTIPLE_OUTPUT OUTPUT_AND_EXIT_POINT @@ -171,7 +170,6 @@ class AnalysisResult ( NO_EXPRESSION -> "cannot.refactor.no.expresson" NO_CONTAINER -> "cannot.refactor.no.container" SUPER_CALL -> "cannot.extract.super.call" - NON_LOCAL_DECLARATION -> "cannot.extract.non.local.declaration.ref" DENOTABLE_TYPES -> "parameter.types.are.not.denotable" MULTIPLE_OUTPUT -> "selected.code.fragment.has.multiple.output.values" OUTPUT_AND_EXIT_POINT -> "selected.code.fragment.has.output.values.and.exit.points" diff --git a/idea/src/org/jetbrains/jet/plugin/refactoring/extractFunction/extractFunctionUtils.kt b/idea/src/org/jetbrains/jet/plugin/refactoring/extractFunction/extractFunctionUtils.kt index 17559e962df..25ffef82cc7 100644 --- a/idea/src/org/jetbrains/jet/plugin/refactoring/extractFunction/extractFunctionUtils.kt +++ b/idea/src/org/jetbrains/jet/plugin/refactoring/extractFunction/extractFunctionUtils.kt @@ -346,9 +346,7 @@ private fun ExtractionData.inferParametersInfo( if (hasClassObjectReceiver) thisDescriptor!!.getContainingDeclaration() as? ClassDescriptor else null if (classObjectClassDescriptor != null) { - if (!classObjectClassDescriptor.canBeReferencedViaImport()) { - return ErrorMessage.NON_LOCAL_DECLARATION - } + assert (classObjectClassDescriptor.canBeReferencedViaImport(), "Class object should be allowed only for importable classes: className = ${classObjectClassDescriptor.getName().asString()}") replacementMap[refInfo.offsetInBody] = FqNameReplacement(DescriptorUtils.getFqNameSafe(originalDescriptor)) }