IDEA-86810 Find Usages not finding usages when I do it on decompiled stub source

This commit is contained in:
peter
2012-06-04 20:20:21 +02:00
parent 0e35f229a4
commit fa4c2a6916
3 changed files with 18 additions and 3 deletions
@@ -15,6 +15,7 @@
*/
package com.intellij.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressIndicatorProvider;
@@ -964,9 +965,12 @@ public class PsiClassImplUtil {
private static PsiElement originalElement(PsiClass aClass) {
final PsiElement originalElement = aClass.getOriginalElement();
final PsiCompiledElement compiled = originalElement.getUserData(ClsElementImpl.COMPILED_ELEMENT);
if (compiled != null) {
return compiled;
ASTNode node = originalElement.getNode();
if (node != null) {
final PsiCompiledElement compiled = node.getUserData(ClsElementImpl.COMPILED_ELEMENT);
if (compiled != null) {
return compiled;
}
}
return originalElement;
}
@@ -0,0 +1,5 @@
import javax.swing.JLabel;
public class Usage {
JLabel s;
}
@@ -89,6 +89,12 @@ public class FindUsagesTest extends PsiTestCase{
assertEquals(1, ReferencesSearch.search(method).findAll().size());
}
public void testLibraryClassUsageFromDecompiledSource() {
PsiElement decompiled =
((PsiCompiledElement)myJavaFacade.findClass("javax.swing.JLabel", GlobalSearchScope.allScope(myProject))).getMirror();
assertEquals(2, ReferencesSearch.search(decompiled).findAll().size());
}
public void testImplicitConstructorUsage() throws Throwable {
PsiMethod[] ctrs = myJavaFacade.findClass("Foo", GlobalSearchScope.allScope(myProject)).getConstructors();
PsiMethod method = ctrs[0];