@@ -33,19 +33,17 @@ class JarClassContentProvider(
33
33
* contents.
34
34
* If the file is inside a source JAR, the source code is returned as is.
35
35
*/
36
- public fun contentOf (uri : KlsURI , source : Boolean ): Pair <KlsURI , String > {
36
+ public fun contentOf (uri : KlsURI ): Pair <KlsURI , String > {
37
37
val key = uri.toString()
38
38
val (contents, extension) = cachedContents[key] ? : run {
39
39
LOG .info(" Finding contents of {}" , describeURI(uri.fileUri))
40
- tryReadContentOf(uri, source )
41
- ? : tryReadContentOf(uri.withFileExtension(" class" ), source )
42
- ? : tryReadContentOf(uri.withFileExtension(" java" ), source )
43
- ? : tryReadContentOf(uri.withFileExtension(" kt" ), source )
40
+ tryReadContentOf(uri)
41
+ ? : tryReadContentOf(uri.withFileExtension(" class" ))
42
+ ? : tryReadContentOf(uri.withFileExtension(" java" ))
43
+ ? : tryReadContentOf(uri.withFileExtension(" kt" ))
44
44
? : throw KotlinLSException (" Could not find $uri " )
45
- }.also {
46
- cachedContents[key] = Pair (it.first, it.second)
47
- }
48
- val sourceURI = uri.withFileExtension(extension).withSource(source)
45
+ }.also { cachedContents[key] = it }
46
+ val sourceURI = uri.withFileExtension(extension)
49
47
return Pair (sourceURI, contents)
50
48
}
51
49
@@ -55,17 +53,16 @@ class JarClassContentProvider(
55
53
javaCode
56
54
}
57
55
58
- private fun tryReadContentOf (uri : KlsURI , source : Boolean ): Pair <String , String >? = try {
59
- val actualUri = uri.withoutQuery()
60
- when (actualUri.fileExtension) {
61
- " class" -> Pair (actualUri.extractToTemporaryFile(tempDir)
56
+ private fun tryReadContentOf (uri : KlsURI ): Pair <String , String >? = try {
57
+ when (uri.fileExtension) {
58
+ " class" -> Pair (uri.extractToTemporaryFile(tempDir)
62
59
.let (decompiler::decompileClass)
63
60
.let { Files .newInputStream(it) }
64
61
.bufferedReader()
65
62
.use(BufferedReader ::readText)
66
63
.let (this ::convertToKotlinIfNeeded), if (config.autoConvertToKotlin) " kt" else " java" )
67
- " java" -> if (source) Pair (actualUri .readContents(), " java" ) else Pair (convertToKotlinIfNeeded(actualUri .readContents()), " kt" )
68
- else -> Pair (actualUri .readContents(), " kt" ) // e.g. for Kotlin source files
64
+ " java" -> if (uri. source) Pair (uri .readContents(), " java" ) else Pair (convertToKotlinIfNeeded(uri .readContents()), " kt" )
65
+ else -> Pair (uri .readContents(), " kt" ) // e.g. for Kotlin source files
69
66
}
70
67
} catch (e: FileNotFoundException ) { null }
71
68
}
0 commit comments