Ctrl+click still search folders outside of root sources
I'm having to work with at like 12 different repos together in PHPStorm, and using Ctrl+click on a variable or function or class will still show every possible same-named thing in different files in different repos (since our previous developers just copied duplicate code to these various repos) rather than just look for files in the root source folder I'm in...
It also sometimes just jumps to a completely unrelated folder, with no drop-down choices, and deleting that folder from the project allows it to finally show different folder choices...
I need this to just search in the same root folder I'm in.
请先登录再写评论。
Hello,
What do you mean by root folder? A root of a project? Or a directory marked as a sources root?
PhpStorm works with all repos as with the single project so all declarations are considered to reside in the same space.
Is it suitable for you to work with a repo as with a single project? You can open repos as directories and use multiple PhpStorm windows for that so you'll be able to work with separate projects at once but they won't conflict.
This is the menu from right-clicking a folder in the Project:
The above folder happens not to be marked a root source folder (colored gray) because I don't need it to be; the others are marked roots, and have the "Unmark" option (and are colored blue).
Because of the way prior developers set up the environment (which I don't need to explain), it is easier for me to have all repo folders in one project than in multiple. I have marked each one as a "root source" folder so PHPStorm should stop considering folders outside of the one I'm in when I'm Ctrl+clicking or using Find Usages, but it doesn't always do that for some reason.
It's a giant pain in the butt trying to trace variables, methods, functions, and classes when the previous developers have duplicated many of them across various repos and PHPStorm shows files in these other repos as possible trace matches for the repo I'm in, when I've found that's usually not the case (if it is the case, it's OK for me to discover that manually than for PHPStorm to show me all possibilities outside of the root source folder).
It will be a bigger pain in the butt to keep switching Projects or have multiple Project windows open with these repos, especially when it appears PHPStorm has the ability to isolate them as root sources... but for some reason it isn't working 100% as it appears it should.
Is any of this making sense?
> I have marked each one as a "root source" folder so PHPStorm should stop considering folders outside of the one I'm in when I'm Ctrl+clicking or using Find Usages, but it doesn't always do that for some reason.
Unfortunately that's not how it works. PhpStorm won't exclude folders outside the one you in from completion.
You can exclude folders manually via Mark as > Excluded.
Mark as > Excluded from what? I'm reading this page - https://www.jetbrains.com/help/phpstorm/configuring-folders-within-a-content-root.html - but it says "Excluded folders are not involved in indexing and therefore they are ignored while searching, parsing, watching etc."... but I don't want them excluded from indexing or searching, I just want each repo folder to not be considered with others when trying to find variables, functions, classes, etc when Ctrl+clicking.
Is my issue being understood? I'm not seeing the solution here, and I simply thought marking each folder as 'root' source would make it sanctioned unto itself and not considered with other repos (so I'm not actually sure what marking them as 'root' did).
I set the top-level directory as "Source", because the doc said it would treat the sub-folders as their own namespaces, but Ctrl+clicking a variable still shows results from repos outside of the repo I'm in even though that repo never accesses the other repos... so I don't know how to get PHPStorm to treat this logically.
> I just want each repo folder to not be considered with others when trying to find variables, functions, classes, etc when Ctrl+clicking.
The only viable option here is to use Scopes (Preferences | Appearance & Behavior | Scopes): create 12 scopes for each of the project.
You can limit searches to selected scope in "Find in path/replace" and "Find usages". Ctrl+click navigation in some cases would still work the way it's working now.
So what benefit is setting the folders as root source doing if it's different than scopes? I'm not seeing that setting them as root sources is changing anything.
The whole point in terms of PHP here is PSR-0 support - for a source root, you can specify the root namespace so that Create PHP Class and other actions substituted, and you didn't have to do that manually.