JavaPsiFacade findClass() return null after mkdirs ?

The way mkdirs:


new File(path).mkdirs();
VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(path);
virtualFile.refresh(false, true);

after mkdirs , even JavaPsiFacade.getInstance(project).findClass("java.lang.String",GlobalSearchScope.allScope(project)) return null

JavaPsiFacade.getInstance(project).findClass(packageName, GlobalSearchScope.allScope(project))
2 comments
Comment actions Permalink

Correct me if I'm wrong, but you've just created new directories - what classes do you expect to find there?

0
Comment actions Permalink

The point is that the scope of  “findClass“ is “GlobalSearchScope.allScope(project)”, not just the scope of the directories I just created。

JavaPsiFacade.getInstance(project).findClass(packageName, GlobalSearchScope.allScope(project))

By the way ,there are many classes in the project ,and I can “findClass“ before I created the new directories.

0

Please sign in to leave a comment.