简体   繁体   English

如何排除目录模式被 PhpStorm 索引?

[英]How to exclude a pattern of directories from being indexed by PhpStorm?

I am doing a massive (next-major-version) refactoring of an ecosystem that involves a heapload of packages.我正在对涉及大量软件包的生态系统进行大规模(下一个主要版本)重构。

In this stage, all packages are loaded from a path<\/code> ( packages\/*<\/code> ) repo.在这个阶段,所有的包都是从一个path<\/code> ( packages\/*<\/code> ) repo 加载的。 Thus, all packages, when required, are symlinked into the requiring package vendor<\/code> directory.因此,在需要时,所有包都被符号链接到需要的包vendor<\/code>目录中。 This creates eventually a nested vendor\/<vendor>\/<package>\/vendor\/<vendor>\/<other_package>\/.....<\/code> structure.这最终会创建一个嵌套的vendor\/<vendor>\/<package>\/vendor\/<vendor>\/<other_package>\/.....<\/code>结构。 PhpStorm tries to index all of this. PhpStorm 试图索引所有这些。

I have two problems with it:我有两个问题:

  1. It takes forever它需要永远<\/li>
  2. It throws off static inspection: finds multiple implementations of the same class (because in depth there are multiple symlinks to the same package).它抛弃了静态检查:找到同一个类的多个实现(因为深入到同一个包有多个符号链接)。 It can find some ghost definitions of a class in a forgotten vendor<\/code> directory that will not actually be present when doing a clean composer install without symlinks.它可以在一个被遗忘的vendor<\/code>目录中找到一些类的幽灵定义,在没有符号链接的情况下进行干净的作曲家安装时,这些定义实际上并不存在。<\/li><\/ol>

    Is there a way to exclude vendor\/*\/*\/vendor\/<\/code> from indexing?有没有办法从索引中排除vendor\/*\/*\/vendor\/<\/code> ?

    "

I finally ended up writing a composer plugin that, in the .idea\/*.xml<\/code> files:我终于写了一个作曲家插件,在.idea\/*.xml<\/code>文件中:

  • <component name="ComposerSettings" updatePackages="false"><\/code> in workspace.xml<\/code> <component name="ComposerSettings" updatePackages="false"><\/code>在workspace.xml<\/code><\/li>
  • Adds an <excludeFolder><\/code> for every composer package in project.iml\/module\/component\/content<\/code>project.iml\/module\/component\/content<\/code>每个 composer 包添加一个<excludeFolder><\/code><\/li>
  • Adds <sourceFolder><\/code> s for every package source root(s) based on the package's composer.json<\/code> autoload<\/code> section in project.iml\/module\/component\/content<\/code>根据project.iml\/module\/component\/content<\/code>包的composer.json<\/code> autoload<\/code>部分,为每个包源根目录添加<sourceFolder><\/code><\/li><\/ul>

    This seems a sensible workaround for the moment... although it's fragile with respect to changing package source paths, most packages have only one source root, src<\/code> and that isn't likely to change any time soon.目前这似乎是一个明智的解决方法......虽然它在更改包源路径方面很脆弱,但大多数包只有一个源根目录src<\/code>并且不太可能很快改变。

    "

I had a similar problem.我有一个类似的问题。 No matter what I´ve excluded in some settings, it didn´t worked as intented.无论我在某些设置中排除了什么,它都没有按预期工作。 Deactivating "indexer.follows.symlinks" in the registry only worked sometimes (for unknown reasons).在注册表中停用“indexer.follows.symlinks”有时会起作用(原因不明)。

The plugin "Exclude Symlinks" finally worked.插件“排除符号链接”终于起作用了。

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

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