why module.getModuleFile return null

Answered

call  method com.intellij.openapi.module.impl.ModuleImpl#getModuleFile ,  follow the code to  com.intellij.openapi.vfs.impl.FilePartNode#myFile(java.lang.Object),  the parameter is .iml file path, then return null.  same call before run well.

0
2 comments

Hi,

Looking at the com.intellij.openapi.vfs.impl.FilePartNode#myFile(java.lang.Object) method it's impossible that it returned a VirtualFile instance for path parameter as it returns non-null values only when parameter is VirtualFile:

static VirtualFile myFile(@NotNull Object fileOrUrl) {
  return fileOrUrl instanceof VirtualFile ? (VirtualFile)fileOrUrl : null;
}

Maybe two calls were done from different contexts. Could you please provide us with the more information about the issue? Where do you call module.getModuleFile() from?

0

Please also consider cases mentioned in com.intellij.openapi.module.Module#getModuleFile javadoc. Note this is Internal API and should not be used by 3rd party plugins. See javadoc for alternatives.

0

Please sign in to leave a comment.