@@ -60,8 +60,8 @@ public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @No
60
60
61
61
ArrayHashElement arrayHash = PsiTreeUtil .getParentOfType (psiElement , ArrayHashElement .class );
62
62
if (arrayHash != null && arrayHash .getKey () instanceof StringLiteralExpression ) {
63
-
64
63
ArrayCreationExpression arrayCreation = PsiTreeUtil .getParentOfType (psiElement , ArrayCreationExpression .class );
64
+
65
65
if (arrayCreation == null ) {
66
66
return new PsiReference [0 ];
67
67
}
@@ -81,8 +81,8 @@ public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @No
81
81
82
82
// @TODO: how to handle custom bundle fields like help_block
83
83
if (keyString .equals ("label" ) || keyString .equals ("help_block" ) || keyString .equals ("help_inline" ) || keyString .equals ("placeholder" )) {
84
-
85
84
// translation_domain in current array block
85
+
86
86
String translationDomain = FormOptionsUtil .getTranslationFromScope (arrayCreation );
87
87
if (translationDomain == null ) {
88
88
translationDomain = "messages" ;
@@ -94,15 +94,11 @@ public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @No
94
94
if (keyString .equals ("class" )) {
95
95
return new PsiReference []{ new EntityReference ((StringLiteralExpression ) psiElement , true )};
96
96
}
97
-
98
97
}
99
98
100
99
return new PsiReference [0 ];
101
-
102
100
}
103
-
104
101
}
105
-
106
102
);
107
103
108
104
/*
@@ -115,7 +111,6 @@ public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @No
115
111
@ NotNull
116
112
@ Override
117
113
public PsiReference [] getReferencesByElement (@ NotNull PsiElement psiElement , @ NotNull ProcessingContext processingContext ) {
118
-
119
114
// match add('foo', 'type name')
120
115
MethodMatcher .MethodMatchParameter methodMatchParameter = new MethodMatcher .StringParameterMatcher (psiElement , 1 )
121
116
.withSignature (FormUtil .PHP_FORM_BUILDER_SIGNATURES )
@@ -133,11 +128,8 @@ public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @No
133
128
}
134
129
135
130
return new PsiReference []{ new FormTypeReferenceRef ((StringLiteralExpression ) psiElement ) };
136
-
137
131
}
138
-
139
132
}
140
-
141
133
);
142
134
143
135
// FormBuilderInterface::add('underscore_method')
@@ -180,9 +172,7 @@ public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @No
180
172
181
173
return new PsiReference []{new FormUnderscoreMethodReference ((StringLiteralExpression ) psiElement , phpClass )};
182
174
}
183
-
184
175
}
185
-
186
176
);
187
177
188
178
// TODO: migrate to FormGotoCompletionRegistrar for better performance as lazy condition
@@ -228,7 +218,7 @@ public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @No
228
218
229
219
if (PhpElementsUtil .getCompletableArrayCreationElement (psiElement ) != null ) {
230
220
return new PsiReference []{
231
- new FormExtensionKeyReference ((StringLiteralExpression ) psiElement ),
221
+ new FormExtensionKeyReference ((StringLiteralExpression ) psiElement , FormUtil . getFormTypeClassFromScope ( psiElement ) ),
232
222
new FormDefaultOptionsKeyReference ((StringLiteralExpression ) psiElement , "form" ),
233
223
new FormDefaultOptionsKeyReference ((StringLiteralExpression ) psiElement , "Symfony\\ Component\\ Form\\ Extension\\ Core\\ Type\\ FormType" ),
234
224
};
@@ -248,8 +238,6 @@ public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @No
248
238
@ NotNull
249
239
@ Override
250
240
public PsiReference [] getReferencesByElement (@ NotNull PsiElement psiElement , @ NotNull ProcessingContext processingContext ) {
251
-
252
-
253
241
MethodMatcher .MethodMatchParameter methodMatchParameter = new MethodMatcher .StringParameterMatcher (psiElement , 0 )
254
242
.withSignature ("\\ Symfony\\ Component\\ Form\\ FormInterface" , "get" )
255
243
.withSignature ("\\ Symfony\\ Component\\ Form\\ FormInterface" , "has" )
@@ -268,23 +256,20 @@ public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @No
268
256
new FormFieldNameReference ((StringLiteralExpression ) psiElement , method )
269
257
};
270
258
}
271
-
272
259
}
273
-
274
260
);
275
261
276
- /**
262
+ /*
277
263
* $options
278
264
* public function buildForm(FormBuilderInterface $builder, array $options) {
279
265
* $options['foo']
280
266
* }
281
267
*
282
268
* public function setDefaultOptions(OptionsResolverInterface $resolver) {
283
- * $resolver->setDefaults(array(
269
+ * $resolver->setDefaults([
284
270
* 'foo' => 'bar',
285
- * ));
286
- }
287
-
271
+ * ]);
272
+ * }
288
273
*/
289
274
psiReferenceRegistrar .registerReferenceProvider (
290
275
PlatformPatterns .psiElement (StringLiteralExpression .class ),
@@ -334,21 +319,15 @@ public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @No
334
319
}
335
320
336
321
return new PsiReference []{
337
- new FormExtensionKeyReference ((StringLiteralExpression ) psiElement ),
322
+ new FormExtensionKeyReference ((StringLiteralExpression ) psiElement , FormUtil . getFormTypeClassFromScope ( psiElement ) ),
338
323
new FormDefaultOptionsKeyReference ((StringLiteralExpression ) psiElement , phpClass .getPresentableFQN ())
339
324
};
340
-
341
325
}
342
-
343
326
}
344
-
345
327
);
346
-
347
-
348
328
}
349
329
350
330
private static class FormTypeReferenceRef extends FormTypeReference {
351
-
352
331
public FormTypeReferenceRef (@ NotNull StringLiteralExpression element ) {
353
332
super (element );
354
333
}
@@ -358,6 +337,5 @@ public FormTypeReferenceRef(@NotNull StringLiteralExpression element) {
358
337
public Object [] getVariants () {
359
338
return new Object [0 ];
360
339
}
361
-
362
340
}
363
341
}
0 commit comments