@@ -35,7 +35,7 @@ class JarClassContentProvider(
35
35
* If the file is inside a source JAR, the source code is returned as is.
36
36
*/
37
37
public fun contentOf (uri : KlsURI ): Pair <KlsURI , String > {
38
- val resolvedUri = sourceJarProvider.fetchSourceJar(uri.jarPath)?.let (uri::withJarPath) ? : uri
38
+ val resolvedUri = sourceJarProvider.fetchSourceJar(uri.jarPath)?.let (uri.withSource( true ) ::withJarPath) ? : uri
39
39
val key = resolvedUri.toString()
40
40
val (contents, extension) = cachedContents[key] ? : run {
41
41
LOG .info(" Finding contents of {}" , describeURI(uri.fileUri))
@@ -56,15 +56,16 @@ class JarClassContentProvider(
56
56
}
57
57
58
58
private fun tryReadContentOf (uri : KlsURI ): Pair <String , String >? = try {
59
- when (uri.fileExtension) {
60
- " class" -> Pair (uri.extractToTemporaryFile(tempDir)
59
+ val actualUri = KlsURI (uri.fileUri, mapOf ())
60
+ when (actualUri.fileExtension) {
61
+ " class" -> Pair (actualUri.extractToTemporaryFile(tempDir)
61
62
.let (decompiler::decompileClass)
62
63
.let { Files .newInputStream(it) }
63
64
.bufferedReader()
64
65
.use(BufferedReader ::readText)
65
66
.let (this ::convertToKotlinIfNeeded), if (config.autoConvertToKotlin) " kt" else " java" )
66
- " java" -> if (uri.source) Pair (uri .readContents(), " java" ) else Pair (convertToKotlinIfNeeded(uri .readContents()), " kt" )
67
- else -> Pair (uri .readContents(), " kt" ) // e.g. for Kotlin source files
67
+ " java" -> if (uri.source) Pair (actualUri .readContents(), " java" ) else Pair (convertToKotlinIfNeeded(actualUri .readContents()), " kt" )
68
+ else -> Pair (actualUri .readContents(), " kt" ) // e.g. for Kotlin source files
68
69
}
69
70
} catch (e: FileNotFoundException ) { null }
70
71
}
0 commit comments