You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was wondering if it is possible to index files outside project directory in order to have completion and code navigation. I'm working on projects that depend on other php files that are in a different location (these projects are not using composer).
Everyone here is using phpstorm and it is possible to add these files as 'External librairies' to have autocompletion of classes and methods and code navigation.
It's currently not possible.
I guess we could add this feature, like we did in order to index the stubs, but I'm not sure it's a good idea right now.
The issue is that I'm almost certain we still have features that do not rely on the index.
So if we add this possibility we will have inconsistent behavior because the features relying on the index will be aware of the external code while other features won't.
@dantleech You have a better vision of project as a all, do you think it would behave properly ?
Maybe we can add the feature but specify that it is only supported when used as a LSP server ?
Even though some RPC features start using the indexer so we will still have the same issue.
I realize that the indexer configuration as not been updated, only the configuration reference
Also, it's not possible to override or change the value of indexer.stub_paths because of:
I guess that if we don't want it to be configurable by the user we should not expose it in the configuration, since it's made as a list I think you intended it to be configurable.
So to resume:
Is it possible to add external sources to the indexer without having a strange behavior ?
If so, maybe we should rename the stub_paths to something like external_sources
Should the user be able to add its own stub paths ? (to fix the current behavior)
Yes, adding it to stub paths would accomplish what is required I think. Maybe it should be renamed, and maybe the phpstorn stubs can be added programatically rather than via config
We need to fix the initialization of the config first, if I understand how the config loader works, we first load the config from the config files, then we override the stubs then we load the extension configs.
Ah, I was on master, sorry. I switched to develop but it is still not working. It does not find the references in vim, nor with phpactor index:search. The index:build --reset command says there are 306 files in the index whereas there are around 5000 php files in the external libraries.
if you run index:build --reset --verbose you should at least see the phpstorm-stub files being indexed, the path may need to be absolute, what does phpactor config:dump --config-only | jq '.["indexer.stub_paths"]' say? (may need to brew|apt install jq or just parse the output manually. .)
Yes, the phpstorm-stub files are shown with the --verbose option. Here is the output of phpactor config:dump --config-only | jq '.["indexer.stub_paths"]':
Activity
camilledejoye commentedon Nov 1, 2020
Hi,
It's currently not possible.
I guess we could add this feature, like we did in order to index the stubs, but I'm not sure it's a good idea right now.
The issue is that I'm almost certain we still have features that do not rely on the index.
So if we add this possibility we will have inconsistent behavior because the features relying on the index will be aware of the external code while other features won't.
@dantleech You have a better vision of project as a all, do you think it would behave properly ?
Maybe we can add the feature but specify that it is only supported when used as a LSP server ?
Even though some RPC features start using the indexer so we will still have the same issue.
I realize that the indexer configuration as not been updated, only the configuration reference
Also, it's not possible to override or change the value of
indexer.stub_pathsbecause of:phpactor/lib/Phpactor.php
Line 79 in 6ee1603
I guess that if we don't want it to be configurable by the user we should not expose it in the configuration, since it's made as a list I think you intended it to be configurable.
So to resume:
stub_pathsto something likeexternal_sourcesdantleech commentedon Nov 1, 2020
Yes, adding it to stub paths would accomplish what is required I think. Maybe it should be renamed, and maybe the phpstorn stubs can be added programatically rather than via config
norival commentedon Nov 3, 2020
Hi! Thank you for your answers and all the details :) It would be great to have this feature. Is there any way I can help?
dantleech commentedon Nov 3, 2020
For now you could try setting:
camilledejoye commentedon Nov 3, 2020
We need to fix the initialization of the config first, if I understand how the config loader works, we first load the config from the config files, then we override the stubs then we load the extension configs.
norival commentedon Nov 3, 2020
It does not change
dantleech commentedon Nov 3, 2020
You'll need to do a --reset, e.g.
:CocCommand phpactor.reindexor$ phpactor index:build --resetnorival commentedon Nov 3, 2020
Ok, I tried to reset the index, but it is still the same. I tried to query with
phpactor index:queryand it does not find the references either.dantleech commentedon Nov 3, 2020
are you on
develop? inmasterstub_pathsdoes not work. Tryphpactor index:search(index:queryrequires FQNs - it not very well named)norival commentedon Nov 3, 2020
Ah, I was on
master, sorry. I switched todevelopbut it is still not working. It does not find the references in vim, nor withphpactor index:search. Theindex:build --resetcommand says there are 306 files in the index whereas there are around 5000 php files in the external libraries.dantleech commentedon Nov 3, 2020
if you run
index:build --reset --verboseyou should at least see thephpstorm-stubfiles being indexed, the path may need to be absolute, what doesphpactor config:dump --config-only | jq '.["indexer.stub_paths"]'say? (may need tobrew|apt install jqor just parse the output manually. .)norival commentedon Nov 3, 2020
Yes, the
phpstorm-stubfiles are shown with the--verboseoption. Here is the output ofphpactor config:dump --config-only | jq '.["indexer.stub_paths"]':I tried changing the value in the config file, and the output is always the same.
dantleech commentedon Nov 3, 2020
ah ok, then I misunderstood how it currently works:
phpactor/lib/Phpactor.php
Lines 79 to 81 in 6ee1603
we could append the stubs here if the key exists rather than overwriting -- that might be an intermediate solution.
norival commentedon Nov 3, 2020
Ok! I tried setting the paths directly here :
phpactor/lib/Phpactor.php
Lines 79 to 81 in 6ee1603
and the files are indexed! Completion and go to definition work fine :) I had to increase php's memory limit though.
Do not overwrite stub_paths config if key exists (#1122)
Master 17 (#1203)