14
14
import com .jetbrains .php .lang .psi .stubs .indexes .PhpConstantNameIndex ;
15
15
import de .espend .idea .php .annotation .util .AnnotationUtil ;
16
16
import fr .adrienbrault .idea .symfony2plugin .Symfony2ProjectComponent ;
17
+ import fr .adrienbrault .idea .symfony2plugin .extension .PluginConfigurationExtensionParameter ;
18
+ import fr .adrienbrault .idea .symfony2plugin .extension .PluginConfigurationExtension ;
17
19
import fr .adrienbrault .idea .symfony2plugin .stubs .dict .TemplateUsage ;
18
20
import fr .adrienbrault .idea .symfony2plugin .stubs .indexes .externalizer .ObjectStreamDataExternalizer ;
19
21
import fr .adrienbrault .idea .symfony2plugin .templating .util .TwigUtil ;
@@ -33,7 +35,7 @@ public class PhpTwigTemplateUsageStubIndex extends FileBasedIndexExtension<Strin
33
35
private static int MAX_FILE_BYTE_SIZE = 2097152 ;
34
36
private static ObjectStreamDataExternalizer <TemplateUsage > EXTERNALIZER = new ObjectStreamDataExternalizer <>();
35
37
36
- public static Set <String > RENDER_METHODS = new HashSet <String >() {{
38
+ private static Set <String > RENDER_METHODS = new HashSet <String >() {{
37
39
add ("render" );
38
40
add ("renderView" );
39
41
add ("renderResponse" );
@@ -64,6 +66,7 @@ public Map<String, TemplateUsage> map(@NotNull FileContent inputData) {
64
66
Map <String , Set <String >> items = new HashMap <>();
65
67
66
68
psiFile .accept (new PsiRecursiveElementWalkingVisitor () {
69
+ private Set <String > methods = null ;
67
70
68
71
@ Override
69
72
public void visitElement (PsiElement element ) {
@@ -77,7 +80,24 @@ public void visitElement(PsiElement element) {
77
80
78
81
private void visitMethodReference (@ NotNull MethodReference methodReference ) {
79
82
String methodName = methodReference .getName ();
80
- if (!RENDER_METHODS .contains (methodName )) {
83
+
84
+ // init methods once per file
85
+ if (methods == null ) {
86
+ methods = new HashSet <>();
87
+ methods .addAll (RENDER_METHODS );
88
+
89
+ PluginConfigurationExtension [] extensions = Symfony2ProjectComponent .PLUGIN_CONFIGURATION_EXTENSION .getExtensions ();
90
+ if (extensions .length > 0 ) {
91
+ PluginConfigurationExtensionParameter pluginConfiguration = new PluginConfigurationExtensionParameter (inputData .getProject ());
92
+ for (PluginConfigurationExtension extension : extensions ) {
93
+ extension .invokePluginConfiguration (pluginConfiguration );
94
+ }
95
+
96
+ methods .addAll (pluginConfiguration .getTemplateUsageMethod ());
97
+ }
98
+ }
99
+
100
+ if (!methods .contains (methodName )) {
81
101
return ;
82
102
}
83
103
0 commit comments