Support PluginMainLineMarkerProvider for Java classes

This commit is contained in:
Him188 2021-02-03 21:31:31 +08:00
parent 8ac8089015
commit 6d02aa72d9
2 changed files with 11 additions and 2 deletions

View File

@ -0,0 +1,10 @@
package test;
import net.mamoe.mirai.console.plugin.jvm.JvmPluginDescription;
import org.jetbrains.annotations.NotNull;
public class TestJavaPlugin extends net.mamoe.mirai.console.plugin.jvm.JavaPlugin {
public TestJavaPlugin(@NotNull JvmPluginDescription description) {
super(description);
}
}

View File

@ -18,14 +18,13 @@ import net.mamoe.mirai.console.intellij.Icons
import net.mamoe.mirai.console.intellij.resolve.allSuperNames
import net.mamoe.mirai.console.intellij.resolve.getElementForLineMark
import net.mamoe.mirai.console.intellij.util.runIgnoringErrors
import org.jetbrains.kotlin.psi.KtObjectDeclaration
class PluginMainLineMarkerProvider : LineMarkerProvider {
override fun getLineMarkerInfo(element: PsiElement): LineMarkerInfo<*>? {
if (element !is KtObjectDeclaration) return null
runIgnoringErrors { // not showing icons is better than throwing exception every time doing inspection
if (element.allSuperNames.any { it == PLUGIN_FQ_NAME }) return Info(getElementForLineMark(element))
}
return null
}