Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6b8f850

Browse files
Merge pull request #1992 from Haehnchen/feature/1984-tagged-locator
#1984 support parameter inside "TaggedLocator" attribute
2 parents 4344301 + cd5fd67 commit 6b8f850

File tree

4 files changed

+55
-5
lines changed

4 files changed

+55
-5
lines changed

‎src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/container/util/ServiceContainerUtil.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ public class ServiceContainerUtil {
7171
};
7272

7373
public static final String AUTOWIRE_ATTRIBUTE_CLASS = "\\Symfony\\Component\\DependencyInjection\\Attribute\\Autowire";
74-
public static final String TAGGET_ITERATOR_ATTRIBUTE_CLASS = "\\Symfony\\Component\\DependencyInjection\\Attribute\\TaggedIterator";
74+
public static final String TAGGED_ITERATOR_ATTRIBUTE_CLASS = "\\Symfony\\Component\\DependencyInjection\\Attribute\\TaggedIterator";
75+
public static final String TAGGED_LOCATOR_ATTRIBUTE_CLASS = "\\Symfony\\Component\\DependencyInjection\\Attribute\\TaggedLocator";
7576

7677
@NotNull
7778
public static Collection<ServiceSerializable> getServicesInFile(@NotNull PsiFile psiFile) {

‎src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/registrar/DicGotoCompletionRegistrar.java‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import com.intellij.codeInsight.lookup.LookupElement;
44
import com.intellij.patterns.PlatformPatterns;
55
import com.intellij.psi.PsiElement;
6-
import com.intellij.psi.PsiElementResolveResult;
7-
import com.intellij.psi.ResolveResult;
86
import com.intellij.psi.util.PsiTreeUtil;
97
import com.jetbrains.php.lang.psi.elements.PhpAttribute;
108
import com.jetbrains.php.lang.psi.elements.PhpClass;
@@ -92,10 +90,13 @@ public void register(@NotNull GotoCompletionRegistrarParameter registrar) {
9290
);
9391

9492
// #[TaggedIterator('app.handler')] iterable $handlers
93+
// #[TaggedLocator('app.handler')] ContainerInterface $handlers
9594
registrar.register(
9695
PlatformPatterns.or(
97-
PhpElementsUtil.getFirstAttributeStringPattern(ServiceContainerUtil.TAGGET_ITERATOR_ATTRIBUTE_CLASS),
98-
PhpElementsUtil.getAttributeNamedArgumentStringPattern(ServiceContainerUtil.TAGGET_ITERATOR_ATTRIBUTE_CLASS, "tag")
96+
PhpElementsUtil.getFirstAttributeStringPattern(ServiceContainerUtil.TAGGED_ITERATOR_ATTRIBUTE_CLASS),
97+
PhpElementsUtil.getAttributeNamedArgumentStringPattern(ServiceContainerUtil.TAGGED_ITERATOR_ATTRIBUTE_CLASS, "tag"),
98+
PhpElementsUtil.getFirstAttributeStringPattern(ServiceContainerUtil.TAGGED_LOCATOR_ATTRIBUTE_CLASS),
99+
PhpElementsUtil.getAttributeNamedArgumentStringPattern(ServiceContainerUtil.TAGGED_LOCATOR_ATTRIBUTE_CLASS, "tag")
99100
), psiElement -> {
100101
PsiElement context = psiElement.getContext();
101102
if (!(context instanceof StringLiteralExpression)) {

‎src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/dic/registrar/DicGotoCompletionRegistrarTest.java‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,42 @@ public void testTagContributorForTaggedIterator() {
167167
);
168168
}
169169

170+
public void testTagContributorForTaggedLocator() {
171+
assertCompletionContains(PhpFileType.INSTANCE, "<?php\n" +
172+
"use Symfony\\Component\\DependencyInjection\\Attribute\\TaggedLocator;\n" +
173+
"\n" +
174+
"class HandlerCollection\n" +
175+
" public function __construct(\n" +
176+
" #[TaggedLocator('<caret>')] ContainerInterface $handlers\n" +
177+
" ) {}\n" +
178+
"}",
179+
"yaml_type_tag"
180+
);
181+
182+
assertCompletionContains(PhpFileType.INSTANCE, "<?php\n" +
183+
"use Symfony\\Component\\DependencyInjection\\Attribute\\TaggedLocator;\n" +
184+
"\n" +
185+
"class HandlerCollection\n" +
186+
" public function __construct(\n" +
187+
" #[TaggedLocator(tag: '<caret>')] ContainerInterface $handlers\n" +
188+
" ) {}\n" +
189+
"}",
190+
"yaml_type_tag"
191+
);
192+
193+
assertNavigationMatch(PhpFileType.INSTANCE, "<?php\n" +
194+
"use Symfony\\Component\\DependencyInjection\\Attribute\\TaggedLocator;\n" +
195+
"\n" +
196+
"class HandlerCollection\n" +
197+
"{\n" +
198+
" public function __construct(\n" +
199+
" #[TaggedLocator('yaml_t<caret>ype_tag')] ContainerInterface $handlers\n" +
200+
" ) {}\n" +
201+
"}",
202+
PlatformPatterns.psiElement()
203+
);
204+
}
205+
170206
public void testServiceContributorForNamedAttribute() {
171207
assertCompletionContains(PhpFileType.INSTANCE, "<?php\n" +
172208
"use Symfony\\Component\\DependencyInjection\\Attribute\\Autowire;\n" +

‎src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/dic/registrar/fixtures/classes.php‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ public function __construct(
3535
public string|array $exclude = [],
3636
) {}
3737
}
38+
39+
class TaggedLocator
40+
{
41+
public function __construct(
42+
public string $tag,
43+
public ?string $indexAttribute = null,
44+
public ?string $defaultIndexMethod = null,
45+
public ?string $defaultPriorityMethod = null,
46+
public string|array $exclude = [],
47+
) {
48+
}
49+
}
3850
}
3951

4052
namespace

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /