Use lazy analysis for debug file

This commit is contained in:
Natalia Ukhorskaya
2014-04-11 15:48:01 +04:00
parent 45d78dae5a
commit fa482bca80
4 changed files with 68 additions and 14 deletions
@@ -21,15 +21,10 @@ import com.intellij.psi.PsiElement
import com.intellij.debugger.SourcePosition
import com.intellij.debugger.engine.evaluation.*
import com.intellij.debugger.engine.evaluation.expression.*
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM
import com.google.common.base.Predicates
import org.jetbrains.jet.lang.resolve.AnalyzingUtils
import org.jetbrains.jet.codegen.state.GenerationState
import org.jetbrains.jet.codegen.ClassBuilderFactories
import java.util.Collections
import com.intellij.psi.PsiFile
import org.jetbrains.jet.codegen.state.Progress
import org.jetbrains.jet.codegen.CompilationErrorHandler
import org.jetbrains.jet.codegen.KotlinCodegenFacade
import com.intellij.openapi.application.ApplicationManager
import com.intellij.testFramework.LightVirtualFile
@@ -48,13 +43,12 @@ import org.jetbrains.eval4j.jdi.asJdiValue
import org.jetbrains.eval4j.jdi.makeInitialFrame
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils
import org.jetbrains.jet.lang.resolve.name.FqName
import org.jetbrains.jet.plugin.caches.resolve.KotlinDeclarationsCache
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
import java.io.File
import org.jetbrains.jet.plugin.debugger.KotlinEditorTextProvider
import org.jetbrains.jet.OutputFileCollection
import org.jetbrains.jet.lang.psi.JetExpressionCodeFragment
import org.jetbrains.jet.lang.psi.JetExpressionCodeFragmentImpl
import org.jetbrains.jet.plugin.caches.resolve.getAnalysisResults
object KotlinEvaluationBuilder: EvaluatorBuilder {
override fun build(codeFragment: PsiElement, position: SourcePosition?): ExpressionEvaluator {
@@ -85,13 +79,7 @@ class KotlinEvaluator(val codeFragment: PsiElement) : Evaluator {
val file = createFileForDebugger(codeFragment)
val analyzeExhaust = AnalyzerFacadeForJVM.analyzeFilesWithJavaIntegrationAndCheckForErrors(
file.getProject(),
Collections.singletonList(file),
Predicates.alwaysTrue())
//val analyzeExhaust = AnalyzerFacadeWithCache.analyzeFileWithCache(file)
//analyzeExhaust.forceResolveAll()
val analyzeExhaust = file.getAnalysisResults()
val bindingContext = analyzeExhaust.getBindingContext()
try {
analyzeExhaust.throwIfError()
@@ -0,0 +1,7 @@
LineBreakpoint created at dependentOnFile.kt:5
!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !APP_PATH!\classes;!KOTLIN_RUNTIME!;!RT_JAR! dependentOnFile.DependentOnFilePackage
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
dependentOnFile.kt:4
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
Process finished with exit code 0
@@ -0,0 +1,54 @@
package dependentOnFile
fun main(args: Array<String>) {
//Breakpoint!
args.size
}
class TestClass {
fun testFun() = 1
class object {
val p = 1
}
}
fun testFun() = 1
fun Int.testExtFun() = 1
object TestObject {
val p = 1
}
val testVal = 1
val Int.testExtVal = 1
val testDelVal by Delegate()
class Delegate {
fun get(a: Any?, b: PropertyMetadata) = 1
}
// EXPRESSION: TestClass().testFun()
// RESULT: 1: I
// EXPRESSION: testFun()
// RESULT: 1: I
// EXPRESSION: TestObject.p
// RESULT: 1: I
// EXPRESSION: TestClass.p
// RESULT: 1: I
// EXPRESSION: 1.testExtFun()
// RESULT: 1: I
// EXPRESSION: testVal
// RESULT: 1: I
// EXPRESSION: 1.testExtVal
// RESULT: 1: I
//
// EXPRESSION: testDelVal
// RESULT: 1: I
@@ -51,6 +51,11 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat
doTest("idea/testData/debugger/tinyApp/src/evaluate/collections.kt");
}
@TestMetadata("dependentOnFile.kt")
public void testDependentOnFile() throws Exception {
doTest("idea/testData/debugger/tinyApp/src/evaluate/dependentOnFile.kt");
}
@TestMetadata("imports.kt")
public void testImports() throws Exception {
doTest("idea/testData/debugger/tinyApp/src/evaluate/imports.kt");