Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在2024.1 提示 ToggleProjectInspectionAction 使用了废弃方法,抽空更新一下呗 #43

Closed
wdkGitHub opened this issue Apr 7, 2024 · 7 comments · Fixed by #44

Comments

@wdkGitHub
Copy link

com.intellij.diagnostic.PluginException: `ActionUpdateThread.OLD_EDT` is deprecated and going to be removed soon. 'com.alibaba.p3c.idea.action.ToggleProjectInspectionAction' must override `getActionUpdateThread` and chose EDT or BGT. See ActionUpdateThread javadoc. [Plugin: io.github.godfather1103.alibaba.p3c]
	at com.intellij.diagnostic.PluginProblemReporterImpl.createPluginExceptionByClass(PluginProblemReporterImpl.java:23)
	at com.intellij.diagnostic.PluginException.createByClass(PluginException.java:90)
	at com.intellij.diagnostic.PluginException.reportDeprecatedUsage(PluginException.java:125)
	at com.intellij.openapi.actionSystem.ActionUpdateThreadAware.getActionUpdateThread(ActionUpdateThreadAware.java:21)
	at com.intellij.openapi.actionSystem.AnAction.getActionUpdateThread(AnAction.java:199)
@godfather1103
Copy link
Owner

有复现的方案吗?

@wdkGitHub
Copy link
Author

2024.1 打开项目就显示,看错误信息是用了将要删除的方法

@godfather1103
Copy link
Owner

每次都会报错?

@wdkGitHub
Copy link
Author

每次都会报错?

每次

@wdkGitHub
Copy link
Author

OpenAI 给的代码, 用2024.1项目没有构建成功 😂

package com.alibaba.p3c.idea.action

import com.alibaba.p3c.idea.compatible.inspection.InspectionProfileService
import com.alibaba.p3c.idea.compatible.inspection.Inspections
import com.alibaba.p3c.idea.config.SmartFoxProjectConfig
import com.alibaba.p3c.idea.i18n.P3cBundle
import com.alibaba.p3c.idea.inspection.AliBaseInspection
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.application.ApplicationManager
import icons.P3cIcons

/**
 * Open or close inspections
 *
 * @author caikang
 * @date 2017/03/14
 */
class ToggleProjectInspectionAction : AnAction() {

    private val textKey = "com.alibaba.p3c.idea.action.ToggleProjectInspectionAction.text"

    override fun actionPerformed(e: AnActionEvent) {
        ApplicationManager.getApplication().invokeLater {
            val project = e.project ?: return@invokeLater
            val smartFoxConfig = project.getService(SmartFoxProjectConfig::class.java)
            val tools = Inspections.aliInspections(project) { it.tool is AliBaseInspection }
            InspectionProfileService.toggleInspection(project, tools, smartFoxConfig.projectInspectionClosed)
            smartFoxConfig.projectInspectionClosed = !smartFoxConfig.projectInspectionClosed
        }
    }

    override fun update(e: AnActionEvent) {
        ApplicationManager.getApplication().invokeLater {
            val project = e.project ?: return@invokeLater
            val smartFoxConfig = project.getService(SmartFoxProjectConfig::class.java)
            if (smartFoxConfig.projectInspectionClosed) {
                e.presentation.icon = P3cIcons.PROJECT_INSPECTION_ON
                e.presentation.text = P3cBundle.getMessage("$textKey.open")
            } else {
                e.presentation.icon = P3cIcons.PROJECT_INSPECTION_OFF
                e.presentation.text = P3cBundle.getMessage("$textKey.close")
            }
        }
    }

    override fun getActionUpdateThread(e: AnActionEvent): ActionUpdateThread {
        return ActionUpdateThread.BGT
    }
}

@shuohao
Copy link

shuohao commented Apr 8, 2024

我这也报这个错 2024.1

@godfather1103 godfather1103 linked a pull request Apr 8, 2024 that will close this issue
Merged
@godfather1103
Copy link
Owner

上传了1.7版本,等待官方审核吧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants