@@ -77,7 +77,8 @@ public Module createModule(String moduleName, ModuleType<?> moduleType) {
7777 Module module = moduleModel .findModuleByName (moduleName );
7878 if (module == null ) {
7979 File imlFile = new File (imlDirectory , moduleName + ModuleFileType .DOT_DEFAULT_EXTENSION );
80- removeImlFile (imlFile );
80+ VirtualFile virtualImlFile = VfsUtil .findFileByIoFile (imlFile , true );
81+ removeImlFile (virtualImlFile );
8182 module = moduleModel .newModule (imlFile .getPath (), moduleType .getId ());
8283 module .setOption (EXTERNAL_SYSTEM_ID_KEY , EXTERNAL_SYSTEM_ID_VALUE );
8384 }
@@ -122,7 +123,7 @@ public void commitWithGc(BlazeContext context) {
122123 continue ;
123124 }
124125 moduleModel .disposeModule (module );
125- File imlFile = new File ( module .getModuleFilePath () );
126+ VirtualFile imlFile = module .getModuleFile ( );
126127 removeImlFile (imlFile );
127128 }
128129 }
@@ -145,9 +146,8 @@ private File getImlDirectory(BlazeImportSettings importSettings) {
145146 // Otherwise, it is possible for IntelliJ to read the
146147 // old IML file from its index and behave unpredictably
147148 // (like failing to save the new IML files to disk).
148- private static void removeImlFile (final File imlFile ) {
149- final VirtualFile imlVirtualFile = VfsUtil .findFileByIoFile (imlFile , true );
150- if (imlVirtualFile != null && imlVirtualFile .exists ()) {
149+ private static void removeImlFile (final VirtualFile imlVirtualFile ) {
150+ if (imlVirtualFile != null && imlVirtualFile .exists () && !imlVirtualFile .isDirectory ()) {
151151 ApplicationManager .getApplication ()
152152 .runWriteAction (
153153 new Runnable () {
0 commit comments