20
20
import fr .adrienbrault .idea .symfony2plugin .TwigHelper ;
21
21
import fr .adrienbrault .idea .symfony2plugin .templating .variable .TwigFileVariableCollector ;
22
22
import fr .adrienbrault .idea .symfony2plugin .templating .variable .TwigFileVariableCollectorParameter ;
23
+ import fr .adrienbrault .idea .symfony2plugin .templating .variable .TwigTypeContainer ;
23
24
import fr .adrienbrault .idea .symfony2plugin .templating .variable .collector .*;
24
25
import fr .adrienbrault .idea .symfony2plugin .util .PhpElementsUtil ;
25
26
import fr .adrienbrault .idea .symfony2plugin .util .PsiElementUtils ;
26
27
import fr .adrienbrault .idea .symfony2plugin .util .yaml .YamlHelper ;
27
28
import org .apache .commons .lang .StringUtils ;
29
+ import org .jetbrains .annotations .Nullable ;
28
30
29
31
import java .util .*;
30
32
import java .util .regex .Matcher ;
@@ -71,18 +73,18 @@ public static String[] formatPsiTypeName(PsiElement psiElement) {
71
73
return possibleTypes ;
72
74
}
73
75
74
- public static Collection <? extends PhpNamedElement > resolveTwigMethodName (PsiElement psiElement , String [] typeName ) {
76
+ public static Collection <TwigTypeContainer > resolveTwigMethodName (PsiElement psiElement , String [] typeName ) {
75
77
76
78
if (typeName .length == 0 ) {
77
79
return Collections .emptyList ();
78
80
}
79
81
80
82
Collection <? extends PhpNamedElement > rootVariable = getRootVariableByName (psiElement , typeName [0 ]);
81
83
if (typeName .length == 1 ) {
82
- return rootVariable ;
84
+ return TwigTypeContainer . fromCollection ( rootVariable ) ;
83
85
}
84
86
85
- Collection <? extends PhpNamedElement > type = rootVariable ;
87
+ Collection <TwigTypeContainer > type = TwigTypeContainer . fromCollection ( rootVariable ) ;
86
88
for (int i = 1 ; i <= typeName .length - 1 ; i ++ ) {
87
89
type = resolveTwigMethodName (type , typeName [i ]);
88
90
@@ -93,7 +95,7 @@ public static Collection<? extends PhpNamedElement> resolveTwigMethodName(PsiEle
93
95
94
96
}
95
97
96
- return type ;
98
+ return TwigTypeContainer . fromCollection ( rootVariable ) ;
97
99
}
98
100
99
101
/**
@@ -250,20 +252,24 @@ private static Collection<? extends PhpNamedElement> getRootVariableByName(PsiEl
250
252
251
253
}
252
254
253
- private static Collection <? extends PhpNamedElement > resolveTwigMethodName (Collection <? extends PhpNamedElement > previousElement , String typeName ) {
255
+ private static Collection <TwigTypeContainer > resolveTwigMethodName (Collection <TwigTypeContainer > previousElement , String typeName ) {
254
256
255
- ArrayList <PhpNamedElement > phpNamedElements = new ArrayList <PhpNamedElement >();
257
+ ArrayList <TwigTypeContainer > phpNamedElements = new ArrayList <TwigTypeContainer >();
258
+
259
+ for (TwigTypeContainer phpNamedElement : previousElement ) {
256
260
257
- for (PhpNamedElement phpNamedElement : previousElement ) {
258
- for (PhpNamedElement target : getTwigPhpNameTargets (phpNamedElement , typeName )) {
259
- PhpType phpType = target .getType ();
260
- for (String typeString : phpType .getTypes ()) {
261
- PhpNamedElement phpNamedElement1 = PhpElementsUtil .getClassInterface (phpNamedElement .getProject (), typeString );
262
- if (phpNamedElement1 != null ) {
263
- phpNamedElements .add (phpNamedElement1 );
261
+ if (phpNamedElement .getPhpNamedElement () != null ) {
262
+ for (PhpNamedElement target : getTwigPhpNameTargets (phpNamedElement .getPhpNamedElement (), typeName )) {
263
+ PhpType phpType = target .getType ();
264
+ for (String typeString : phpType .getTypes ()) {
265
+ PhpNamedElement phpNamedElement1 = PhpElementsUtil .getClassInterface (phpNamedElement .getPhpNamedElement ().getProject (), typeString );
266
+ if (phpNamedElement1 != null ) {
267
+ phpNamedElements .add (new TwigTypeContainer (phpNamedElement1 ));
268
+ }
264
269
}
265
270
}
266
271
}
272
+
267
273
}
268
274
269
275
return phpNamedElements ;
0 commit comments