how can I get FQName of an PsiElement?

Answered

When I run inspect on shell command, I notice <entry_point> node on result.

<entry_point TYPE="method" FQNAME="com.study.foo int bar(java.lang.Integer id)" />

I want to retrive FQName of an PsiElement on my localInspection. After research, I found GlobalInspectionContextUtil class. 

GlobalInspectionContext globalInspectionContext = new GlobalInspectionContextBase(element.getProject());
RefElement refElem = GlobalInspectionContextUtil.retrieveRefElement(element, globalInspectionContext);
refElem.getExternalName();

But I failed, refElem is always null.  Is there any method can convert PsiElement to RefElement, then I can get FQName from RefElement?

 

3 comments
Comment actions Permalink

I answer my question.

Now I write a method to get FQName of a PsiMethod or PsiClass by retrive segment info, and concrete then manually.

But I think idea-api may have some method I could use to do so :)

0
Comment actions Permalink

com.intellij.ide.actions.QualifiedNameProviderUtil#getQualifiedName

0
Comment actions Permalink

Ahhhh. It gives a simple format FQName.

 

0

Please sign in to leave a comment.