10000 remove "defaults" key detection for a valid yaml route id #518 · Koc/idea-php-symfony2-plugin@2104872 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2104872

Browse files
committed
remove "defaults" key detection for a valid yaml route id Haehnchen#518
1 parent 1a36c92 commit 2104872

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

src/fr/adrienbrault/idea/symfony2plugin/routing/RouteHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ public static Collection<StubIndexedRoute> getYamlRouteDefinitions(YAMLDocument
509509
if(element instanceof YAMLCompoundValue) {
510510
Set<String> keySet = YamlHelper.getYamlCompoundValueKeyNames((YAMLCompoundValue) element);
511511

512-
if((keySet.contains("path") || keySet.contains("pattern")) && keySet.contains("defaults")) {
512+
if((keySet.contains("path") || keySet.contains("pattern"))) {
513513
// cleanup: 'foo', "foo"
514514
String keyText = StringUtils.strip(StringUtils.strip(yamlKeyValue.getKeyText(), "'"), "\"");
515515
if(StringUtils.isNotBlank(keyText)) {
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package fr.adrienbrault.idea.symfony2plugin.tests.stubs.indexes;
2+
3+
import com.intellij.ide.highlighter.XmlFileType;
4+
import fr.adrienbrault.idea.symfony2plugin.stubs.indexes.RoutesStubIndex;
5+
import fr.adrienbrault.idea.symfony2plugin.tests.SymfonyLightCodeInsightFixtureTestCase;
6+
import org.jetbrains.yaml.YAMLFileType;
7+
8+
/**
9+
* @author Daniel Espendiller <daniel@espendiller.net>
10+
* @see fr.adrienbrault.idea.symfony2plugin.stubs.indexes.RoutesStubIndex
11+
*/
12+
public class RoutesStubIndexTestTest extends SymfonyLightCodeInsightFixtureTestCase {
13+
14+
public void setUp() throws Exception {
15+
super.setUp();
16+
17+
myFixture.configureByText(YAMLFileType.YML, "" +
18+
"foo_yaml_pattern:\n" +
19+
" pattern: /\n" +
20+
" defaults: { _controller: foo_controller }" +
21+
"\n" +
22+
"foo_yaml_path:\n" +
23+
" path: /\n" +
24+
" defaults: { _controller: foo_controller }" +
25+
"\n" +
26+
"foo_yaml_path_only:\n" +
27+
" path: /\n" +
28+
"foo_yaml_invalid:\n" +
29+
" path_invalid: /\n"
30+
);
31+
32+
myFixture.configureByText(XmlFileType.INSTANCE, "" +
33+
"<routes>\n" +
34+
" <route id=\"foo_xml_pattern\" pattern=\"/blog/{slug}\"/>\n" +
35+
" <route id=\"foo_xml_path\" path=\"/blog/{slug}\">\n" +
36+
" <default key=\"_controller\">Foo</default>\n" +
37+
" </route>\n" +
38+
" <route id=\"foo_xml_id_only\"/>\n" +
39+
"</routes>"
40+
);
41+
}
42+
43+
/**
44+
* @see fr.adrienbrault.idea.symfony2plugin.stubs.indexes.RoutesStubIndex#getIndexer()
45+
*/
46+
public void testRouteIdIndex() {
47+
assertIndexContains(RoutesStubIndex.KEY,
48+
"foo_yaml_pattern", "foo_yaml_path", "foo_yaml_path_only",
49+
"foo_xml_pattern", "foo_xml_path", "foo_xml_id_only"
50+
);
51+
52+
assertIndexNotContains(RoutesStubIndex.KEY,
53+
"foo_yaml_invalid"
54+
);
55+
}
56+
}

0 commit comments

Comments
 (0)
0