Usage of PsiManager.findClass & PsiManager.findClasses

Hello all!

I would like to ask a question about usage of PsiManager.findClass & PsiManager.findClasses methods.

Context:

// Button listener in dialog's constructor:
generateNamesButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {

PsiClass[] psiClasses = PsiManager.getInstance(BindConstantToInterface.project).findClasses("com.training.mytraining.BasicStepUsage", GlobalSearchScope.projectScope(BindConstantToInterface.project));

PsiClass psiClass = PsiManager.getInstance(BindConstantToInterface.project).findClass("com.training.mytraining.BasicStepUsage", GlobalSearchScope.projectScope(BindConstantToInterface.project));

As results psiClass is null, psiClasses is PsiClasses[] with 0 size.

}
});

What's wrong?

com.training.mytraining.BasicStepUsage - opened class in IDEA Project...

Sincerelly yours

3 comments
Comment actions Permalink

Are you sure the class name is correct?
Are you sure you're using the correct scope? As an experiment you can try using GlobalSearchScope.allScope(BindConstantToInterface.project)).

0
Comment actions Permalink

Yep, sure...

Same result - no difference :(

0
Comment actions Permalink

Seems, I've solved the problem.

Problem was that project must be passed in dataContext when dialog is opened.

0

Please sign in to leave a comment.