how can I get FQName of an PsiElement?

已回答

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?

 

1

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

com.intellij.ide.actions.QualifiedNameProviderUtil#getQualifiedName

0

Ahhhh. It gives a simple format FQName.

 

0

请先登录再写评论。