7 comments
Comment actions Permalink

Hello lingll,

how can i enumerate all classes in the project?


PsiShortNameCache cache = JavaPsiFacade.getInstance(project).getShortNamesCache();
String[] classNames = cache.getAllClassNames();
for(String className: classNames) { cache.getClassesByName(name, GlobalSearchScope.projectScope(project);
}

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

thank you.
but i don't know how to import JavaPsiFacade, i find it in com.intellij.psi.JavaPsiFacade from the api document.  but it doesn't work.
the package com.intellij.psi does not have class JavaPsiFacade .

0
Comment actions Permalink

Hello lingll,

JavaPsiFacade was added in IDEA 8. In IDEA 7, use PsiManager.getShortNamesCache()
instead.

thank you.

but i don't know how to import JavaPsiFacade, i find it in
*com.intellij.psi.JavaPsiFacade from the api document. but it doesn't
work.*

the package com.intellij.psi does not have class JavaPsiFacade .

---
Original message URL:
http://www.jetbrains.net/devnet/message/5242172#5242172

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink


ha, it does work!
thank you very much!

0
Comment actions Permalink

in idea 7  cache.getAllClassNames(false); can return the real class names ,the  length of the return array  is matched the classes number.
but in idea 8 , what ever how many classes in the project , the length of the return array is 25736 , seems it include all things , libraries or none libraries ...

as the size of the array is so large , when i do a loop to enumerate all classes by using cache.getClassesByName , it cost to much time , how can i improve this ?

thanks.

0
Comment actions Permalink

i find this

getAllClassNames(boolean searchInLibraries)
          Returns the list of names of all classes in the project and (optionally) libraries.



it seems getAllClassNames in  the  old version of idea  has a parameter which can determine whether include libraries .

how can i do the same in idea 8?

0
Comment actions Permalink

For those who follow, the class names cache class location changed IDEA 12...

PsiShortNamesCache.getInstance(project).getAllClassNames();
0

Please sign in to leave a comment.