Skip to content

Commit 908db7a

Browse files
committed
refactor: Replace custom readLibraryText with standard VFS readText extension
1 parent 58ba2dd commit 908db7a

2 files changed

Lines changed: 3 additions & 8 deletions

File tree

src/main/kotlin/facet/MinecraftLibraryDetector.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import com.intellij.openapi.vfs.VirtualFile
2727
import com.intellij.psi.JavaPsiFacade
2828
import com.intellij.psi.search.FilenameIndex
2929
import com.intellij.psi.search.GlobalSearchScope
30-
import java.nio.charset.StandardCharsets
3130
import java.util.*
3231
import java.util.jar.Manifest
3332

@@ -102,10 +101,6 @@ fun hasLibraryManifest(scope: GlobalSearchScope, predicate: (Manifest) -> Boolea
102101
}.getOrDefault(false)
103102
}
104103

105-
fun VirtualFile.readLibraryText(): String? = runCatching {
106-
inputStream.reader(StandardCharsets.UTF_8).use { it.readText() }
107-
}.getOrNull()
108-
109104
private fun filesByName(name: String, scope: GlobalSearchScope): Collection<VirtualFile> =
110105
FilenameIndex.getVirtualFilesByName(name, scope)
111106

src/main/kotlin/platform/velocity/framework/VelocityPresentationProvider.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ package com.demonwav.mcdev.platform.velocity.framework
2222

2323
import com.demonwav.mcdev.facet.ClassMinecraftLibraryDetector
2424
import com.demonwav.mcdev.facet.hasLibraryFile
25-
import com.demonwav.mcdev.facet.readLibraryText
2625
import com.demonwav.mcdev.platform.PlatformType
2726
import com.intellij.openapi.project.Project
27+
import com.intellij.openapi.vfs.readText
2828
import com.intellij.psi.search.GlobalSearchScope
2929

3030
class VelocityLibraryDetector : ClassMinecraftLibraryDetector(
@@ -36,8 +36,8 @@ class VelocityLibraryDetector : ClassMinecraftLibraryDetector(
3636
override fun isLibraryPresent(project: Project, scope: GlobalSearchScope): Boolean =
3737
super.isLibraryPresent(project, scope) ||
3838
hasLibraryFile("javax.annotation.processing.Processor", annotationProcessorsPath, scope) { file ->
39-
file.readLibraryText()?.lineSequence()?.any {
39+
file.readText().lineSequence().any {
4040
it.trim() == "com.velocitypowered.api.plugin.ap.PluginAnnotationProcessor"
41-
} == true
41+
}
4242
}
4343
}

0 commit comments

Comments
 (0)