Skip to content

Commit 81a3096

Browse files
committed
autocompletion for known tag names in Definition::addTag, clearTag, hasTag #955
1 parent cfa3ae2 commit 81a3096

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed

src/fr/adrienbrault/idea/symfony2plugin/config/php/PhpConfigReferenceContributor.java

+3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ public void registerReferenceProviders(PsiReferenceRegistrar psiReferenceRegistr
4343

4444
psiReferenceRegistrar.registerReferenceProvider(PhpElementsUtil.methodWithFirstStringPattern(), new PhpStringLiteralExpressionReference(TagReference.class)
4545
.addCall("\\Symfony\\Component\\DependencyInjection\\ContainerBuilder", "findTaggedServiceIds")
46+
.addCall("\\Symfony\\Component\\DependencyInjection\\Definition", "addTag")
47+
.addCall("\\Symfony\\Component\\DependencyInjection\\Definition", "hasTag")
48+
.addCall("\\Symfony\\Component\\DependencyInjection\\Definition", "clearTag")
4649
);
4750

4851
psiReferenceRegistrar.registerReferenceProvider(PhpElementsUtil.methodWithFirstStringPattern(), new PhpStringLiteralExpressionReference(EventDispatcherEventReference.class)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package fr.adrienbrault.idea.symfony2plugin.tests.config.php;
2+
3+
import com.jetbrains.php.lang.PhpFileType;
4+
import fr.adrienbrault.idea.symfony2plugin.tests.SymfonyLightCodeInsightFixtureTestCase;
5+
6+
import java.io.File;
7+
8+
/**
9+
* @author Daniel Espendiller <daniel@espendiller.net>
10+
* @see fr.adrienbrault.idea.symfony2plugin.config.php.PhpConfigReferenceContributor
11+
*/
12+
public class PhpConfigReferenceContributorTest extends SymfonyLightCodeInsightFixtureTestCase {
13+
public void setUp() throws Exception {
14+
super.setUp();
15+
myFixture.copyFileToProject("classes.php");
16+
myFixture.copyFileToProject("tags.yml");
17+
}
18+
19+
public String getTestDataPath() {
20+
return new File(this.getClass().getResource("fixtures").getFile()).getAbsolutePath();
21+
}
22+
23+
public void testTagReferences() {
24+
assertCompletionContains(PhpFileType.INSTANCE, "<?php\n" +
25+
"/** @var $x \\Symfony\\Component\\DependencyInjection\\Definition */\n" +
26+
"$x->addTag('<caret>')",
27+
"foobar"
28+
);
29+
30+
assertCompletionContains(PhpFileType.INSTANCE, "<?php\n" +
31+
"/** @var $x \\Symfony\\Component\\DependencyInjection\\Definition */\n" +
32+
"$x->clearTag('<caret>')",
33+
"foobar"
34+
);
35+
36+
assertCompletionContains(PhpFileType.INSTANCE, "<?php\n" +
37+
"/** @var $x \\Symfony\\Component\\DependencyInjection\\Definition */\n" +
38+
"$x->hasTag('<caret>')",
39+
"foobar"
40+
);
41+
}
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Symfony\Component\DependencyInjection
4+
{
5+
class Definition
6+
{
7+
public function addTag($name, array $attributes = array())
8+
{
9+
}
10+
11+
public function hasTag($name)
12+
{
13+
}
14+
15+
public function clearTag($name)
16+
{
17+
}
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
services:
2+
my_foobar:
3+
class: espend\Form\TypeBundle\Form\FooType
4+
tags:
5+
- { name: foobar }

0 commit comments

Comments
 (0)