Debugger: quote package fqName properly. Fix muted tests
This commit is contained in:
committed by
Natalia Ukhorskaya
parent
d4fcb59965
commit
b73ce68dbd
@@ -57,6 +57,7 @@ import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
|
||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getJavaClassDescriptor
|
||||
import org.jetbrains.kotlin.idea.refactoring.quoteIfNeeded
|
||||
import org.jetbrains.kotlin.idea.refactoring.quoteSegmentsIfNeeded
|
||||
import org.jetbrains.kotlin.idea.debugger.evaluate.KotlinEvaluateExpressionCache.CompiledDataDescriptor
|
||||
import org.jetbrains.kotlin.idea.debugger.evaluate.KotlinEvaluateExpressionCache.ParametersDescriptor
|
||||
import org.jetbrains.kotlin.idea.debugger.evaluate.compilingEvaluator.loadClasses
|
||||
@@ -487,8 +488,8 @@ private fun createFileForDebugger(codeFragment: KtCodeFragment,
|
||||
importsFromContextFile + codeFragment.importsToString().split(KtCodeFragment.IMPORT_SEPARATOR).joinToString("\n")
|
||||
)
|
||||
|
||||
val packageFromContextFile = containingContextFile?.packageName?.let {
|
||||
if (it.isNotBlank()) "package ${it.quoteIfNeeded()}" else ""
|
||||
val packageFromContextFile = containingContextFile?.packageFqName?.let {
|
||||
if (!it.isRoot) "package ${it.quoteSegmentsIfNeeded()}" else ""
|
||||
} ?: ""
|
||||
fileText = fileText.replace("!PACKAGE!", packageFromContextFile)
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ import org.jetbrains.kotlin.idea.util.string.collapseSpaces
|
||||
import org.jetbrains.kotlin.j2k.ConverterSettings
|
||||
import org.jetbrains.kotlin.j2k.JavaToKotlinConverter
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.FqNameUnsafe
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.codeFragmentUtil.suppressDiagnosticsInDebugMode
|
||||
@@ -681,6 +682,10 @@ fun invokeOnceOnCommandFinish(action: () -> Unit) {
|
||||
|
||||
fun String.quoteIfNeeded(): String = if (KotlinNameSuggester.isIdentifier(this)) this else "`$this`"
|
||||
|
||||
fun FqName.quoteSegmentsIfNeeded(): String {
|
||||
return pathSegments().map { it.asString().quoteIfNeeded() }.joinToString(".")
|
||||
}
|
||||
|
||||
fun FqNameUnsafe.hasIdentifiersOnly(): Boolean = pathSegments().all { KotlinNameSuggester.isIdentifier(it.asString()) }
|
||||
|
||||
fun PsiNamedElement.isInterfaceClass(): Boolean = this is KtClass && isInterface() || this is PsiClass && isInterface
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
LineBreakpoint created at package.kt:6
|
||||
!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !OUTPUT_PATH!;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! package.PackageKt
|
||||
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
package.kt:6
|
||||
Compile bytecode for 1
|
||||
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
|
||||
Process finished with exit code 0
|
||||
@@ -0,0 +1,10 @@
|
||||
package `package`
|
||||
|
||||
// Check that package fq-name is correctly escaped
|
||||
fun main(args: Array<String>) {
|
||||
//Breakpoint!
|
||||
args.size()
|
||||
}
|
||||
|
||||
// EXPRESSION: 1
|
||||
// RESULT: 1: I
|
||||
+6
@@ -235,6 +235,12 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat
|
||||
doSingleBreakpointTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("package.kt")
|
||||
public void testPackage() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/package.kt");
|
||||
doSingleBreakpointTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("parametersOfInlineFun.kt")
|
||||
public void testParametersOfInlineFun() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/parametersOfInlineFun.kt");
|
||||
|
||||
Reference in New Issue
Block a user