简体   繁体   English

如何在 PhpStorm 搜索中设置文件名掩码以排除 *test* 文件 (PHPUnit)

[英]How to set filename mask in PhpStorm search to exclude *test* files (PHPUnit)

In The PhpStorm you can search to text in all files in the whole project -- just click Schift+F.在 PhpStorm 中,您可以在整个项目的所有文件中搜索文本——只需单击 Schift+F。 And you can set the filename mask there, like *.php您可以在那里设置文件名掩码,例如*.php

The test/phpunit folder is located in the project as well and is indexed for search. test/phpunit文件夹也位于项目中,并已编入索引以供搜索。 This is good and useful.这是好的和有用的。

But sometimes you need to search in source code only, not in the test files.但有时您只需要在源代码中搜索,而不是在测试文件中搜索。

It means that you should not disable those files from search index -- you need them.这意味着您不应该从搜索索引中禁用这些文件——您需要它们。

PHPStorm exclude files by mask from indexing PHPStorm 通过掩码从索引中排除文件

WebStorm/PhpStorm exclude file from search everywhere WebStorm/PhpStorm 从搜索中排除文件

You just need some ability to filter them out sometimes.您有时只需要一些过滤它们的能力。

I supposed to use the mask like " *[~^test]*.php " but it seems is not supported.我应该使用像“ *[~^test]*.php ”这样的掩码,但它似乎不受支持。

Any idea?任何想法?

Considering that the test files would normally be named like SomethingTest.php .. then exclusion mask would be .*Test.php .考虑到测试文件通常会被命名为SomethingTest.php .. 那么排除掩码将是.*Test.php

To combine multiple extensions just list them using comma , , eg *.php,.*test.php (search in.php files only but excluding test files)要组合多个扩展名,只需使用逗号列出它们,例如*.php,.*test.php (仅在.php 文件中搜索,但不包括测试文件)


PS If you need to make such search often, it may be more convenient to create and use custom Scope (it can also be used in many other places: Navigate To File/Class/Symbol; Project View panel, File Watchers etc.) PS 如果您需要经常进行此类搜索,创建和使用自定义 Scope可能更方便(它也可以在许多其他地方使用:导航到文件/类/符号;项目视图面板,文件观察器等)

Scope is more flexible as it allows to select specific folders and have more complex include or exclude patterns in general (as it can work with folder names as well). Scope 更灵活,因为它允许 select 特定文件夹,并且通常具有更复杂的包含或排除模式(因为它也可以与文件夹名称一起使用)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM