How to register and use registerProblem in a thread?
已回答
overrid fun visitFile(file: PsiFile) {
if (!isOnTheFly) return
val yamlFileParser: YamlFileParser = YamlFileParser(file, holder)
val allPlugins = yamlFileParser.getAllPlugins()
println("project plugin size is ----> ${allPlugins.size}")
allPlugins.map {
// 使用线程防止UI阻塞
ApplicationManager.getApplication().executeOnPooledThread(){
yamlFileParser.getPubDataWithVersionName(it.name){ data->
println("get data success laset version is ${data.latest.version} , current version is ${it.currentVersion}")
if(data.latest.version!=it.currentVersion.replace("^","")){
/// 如果存在新版本,注册问题快速修复
it.newVersion = data.latest.version
ApplicationManager.getApplication().runReadAction {
println("register problem $it")
yamlFileParser.regProblemWithPluginData(it) // <------------Unable to register here,invalid
}
}
}
}
}
super.visitFile(file
This is my regProblemWithPluginData function
/**
* 注册一个问题解决方案
*/
fun regProblemWithPluginData(plugin: PluginVersion) {
val findElementAt = file.findElementAt(plugin.startIndex)!!
hodle.registerProblem(
findElementAt,
"当前插件有新版本:${plugin.newVersion}",
ProblemHighlightType.WARNING,
NewVersinFix(file.findElementAt(plugin.startIndex)!!, plugin.newVersion)
)
}
I want to use'hodle.registerProblem' to register to the editor in a thread, what should I do?
请先登录再写评论。
Why would you need to do that?