1
1
package com .magento .idea .magento2plugin .reference .provider ;
2
2
3
- import com .intellij .ide .highlighter .XmlFileType ;
4
3
import com .intellij .openapi .util .TextRange ;
5
4
import com .intellij .openapi .vfs .*;
6
5
import com .intellij .psi .*;
7
6
import com .intellij .psi .search .FilenameIndex ;
8
7
import com .intellij .psi .search .GlobalSearchScope ;
9
8
import com .intellij .util .ProcessingContext ;
10
9
import com .intellij .util .indexing .FileBasedIndex ;
10
+ import com .jetbrains .php .lang .PhpFileType ;
11
11
import com .magento .idea .magento2plugin .reference .xml .PolyVariantReferenceBase ;
12
12
import com .magento .idea .magento2plugin .stubs .indexes .ModuleNameIndex ;
13
13
import gnu .trove .THashMap ;
@@ -33,6 +33,7 @@ public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNu
33
33
return PsiReference .EMPTY_ARRAY ;
34
34
}
35
35
36
+ // Find all files based on provided path
36
37
Collection <VirtualFile > files = getFiles (element );
37
38
if (!(files .size () > 0 )) {
38
39
return PsiReference .EMPTY_ARRAY ;
@@ -92,12 +93,9 @@ public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNu
92
93
}
93
94
94
95
if (psiPathElements .size () > 0 ) {
95
- psiPathElements .forEach (new BiConsumer <TextRange , List <PsiElement >>() {
96
- @ Override
97
- public void accept (TextRange textRange , List <PsiElement > psiElements ) {
98
- psiReferences .add (new PolyVariantReferenceBase (element , textRange , psiElements ));
99
- }
100
- });
96
+ psiPathElements .forEach (((textRange , psiElements ) ->
97
+ psiReferences .add (new PolyVariantReferenceBase (element , textRange , psiElements ))
98
+ ));
101
99
}
102
100
}
103
101
@@ -141,7 +139,7 @@ private Collection<VirtualFile> getFiles(@NotNull PsiElement element)
141
139
Collection <VirtualFile > vfs = getModuleSourceFiles (element );
142
140
if (null != vfs ) {
143
141
for (VirtualFile vf : vfs ) {
144
- Collection <VirtualFile > vfChildren = getAllSubFiles (vf . findChild ( "view" ) );
142
+ Collection <VirtualFile > vfChildren = getAllSubFiles (vf );
145
143
if (null != vfChildren ) {
146
144
vfChildren .removeIf (f -> {
147
145
if (!f .isDirectory ()) {
@@ -171,7 +169,7 @@ private Collection<VirtualFile> getModuleFile(@NotNull PsiElement element)
171
169
.getContainingFiles (ModuleNameIndex .KEY , moduleName ,
172
170
GlobalSearchScope .getScopeRestrictedByFileTypes (
173
171
GlobalSearchScope .allScope (element .getProject ()),
174
- XmlFileType .INSTANCE
172
+ PhpFileType .INSTANCE
175
173
)
176
174
);
177
175
}
@@ -182,10 +180,10 @@ private Collection<VirtualFile> getModuleSourceFiles(@NotNull PsiElement element
182
180
if (null == virtualFiles ) {
183
181
return null ;
184
182
}
185
- virtualFiles .removeIf (vf -> !(vf != null && vf .getParent () != null && vf . getParent (). getParent () != null ));
183
+ virtualFiles .removeIf (vf -> !(vf != null && vf .getParent () != null ));
186
184
Collection <VirtualFile > sourceVfs = new ArrayList <>();
187
185
for (VirtualFile vf : virtualFiles ) {
188
- sourceVfs .add (vf .getParent (). getParent () );
186
+ sourceVfs .add (vf .getParent ());
189
187
}
190
188
return sourceVfs ;
191
189
}
@@ -223,10 +221,6 @@ private Collection<VirtualFile> getAllSubFiles(VirtualFile virtualFile)
223
221
{
224
222
Collection <VirtualFile > list = new ArrayList <>();
225
223
226
- if (null == virtualFile ) {
227
- return list ;
228
- }
229
-
230
224
VfsUtilCore .visitChildrenRecursively (virtualFile , new VirtualFileVisitor () {
231
225
@ Override
232
226
public boolean visitFile (@ NotNull VirtualFile file ) {
0 commit comments