-
Notifications
You must be signed in to change notification settings - Fork 73
File content is fetched multiple times #96
Description
When adding a list of fetched content to RemoteFileSystem.getTextDocumentContent()
and logging when content is fetched twice, you can see that apparently every single file is fetched at least twice (without having done any request besides initialize
).
My suspicion is that this is because on initialize
ensureFilesForWorkspaceSymbols()
is called, whose result promise is memoized, but other places in the code (ensureFilesForHoverAndDefinition()
? ProjectConfiguration.init()
?) fetch them directly again.
Solution
Eventually, these file contents will be added to the InMemoryFileSystem
. This should be the source of truth for file contents and whether they are loaded or not. One difficulty I see here is the "dummy" placeholder that is added for some files (ideally this should be removed).
I want InMemoryFileSystem
to be able to hold the workspace structure (as returned from workspace/files
), but only optionally hold a content for each file.
Additional benefit: RemoteFileSystem.getWorkspaceFiles()
is currently memoized, instead should only be used to hydrate the structure of InMemoryFileSystem
once (that is, *.ts, tsconfig.json, package.json), contents in the background and then all parts of the codebase should just interact with that (and invalidate / modify it as needed).
TODO
- Extend
InMemoryFileSystem
to differentiate whether a file does not exist or is just not loaded - Find out which functions call the remote file system to fetch files directly
- Adapt them
- Remove memoization in
RemoteFileSystem
and hydrate the structure once on initialization - Make
InMemoryFileSystem
available toTypeScriptService
and the build handler, remove direct usage ofRemoteFileSystem
(for other purposes than hydration)
Difficulties
ProjectManager
's,ProjectConfiguration
's andInMemoryFileSystem
's properties, methods and parameters are undocumented and I have a hard time understanding the semantics of each oneInMemoryFileSystem.entries
is justany
. It's hard for me to understand how the tree is typed.
wdyt @beyang @alexsaveliev