Skip to content

Commit 0027149

Browse files
committed
[T3CMS] Correctly query index with signature
1 parent 72c0c28 commit 0027149

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

typo3-cms/src/main/java/com/cedricziel/idea/typo3/icons/IconReferenceContributor.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99
import com.jetbrains.php.lang.psi.elements.PhpNamedElement;
1010
import com.jetbrains.php.lang.psi.elements.StringLiteralExpression;
1111
import com.jetbrains.php.lang.psi.elements.Variable;
12-
import com.jetbrains.php.lang.psi.resolve.types.PhpType;
1312
import org.jetbrains.annotations.NotNull;
1413

1514
import java.util.Collection;
16-
import java.util.Set;
1715

1816
public class IconReferenceContributor extends PsiReferenceContributor {
1917

@@ -47,19 +45,16 @@ public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNu
4745

4846
if (methodReference.getFirstPsiChild() instanceof Variable) {
4947
Variable variable = (Variable) methodReference.getFirstPsiChild();
50-
PhpType inferredType = variable.getInferredType();
51-
Set<String> types = inferredType.getTypes();
52-
for (String type : types) {
53-
try {
54-
Collection<? extends PhpNamedElement> bySignature = PhpIndex.getInstance(element.getProject()).getBySignature(type);
55-
for (PhpNamedElement el : bySignature) {
56-
if (el.getFQN().equals(ICON_FACTORY) && methodName.equals("getIcon")) {
57-
return new PsiReference[]{new IconReference(stringLiteralExpression)};
58-
}
48+
String signature = variable.getSignature();
49+
Collection<? extends PhpNamedElement> bySignature = PhpIndex.getInstance(element.getProject()).getBySignature(signature);
50+
try {
51+
for (PhpNamedElement el : bySignature) {
52+
if (el.getFQN().equals(ICON_FACTORY) && methodName.equals("getIcon")) {
53+
return new PsiReference[]{new IconReference(stringLiteralExpression)};
5954
}
60-
} catch (RuntimeException e) {
61-
// invalid index signature, skip
6255
}
56+
} catch (RuntimeException e) {
57+
// invalid index signature, skip
6358
}
6459
}
6560

0 commit comments

Comments
 (0)