Shopify / theme-check

The Ultimate Shopify Theme Linter
Other
338 stars 95 forks source link

Define the domain for the `theme-liquid-docs` files #643

Closed karreiro closed 2 years ago

karreiro commented 2 years ago

This PR introduces the domain for the theme-liquid-docs files.

We're introducing them as a ScopeIndex, so we may rely on it in other use cases than the documentation. Still, this PR also introduces the documentation module to support the language server.

Each kind of scope, in the ScopeIndex, is lazy loaded. Here's some early bench marks:

== Documentation.filter_doc('size')
1st call ~> 1.918ms
2nd call ~> 0.008ms
3rd call ~> 0.007ms

== Documentation.tag_doc('tablerow')
1st call ~> 0.540ms
2nd call ~> 0.004ms
3rd call ~> 0.002ms

== Documentation.object_doc('product')
1st call ~> 9.987ms
2nd call ~> 0.006ms
3d call  ~> 0.005ms

== Documentation.object_property_doc('product', 'available')
1st call ~> 9.799ms
2nd call ~> 0.012ms
3rd call ~> 0.017ms

Considering we're targeting 100ms (as a strict limit) and that the whole index doesn't reach 2MB in memory, I believe we may proceed with this implementation for now. Also, I believe we might warmup the ScopeIndex at the startup of the language server.

--

⚠️ Please, ignore the ScopeIndex#download_files method -- it's a temporary implementation to support the development of this feature.