@@ -16,22 +16,26 @@ import com.intellij.framework.library.LibraryVersionProperties
1616import com.intellij.openapi.roots.libraries.LibraryPresentationProvider
1717import com.intellij.openapi.vfs.VirtualFile
1818import java.io.BufferedReader
19+ import java.io.IOException
1920import java.util.jar.JarFile
2021
2122class VelocityPresentationProvider : LibraryPresentationProvider <LibraryVersionProperties >(VELOCITY_LIBRARY_KIND ) {
2223 override fun getIcon (properties : LibraryVersionProperties ? ) = PlatformAssets .VELOCITY_ICON
2324
2425 override fun detect (classesRoots : MutableList <VirtualFile >): LibraryVersionProperties ? {
2526 for (classesRoot in classesRoots) {
26- // Velocity API jar has no Manifest entries, so we search for their annotation processor instead
27- val registeredAPs = JarFile (classesRoot.localFile).use { jar ->
28- val aps = jar.getEntry(" META-INF/services/javax.annotation.processing.Processor" )
29- ? : return @use null
30- jar.getInputStream(aps).bufferedReader().use(BufferedReader ::readLines)
31- } ? : continue
27+ try {
28+ // Velocity API jar has no Manifest entries, so we search for their annotation processor instead
29+ val registeredAPs = JarFile (classesRoot.localFile).use { jar ->
30+ val aps = jar.getEntry(" META-INF/services/javax.annotation.processing.Processor" )
31+ ? : return @use null
32+ jar.getInputStream(aps).bufferedReader().use(BufferedReader ::readLines)
33+ } ? : continue
3234
33- if (registeredAPs.contains(" com.velocitypowered.api.plugin.ap.PluginAnnotationProcessor" )) {
34- return LibraryVersionProperties ()
35+ if (registeredAPs.contains(" com.velocitypowered.api.plugin.ap.PluginAnnotationProcessor" )) {
36+ return LibraryVersionProperties ()
37+ }
38+ } catch (ignored: IOException ) {
3539 }
3640 }
3741 return null
0 commit comments