The best way to refresh Virtual FIles

Answered

Hi Dears, before I used for refreshing:

Objects.requireNonNull(project.getProjectFile()).refresh(false, true);

now changed to:

VfsUtil.markDirtyAndRefresh(true, true, true, project.getProjectFile());

Please let me know is the second one (of course can be slower then as mentioned in documentation) better or any other solution you can suggest.

 

Thanks in advance

8 comments
Comment actions Permalink

Why do you need to refresh this file? From where do you use it?

0
Comment actions Permalink

I am using that in my plugin to refresh in background mode the project when some changes comes from web browser.

This plugin will work to do some background stuff, when I will update something in my account in web some changes in project will see changes in my Intellij project.

So my Intellij project will have installed plugin and also will have configuration file which providing connection configuration to my web project.

0
Comment actions Permalink

ok, but why specifically com.intellij.openapi.project.Project#getProjectFile? what kind of changes?

0
Comment actions Permalink

For example new folder will be added with inside some new file(s).

Did some research and for refresh stuff for project found above mentioned examples.

So I taking the all projects in my plugin and pass to my framework the project.

 

0
Comment actions Permalink

Project#getProjectFile is not the project directory. You'll probably want to check/refresh content roots of modules inside project, see com.intellij.openapi.roots.ProjectRootManager#getContentRoots

0
Comment actions Permalink

Do you mean refreshing stuff like this  :

 

VfsUtil.markDirtyAndRefresh(true, true, true, ProjectRootManager.getInstance(project).getContentRoots());

 Thanks for valuable tips.

0

Please sign in to leave a comment.