Serhioromano / vscode-st

Extension for VS Code to support Structured Text language.
https://marketplace.visualstudio.com/items?itemName=Serhioromano.vscode-st#overview
MIT License
141 stars 28 forks source link

Improve SymbolProvider.ts #27

Closed msftrncs closed 3 years ago

msftrncs commented 3 years ago

Overhaul of SymbolProvider.ts to more thoroughly process well known POU symbols excluding symbol discovery in comments or quoted text, and with recovery of parsing on syntax errors where ever possible.

References issue #25.

msftrncs commented 3 years ago

I've tested and it works fine. Although it works very slow. Anyway, could you please resubmit this PR against develop branch? I use Git Flow, so master is the latest release.

It might be slower for sure, but on my system with most the files I have used it with, including the test.st file, it populates the outline nearly instantly. The regex's are fairly complicated, and have to consume large amounts of the document carefully in order to insure they only find valid closing keywords/punctuation. As a reference, the VS Code TextMate grammar.ts file takes about 3 seconds to provide symbols for a 1500 line file. The test.st file loads symbols so fast it appears instantly for me, at 1000 lines. My machine is a 8th gen Core i7.

Serhioromano commented 3 years ago

Perfect! I'll make another review and release new version today.

msftrncs commented 3 years ago

I'm (was) going to force one more commit, cleaned some unneeded sections from regex to not skip over quoted strings where an identifier is expected.

I'll commit it up to the same branch. You can take a look at it at your leisure, as its really minor.