|
1 | 1 | package fr.adrienbrault.idea.symfony2plugin.tests.stubs.indexes; |
2 | 2 |
|
| 3 | +import com.intellij.openapi.vfs.VirtualFile; |
3 | 4 | import com.intellij.psi.search.GlobalSearchScope; |
| 5 | +import com.intellij.util.Processor; |
4 | 6 | import com.intellij.util.containers.ArrayListSet; |
5 | 7 | import com.intellij.util.containers.ContainerUtil; |
6 | 8 | import com.intellij.util.indexing.FileBasedIndex; |
| 9 | +import com.jetbrains.twig.TwigFileType; |
7 | 10 | import fr.adrienbrault.idea.symfony2plugin.stubs.indexes.TranslationStubIndex; |
8 | 11 | import fr.adrienbrault.idea.symfony2plugin.tests.SymfonyLightCodeInsightFixtureTestCase; |
9 | 12 | import org.apache.commons.lang.StringUtils; |
10 | 13 | import org.jetbrains.annotations.NotNull; |
11 | 14 |
|
| 15 | +import java.util.Arrays; |
| 16 | +import java.util.HashSet; |
| 17 | +import java.util.List; |
12 | 18 | import java.util.Set; |
13 | 19 |
|
14 | 20 | /** |
@@ -36,12 +42,35 @@ public void setUp() throws Exception { |
36 | 42 |
|
37 | 43 | myFixture.copyFileToProject("fr.xlf", "+intl-icu.fr.xlf"); |
38 | 44 | myFixture.copyFileToProject("fr.xlf", " .fr.xlf"); |
| 45 | + |
| 46 | + myFixture.copyFileToProject("apple.de.yml", "unknown/unknown-1+intl-icu.fr.yml"); |
| 47 | + myFixture.copyFileToProject("apple.de.yml", "unknown/messages.ar.yml"); |
| 48 | + myFixture.copyFileToProject("apple.de.yml", "unknown/validators.ar.yml"); |
| 49 | + myFixture.copyFileToProject("apple.de.yml", "unknown/unknown-2.fr.yml"); |
| 50 | + myFixture.copyFileToProject("apple.de.yml", "unknown/unknown-3.sr_Cyrl.yml"); |
| 51 | + myFixture.copyFileToProject("apple.de.yml", "unknown/unknown-3.sr_Cyrla.yml"); |
| 52 | + myFixture.copyFileToProject("apple.de.yml", "unknown/unknown-3.xx.yml"); |
| 53 | + myFixture.copyFileToProject("apple.de.yml", "unknown/unknown-3.yml"); |
39 | 54 | } |
40 | 55 |
|
41 | 56 | public String getTestDataPath() { |
42 | 57 | return "src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/stubs/indexes/fixtures"; |
43 | 58 | } |
44 | 59 |
|
| 60 | + public void testNamingMatchingForTranslations() { |
| 61 | + Set<String> filenames = new HashSet<>(); |
| 62 | + |
| 63 | + for (String key : new String[]{"unknown-1", "unknown-2", "unknown-3", "validators", "messages"}) { |
| 64 | + FileBasedIndex.getInstance().getFilesWithKey(TranslationStubIndex.KEY, new HashSet<>(List.of(key)), virtualFile -> { |
| 65 | + filenames.add(virtualFile.getName()); |
| 66 | + return true; |
| 67 | + }, GlobalSearchScope.allScope(getProject())); |
| 68 | + } |
| 69 | + |
| 70 | + assertContainsElements(filenames, "unknown-1+intl-icu.fr.yml", "messages.ar.yml", "validators.ar.yml", "unknown-2.fr.yml", "unknown-3.sr_Cyrl.yml"); |
| 71 | + assertDoesntContain(filenames, "unknown-3.sr_Cyrla.yml", "unknown-3.xx.yml", "unknown-3.yml"); |
| 72 | + } |
| 73 | + |
45 | 74 | public void testThatDomainFromFileIsExtracted() { |
46 | 75 | assertIndexContains(TranslationStubIndex.KEY, "foo.bar"); |
47 | 76 | assertIndexNotContains(TranslationStubIndex.KEY, ""); |
|
0 commit comments