Evaluate expression: add readAction during file analysis

This commit is contained in:
Natalia Ukhorskaya
2014-10-09 16:00:00 +04:00
parent 1055aa86aa
commit db86ade5fb
@@ -140,7 +140,7 @@ class KotlinEvaluator(val codeFragment: JetCodeFragment,
class object { class object {
private fun extractAndCompile(codeFragment: JetCodeFragment, sourcePosition: SourcePosition): CompiledDataDescriptor { private fun extractAndCompile(codeFragment: JetCodeFragment, sourcePosition: SourcePosition): CompiledDataDescriptor {
codeFragment.checkForErrors(codeFragment.getAnalysisResults()) codeFragment.checkForErrors()
val extractedFunction = getFunctionForExtractedFragment(codeFragment, sourcePosition.getFile(), sourcePosition.getLine()) val extractedFunction = getFunctionForExtractedFragment(codeFragment, sourcePosition.getFile(), sourcePosition.getLine())
if (extractedFunction == null) { if (extractedFunction == null) {
@@ -232,9 +232,9 @@ class KotlinEvaluator(val codeFragment: JetCodeFragment,
return runReadAction { return runReadAction {
val file = createFileForDebugger(codeFragment, extractedFunction) val file = createFileForDebugger(codeFragment, extractedFunction)
val analyzeExhaust = file.getAnalysisResults() file.checkForErrors()
file.checkForErrors(analyzeExhaust)
val analyzeExhaust = file.getAnalysisResults()
val state = GenerationState( val state = GenerationState(
file.getProject(), file.getProject(),
ClassBuilderFactories.BINARIES, ClassBuilderFactories.BINARIES,
@@ -259,7 +259,7 @@ class KotlinEvaluator(val codeFragment: JetCodeFragment,
throw EvaluateExceptionUtil.createEvaluateException(e) throw EvaluateExceptionUtil.createEvaluateException(e)
} }
private fun JetFile.checkForErrors(analyzeExhaust: AnalyzeExhaust) { private fun JetFile.checkForErrors() {
runReadAction { runReadAction {
try { try {
AnalyzingUtils.checkForSyntacticErrors(this) AnalyzingUtils.checkForSyntacticErrors(this)
@@ -268,16 +268,14 @@ class KotlinEvaluator(val codeFragment: JetCodeFragment,
throw EvaluateExceptionUtil.createEvaluateException(e.getMessage()) throw EvaluateExceptionUtil.createEvaluateException(e.getMessage())
} }
val analyzeExhaust = this.getAnalysisResults()
if (analyzeExhaust.isError()) { if (analyzeExhaust.isError()) {
throw EvaluateExceptionUtil.createEvaluateException(analyzeExhaust.getError()) throw EvaluateExceptionUtil.createEvaluateException(analyzeExhaust.getError())
} }
val bindingContext = analyzeExhaust.getBindingContext() val bindingContext = analyzeExhaust.getBindingContext()
bindingContext.getDiagnostics().forEach { bindingContext.getDiagnostics().firstOrNull { it.getSeverity() == Severity.ERROR }?.let {
diagnostic -> throw EvaluateExceptionUtil.createEvaluateException(DefaultErrorMessages.RENDERER.render(it))
if (diagnostic.getSeverity() == Severity.ERROR) {
throw EvaluateExceptionUtil.createEvaluateException(DefaultErrorMessages.RENDERER.render(diagnostic))
}
} }
} }
} }