AdguardTeam / VscodeAdblockSyntax

Comprehensive extension to manage Adblock Syntax in VSCode: syntax highlighter, linter and much more. Available on the VSCode Marketplace.
https://marketplace.visualstudio.com/items?itemName=adguard.adblock
MIT License
70 stars 8 forks source link

Add support for `ext_devbuild` as `!#if` directive condition #68

Closed scripthunter7 closed 8 months ago

scripthunter7 commented 1 year ago

New syntax ("call-nothrow" and "ext_devbuild"):

example.com##+js(call-nothrow, Object.defineProperty)
!#if ext_devbuild
example.com##.ads
!#endif

https://github.com/gorhill/uBlock/commit/e93117cbb607472a830e1c0653dfbddde4c965fc

https://github.com/gorhill/uBlock/commit/464b54bbc6432fa07c85820b37f72b77f0855638 Should I open another issue?

Originally posted by @MasterKia in https://github.com/ameshkov/VscodeAdblockSyntax/issues/58#issuecomment-1483315289

scripthunter7 commented 1 year ago

@ameshkov The highlighter can tokenize the main syntactic elements. If we introduce the linter, I think we can remove most of the reserved/burned in variable names (logical expression variables, modifier names, etc) from the highlighter. I think it is enough for the highlighter to handle just the syntax itself, the concrete content is probably not necessary at this level. Only in specific cases should we deal with content, e.g. if should be followed by a logical expression, or safari_cb_affinity should be handled properly, but variable names/content can be generic.

That way Linguist will not mark as invalid any modifiers or variables introduced in the meantime, and the linter will detect when unsupported names are used by the user (in CLI / CI workflow / VSCode).

scripthunter7 commented 1 year ago

@MasterKia Now I see that the scriptlet in the highlighter is universally supported, there is no need to do anything there, the scriptlet you mentioned appears fine in the highlighter. However, the logical expression variable is marked as invalid, which is a problem.