简体   繁体   中英

Programmatically refresh/synchronize an IntelliJ IDEA project via a plugin

Is there a way to programmatically refresh/synchronize an IntelliJ IDEA project via a plugin?

I'm working on an IntelliJ IDEA plugin that creates a file within the active project. And I want to refresh/synchronize the project automatically via the plugin so that the user can see the changes immediately. Is this possible in IntelliJ IDEA?

After digging a bit more I came through the following solution and it worked.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM