iljapostnovs / VSCodeUI5Plugin

Visual Studio Code Extension for UI5 Development
Apache License 2.0
61 stars 6 forks source link

Regex too Large && Architecture Question #46

Closed timostark closed 4 years ago

timostark commented 4 years ago

Hi Ilja,

First of all: Impressive how much work is within this extension. Really a lot of parsing code :-) I have two issues atm: (1) I can not really run your plugin with bigger JS files. A RegEx too large is triggered. grafik calls (and causes exception) grafik

(2) I see you are doing a full parsing of the file in the registerCompletionItemProvider callback of vs-code. What I can not find is any kind of delta parsing, which is causing pretty bad performance (probably related to https://github.com/iljapostnovs/VSCodeUI5Plugin/issues/45 ).

See: getInstance, instantiating a new class: grafik

Are there any plans of a delta-parsing architecture? If not, for higher performance, you might also offer a minimal version which is just reading the sap.ui.define stuff to get standard auto complete (w/o user code). Alternative :full parsing of the current file only on save (or similar).

two questions: (3) Is there any reason, why you are parsing custom files on your own (instead of e.g. taking esprima ( https://github.com/jquery/esprima ), or acorn, which even has a "loose" mode ( https://github.com/acornjs/acorn/tree/master/acorn-loose ). It is not only about performance but also especially about stability (where such well established tools are ofc pretty good).

(4) Are you aware of https://github.com/SAP/ui5-typescript/tree/master/demos/demo-js (as alternative approach for auto-code-completion)? This basically uses jsdoc / ts type definitions for auto-complete.

Thanks again for your work, Timo

iljapostnovs commented 4 years ago

Hi,

It is a pitty that you have closed the issue right away, I didn't notice it :)

That was a nice suggestion from your side, thanks :) I have migrated the JS parser to acorn-loose and it works much faster and more stable.

Anwsering on your questions: 1) Should be solved with acorn-loose 2) Performance issues should be solved with acorn-loose 3) Reason was that I didn't find any parsers at the time when I started developing the plugin. The biggest issue was that all of them crashes with syntax errors, but acorn-loose is not, that helps a lot. Poor googling from my side I guess :) 4) Yes, I am aware, but I don't have time yet to research how exactly it is done.