Evaluate expression: rethrow exceptions from evaluate expression
This commit is contained in:
@@ -63,6 +63,7 @@ import org.jetbrains.jet.lang.psi.codeFragmentUtil.setSkipVisibilityCheck
|
|||||||
import org.jetbrains.jet.lang.psi.JetBlockCodeFragment
|
import org.jetbrains.jet.lang.psi.JetBlockCodeFragment
|
||||||
import org.jetbrains.jet.lang.psi.JetExpression
|
import org.jetbrains.jet.lang.psi.JetExpression
|
||||||
import org.jetbrains.jet.plugin.refactoring.extractFunction.AnalysisResult.Status
|
import org.jetbrains.jet.plugin.refactoring.extractFunction.AnalysisResult.Status
|
||||||
|
import com.intellij.openapi.diagnostic.Logger
|
||||||
|
|
||||||
object KotlinEvaluationBuilder: EvaluatorBuilder {
|
object KotlinEvaluationBuilder: EvaluatorBuilder {
|
||||||
override fun build(codeFragment: PsiElement, position: SourcePosition?): ExpressionEvaluator {
|
override fun build(codeFragment: PsiElement, position: SourcePosition?): ExpressionEvaluator {
|
||||||
@@ -81,10 +82,13 @@ object KotlinEvaluationBuilder: EvaluatorBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val logger = Logger.getInstance(javaClass<KotlinEvaluator>())
|
||||||
|
|
||||||
class KotlinEvaluator(val codeFragment: JetCodeFragment,
|
class KotlinEvaluator(val codeFragment: JetCodeFragment,
|
||||||
val sourcePosition: SourcePosition
|
val sourcePosition: SourcePosition
|
||||||
) : Evaluator {
|
) : Evaluator {
|
||||||
override fun evaluate(context: EvaluationContextImpl): Any? {
|
override fun evaluate(context: EvaluationContextImpl): Any? {
|
||||||
|
try {
|
||||||
val extractedFunction = getFunctionForExtractedFragment(codeFragment, sourcePosition.getFile(), sourcePosition.getLine())
|
val extractedFunction = getFunctionForExtractedFragment(codeFragment, sourcePosition.getFile(), sourcePosition.getLine())
|
||||||
if (extractedFunction == null) {
|
if (extractedFunction == null) {
|
||||||
exception("This code fragment cannot be extracted to function")
|
exception("This code fragment cannot be extracted to function")
|
||||||
@@ -129,6 +133,15 @@ class KotlinEvaluator(val codeFragment: JetCodeFragment,
|
|||||||
|
|
||||||
return resultValue!!.asJdiValue(virtualMachine, resultValue!!.asmType)
|
return resultValue!!.asJdiValue(virtualMachine, resultValue!!.asmType)
|
||||||
}
|
}
|
||||||
|
catch(e: EvaluateException) {
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
catch (e: Exception) {
|
||||||
|
logger.error(e)
|
||||||
|
val cause = if (e.getMessage() != null) ": ${e.getMessage()}" else ""
|
||||||
|
exception("An exception occurs during Evaluate Expression Action $cause")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun getModifier(): Modifier? {
|
override fun getModifier(): Modifier? {
|
||||||
return null
|
return null
|
||||||
|
|||||||
Reference in New Issue
Block a user