Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 225
RoshFsk Avatar asked Aug 31 '25 16:08

RoshFsk


1 Answers

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);

}
like image 71
RoshFsk Avatar answered Sep 02 '25 05:09

RoshFsk