Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does Visual Studio Code cache Java dependency information for autocomplete?

I'm using VS Code to write Java, with the various Red Hat and Microsoft extensions installed.

I have two projects, A and B. I publish snapshots (with Gradle) of Project A to a Nexus repository. Project B (also using Gradle) has a reference to the current snapshot of project A in that Nexus repository.

If I use the command line to publish project A, then compile project B, everything compiles OK. But when I return to Visual Studio Code, new methods I added to project A aren't shown in Intellisense. They show up as errors.

I feel like VS Code must be caching its view of the dependency somewhere, and if I could delete that cache, it would be forced to rescan the dependency. But where is that cache? Or is there another way to force VS Code to update its Intellisense? (Exiting VS Code and restarting doesn't do it.)

I tried clearing out the contents of Cache and CachedData in C:\Users\[myusername]\AppData\Roaming\Code, but that didn't help.

like image 695
Ryan Lundy Avatar asked Jan 26 '23 19:01

Ryan Lundy


1 Answers

There's a command that can refresh the Java autocomplete information automatically:

java.clean.workspace

You can use Keyboard Shortcuts to bind it to some memorable keys. (Warning: It takes a while to refresh the workspace afterwards.)

If you need to do it manually for some reason:

In this folder...

%USERPROFILE%\AppData\Roaming\Code\User\workspaceStorage

...VS Code creates a lot of small databases with the cached information for your projects. The folders there all have GUID names, but a workspace.json file in the root of each one shows what project it belongs to, like this:

{
  "folder": "file:///c%3A/path/to/my/folderforthisproject"
}

I wiped out the whole workspaceStorage folder, but it pretty clearly would have been sufficient to delete only the folder for my project.

like image 96
Ryan Lundy Avatar answered Jan 29 '23 09:01

Ryan Lundy