forked from magento/magento2-phpstorm-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLayoutUpdateReferenceProvider.java
31 lines (27 loc) · 1.15 KB
/
LayoutUpdateReferenceProvider.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* Copyright © Dmytro Kvashnin. All rights reserved.
* See COPYING.txt for license details.
*/
package com.magento.idea.magento2plugin.reference.provider;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiReference;
import com.intellij.psi.PsiReferenceProvider;
import com.intellij.psi.xml.XmlFile;
import com.intellij.util.ProcessingContext;
import com.magento.idea.magento2plugin.indexes.LayoutIndex;
import com.magento.idea.magento2plugin.reference.xml.PolyVariantReferenceBase;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class LayoutUpdateReferenceProvider extends PsiReferenceProvider {
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
String value = StringUtil.unquoteString(element.getText());
List<XmlFile> targets = LayoutIndex.getLayoutFiles(element.getProject(), value);
if (targets.size() > 0) {
return new PsiReference[] {new PolyVariantReferenceBase(element, targets)};
}
return PsiReference.EMPTY_ARRAY;
}
}