I use idea api createFileChooser as follows,but can not search the file I want, what's the problem?

Answered
PsiFile ps = PsiManager.getInstance(project).findFile(virtualFiles[0]);
TreeFileChooser.PsiFileFilter psiFileFilter = new TreeFileChooser.PsiFileFilter() {
@Override
public boolean accept(PsiFile psiFile) {
return true;
}
};
//PsiFile ps = PsiFileFactory.getInstance(project).createFileFromText("psi", StdFileTypes.CLASS,null);
TreeFileChooser fileChooser = TreeClassChooserFactory.getInstance(project).createFileChooser("选择类",ps, StdFileTypes.CLASS, psiFileFilter);
fileChooser.showDialog();


0
2 comments

You're using StdFileTypes.CLASS which refers to compiled .class files.Use com.intellij.openapi.fileTypes.StdFileTypes#JAVA for accessing .java source files.

0
Avatar
Permanently deleted user

You got my problem resolved !!!

0

Please sign in to leave a comment.