Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Intellisense option to parse all files of the project on startup in background #8935

Closed
juxeii opened this issue Feb 25, 2022 · 10 comments
Closed
Labels
Feature Request Language Service more info needed The issue report is not actionable in its current state parser
Milestone

Comments

@juxeii
Copy link

juxeii commented Feb 25, 2022

When the IDE CLion starts, it parses all documents once and probably creates some kind of cached index.
This means that when you open a file, all symbols and go to definition calls are more or less done in an instant.

Would it be possible to add some kind of option for this to happen in VSC?
Specifically, add an option for Intellisense to parse not only opened files on the fly, but parse all files(on the basis of e.g. compile_commands.json) after vsc startup.
For big projects I would rather wait longer after startup, than to wait a little each time I open a file before Intellisense updates.

@michelleangela
Copy link
Contributor

@juxeii

The extension's browse engine does tag parsing of all files in a project on startup to index symbols in a browse or symbol database. The files the extension parses can be seen in the Language Server logging (see https://code.visualstudio.com/docs/cpp/enable-logging-cpp#_enable-logging-for-the-language-server).

To clarify, is this new "IntelliSense option to parse all files" feature something different from the existing browse engine tag parsing? That is, would this new feature have IntelliSense engine compile the entire project on startup?

@michelleangela michelleangela added the more info needed The issue report is not actionable in its current state label Feb 25, 2022
@juxeii
Copy link
Author

juxeii commented Feb 25, 2022

When I open a file, the fire icon at the bottom shows that some parsing is ongoing.
My question is, can this parsing be avoided, such when you open any file of the project, no fire icon is shown?
Especially, when there were no edits made on the file.

@michelleangela
Copy link
Contributor

@sean-mcmanus could you comment on this one? I see there was a discussion related to this at #8881.

@juxeii
Copy link
Author

juxeii commented Feb 25, 2022

@michelleangela
#8881 is about some unnecessary reparsing of files.
I am asking about "avoiding the fire icon when opening new files" via some preparsing on startup.

@sean-mcmanus
Copy link
Contributor

sean-mcmanus commented Feb 26, 2022

The fire icon (IntelliSense parsing) is required when a document is opened -- it's parsing the TU, which isn't fully stored to disk. If you have C_Cpp.intelliSenseCacheSize > 0 then we do some caching of the header file contents in ipch files. Additional caching with manual pch is being tracked by #3628 , which could yield additional speedup. We could potentially generate ipch files in the background, but I'm not convinced that the cost would outweigh the benefit.

The tag parsing to generate global symbols, document symbols, and go to definition targets is already done in the background and saved to our database. However, an ongoing IntelliSense operation could block that database request from giving results sooner.

@juxeii
Copy link
Author

juxeii commented Feb 26, 2022

@sean-mcmanus
Yes, this blocking after startup would be the price to pay. This is somewhat what CLion does: it tells you that you have to wait until indexing is done, otherwise you will not get reliable results.
And an option would give users the choice of what they want after startup.

@coldear
Copy link

coldear commented Oct 3, 2022

I think it auto create index for files in the project, but not for dependencies that lives out side of the project folder. So you can't search for your dependencies (although they are in the compile_commands.json file). BTW, Clion creates index for these dependencies.

@fquinner
Copy link

This is the closest I could see to what I was looking for so weighing in here.

If I set:

            "browse": {
                "databaseFilename": "${default}"
            }

And watch the contents with something like:

watch "find  ~/.cache/vscode-cpptools/ipch/ -type f -name "*.ipch" -exec ls -l {} \;"

I can see the files getting indexed as they're opened. As a new user to vscode this did surprise me purely because there is a little spinner in the corner that's easy to miss (certainly on an ultrawide monitor :)) letting me know that indexing was happening.

The time to index each file in my project about 10-20 seconds. As someone trying out this functionality for the first time, I had assumed that this had in fact not worked at all when instead I was simply "impatient". Also I think databaseFilename was originally blank so it was doing this all the time so I assumed intellisense was simply not working correctly.

An option (even a Command Palette command rather than a mandatory slow startup command) to index all actual project files in the workspace would be brilliant.

@sean-mcmanus
Copy link
Contributor

@fquinner The browse.database property only affects the db file and it should default to ${default} already (which uses the C_Cpp.default.browse.databaseFilename setting) and doesn't affct the .ipch files.

@github-actions
Copy link

This issue has been closed because it needs more information and has not had recent activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 20, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Nov 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Feature Request Language Service more info needed The issue report is not actionable in its current state parser
Projects
None yet
Development

No branches or pull requests

5 participants