簡體   English   中英

通過插件以編程方式刷新/同步IntelliJ IDEA項目

[英]Programmatically refresh/synchronize an IntelliJ IDEA project via a plugin

有沒有辦法通過插件以編程方式刷新/同步IntelliJ IDEA項目?

我正在開發一個IntelliJ IDEA插件,可以在活動項目中創建一個文件。 我想通過插件自動刷新/同步項目,以便用戶可以立即看到更改。 這在IntelliJ IDEA中是否可行?

經過多次挖掘后,我得到了以下解決方案,並且有效。

public void actionPerformed(AnActionEvent e) {

    // Create/Modify files

    // Get the project from the ActionEvent
    Project project = e.getData(PlatformDataKeys.PROJECT);

    // Get the Base Dir and refresh with the following parameters
    // 'asynchronous' set to false and 'recursive' set to true
    project.getBaseDir().refresh(false,true);

}

您可以使用SyncAction

SyncProjectAction().actionPerformed(actionEvent)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM