@@ -122,8 +122,10 @@ public void commitWithGc(BlazeContext context) {
122122 continue ;
123123 }
124124 moduleModel .disposeModule (module );
125- File imlFile = new File (module .getModuleFilePath ());
126- removeImlFile (imlFile );
125+ VirtualFile imlFile = module .getModuleFile ();
126+ if (imlFile != null ) {
127+ removeImlFile (imlFile );
128+ }
127129 }
128130 }
129131
@@ -141,29 +143,38 @@ private File getImlDirectory(BlazeImportSettings importSettings) {
141143 return new File (BlazeDataStorage .getProjectDataDir (importSettings ), "modules" );
142144 }
143145
146+ private static void removeImlFile (final VirtualFile imlFile ) {
147+ if (imlFile .isDirectory ()) {
148+ return ;
149+ }
150+
151+ ApplicationManager .getApplication ()
152+ .runWriteAction (
153+ new Runnable () {
154+ @ Override
155+ public void run () {
156+ try {
157+ imlFile .delete (this );
158+ } catch (IOException e ) {
159+ logger .warn (
160+ String .format (
161+ "Could not delete file: %s, will try to continue anyway." ,
162+ imlFile .getPath ()),
163+ e );
164+ }
165+ }
166+ });
167+ }
168+
169+
144170 // Delete using the virtual file to ensure that IntelliJ properly updates its index.
145171 // Otherwise, it is possible for IntelliJ to read the
146172 // old IML file from its index and behave unpredictably
147173 // (like failing to save the new IML files to disk).
148174 private static void removeImlFile (final File imlFile ) {
149175 final VirtualFile imlVirtualFile = VfsUtil .findFileByIoFile (imlFile , true );
150176 if (imlVirtualFile != null && imlVirtualFile .exists ()) {
151- ApplicationManager .getApplication ()
152- .runWriteAction (
153- new Runnable () {
154- @ Override
155- public void run () {
156- try {
157- imlVirtualFile .delete (this );
158- } catch (IOException e ) {
159- logger .warn (
160- String .format (
161- "Could not delete file: %s, will try to continue anyway." ,
162- imlVirtualFile .getPath ()),
163- e );
164- }
165- }
166- });
177+ removeImlFile (imlVirtualFile );
167178 }
168179 }
169180}
0 commit comments