|
7 | 7 |
|
8 | 8 | import com.intellij.openapi.project.Project; |
9 | 9 | import com.intellij.openapi.ui.ComboBox; |
| 10 | +import com.intellij.openapi.vfs.VirtualFile; |
10 | 11 | import com.intellij.psi.PsiDirectory; |
11 | 12 | import com.intellij.psi.PsiFile; |
| 13 | +import com.intellij.psi.search.GlobalSearchScope; |
12 | 14 | import com.intellij.ui.DocumentAdapter; |
13 | 15 | import com.intellij.util.indexing.FileBasedIndex; |
14 | 16 | import com.magento.idea.magento2plugin.actions.context.php.NewObserverAction; |
|
24 | 26 | import com.magento.idea.magento2plugin.actions.generation.generator.ModuleObserverGenerator; |
25 | 27 | import com.magento.idea.magento2plugin.actions.generation.generator.ObserverEventsXmlGenerator; |
26 | 28 | import com.magento.idea.magento2plugin.actions.generation.generator.util.DirectoryGenerator; |
| 29 | +import com.magento.idea.magento2plugin.lang.roots.MagentoTestSourceFilter; |
27 | 30 | import com.magento.idea.magento2plugin.magento.files.ModuleObserverFile; |
28 | 31 | import com.magento.idea.magento2plugin.magento.packages.Areas; |
29 | 32 | import com.magento.idea.magento2plugin.magento.packages.Package; |
|
36 | 39 | import java.awt.event.WindowEvent; |
37 | 40 | import java.util.ArrayList; |
38 | 41 | import java.util.Collection; |
| 42 | +import java.util.List; |
39 | 43 | import java.util.Locale; |
40 | 44 | import javax.swing.JButton; |
41 | 45 | import javax.swing.JComboBox; |
@@ -328,6 +332,24 @@ private void createUIComponents() { |
328 | 332 | final Collection<String> events = FileBasedIndex.getInstance().getAllKeys( |
329 | 333 | EventNameIndex.KEY, project |
330 | 334 | ); |
| 335 | + // Filter all events declared only for tests. |
| 336 | + events.removeIf(event -> { |
| 337 | + final Collection<VirtualFile> files = FileBasedIndex.getInstance() |
| 338 | + .getContainingFiles( |
| 339 | + EventNameIndex.KEY, |
| 340 | + event, |
| 341 | + GlobalSearchScope.allScope(project) |
| 342 | + ); |
| 343 | + final List<VirtualFile> realObservers = new ArrayList<>(); |
| 344 | + |
| 345 | + for (final VirtualFile file : files) { |
| 346 | + if (!MagentoTestSourceFilter.isTestSources(file, project)) { |
| 347 | + realObservers.add(file); |
| 348 | + } |
| 349 | + } |
| 350 | + |
| 351 | + return realObservers.isEmpty(); |
| 352 | + }); |
331 | 353 | this.eventName = new FilteredComboBox(new ArrayList<>(events)); |
332 | 354 | } |
333 | 355 | } |
0 commit comments