EliotVU / UnrealScript-Language-Service

Bringing a work-in-progress intelliSense to ye olde UnrealScript :)
MIT License
48 stars 9 forks source link

[Bug]: No symbols found #157

Closed Shtoyan closed 1 year ago

Shtoyan commented 1 year ago

Describe the bug

After 0.6.0 symbols started to appear in Outline tab. But they behave quite strangely:

You can fix it by editing-saving the file or switching to other classes several times.

Screenshots

Not a screenshot but a short video demonstration: https://youtu.be/h22MRGMKCwI

Shtoyan commented 1 year ago

And a little post scriptum: seems like extension parses the document for symbols on each file switch / reopen. Maybe change it, so it triggers only on file modification?

EliotVU commented 1 year ago

This could definitely be done better, but basically VSCode is waiting for the server to respond as it is still indexing all the dependencies, which is why it's sometimes not showing up, some classes have a dependency with even more dependencies, so it can take quite a while before it is able to respond to the symbols request.

You can see what the server is doing under "Output > UnrealScript" to confirm.

EliotVU commented 1 year ago

I have two solutions for this that may make this more responsive:

  1. Respond as soon as the document has sufficient data to feedback the symbols data.
  2. As request, re-parse the entire document and just collect the symbols from the AST, bypassing the indexation of the document as we don't need any semantics here. This however is a bit wasteful :)
EliotVU commented 1 year ago

And a little post scriptum: seems like extension parses the document for symbols on each file switch / reopen. Maybe change it, so it triggers only on file modification?

This was done by design to ensure that the server is working the correct up-to-date document, for instance if you open a document and make some unsaved changes, and proceed to close this document, the server will re-process the document without any of the unsaved changes.

Surely this can be optimized, but it is not crucial as it has almost no impact on performance.

Shtoyan commented 1 year ago

What comes to my mind at first - cache everything in the workspace? Most of the files, especially the game source code that you make mods for, never change. So you can just check the md5-file date and use the cached dependency and symbol tree. It will speed up the startup and new file opening significantly.

But honestly, I don't know how it's done and what's the best practice / the easiest way to do it in VSCode, so up to you, I guess.

EliotVU commented 1 year ago

Yeah, but this is out of scope for now, as the current approach may still be changed drastically, it would be a lot of work to keep a persisted cache compatible.

I solved this by waiting for the document to be indexed before the server sends a result of symbols. This fixes the issue where a list of symbols never gets retrieved.

However this may still take (seconds) if the server is indexing multiple documents, this can definitely be improved on later, by responding right before indexing as we don't need the all the info that gets indexed.

Shtoyan commented 1 year ago

This fixes the issue where a list of symbols never gets retrieved.

This is fine too, I'm used to wait a little bit for indexing. Thanks!