Currently AGTree assigns a single syntax value to AST nodes, choosing from: Common, AdGuard, UblockOrigin, or AdblockPlus. However, this model is not accurate enough for many real-world scenarios.
Problem 1: Incorrect fallback to Common
When a feature-specific detector is disabled (e.g., uBlock syntax detection is turned off), AGTree assigns Common as the syntax.
Example AGTree detects uBlock syntax for the following rule:
foo.com##:matches-path(/foo) .foo
But if the user disables uBO parsing, AGTree sets the syntax to Common, even though the actual syntax is unknown, because the relevant detection step was skipped.
In such cases, the correct value should be Unknown, not Common.
Problem 2: Mixed or ambiguous syntax is forced into Common
For example:
!#if (adguard && !ext_abp)
This expression is valid in AdGuard and uBlock, but AGTree still categorizes it as Common.
However, “common” is not accurate here — the rule is simply compatible with multiple products, but not all.
Proposed solution
Instead of a single enum-like syntax value, the syntax should:
- Be an array or a bitflag representing all compatible syntaxes.
- Example: ["AdGuard", "UblockOrigin"]
- Use Unknown when syntax detection could not run or was intentionally skipped.
- Remove Common entirely.
- Whether something is effectively “common” can be inferred automatically if all supported products appear in the syntax list.
Summary
- syntax = Unknown → detection incomplete or skipped
- syntax = ["AdGuard", "UblockOrigin"] → compatible with multiple products
- “Common” no longer exists, because it becomes derivable (all products listed)
This change would significantly improve the accuracy of AGTree’s syntax metadata and allow downstream tools (like AGLint) to reason about compatibility more precisely.
Currently AGTree assigns a single syntax value to AST nodes, choosing from:
Common,AdGuard,UblockOrigin, orAdblockPlus. However, this model is not accurate enough for many real-world scenarios.Problem 1: Incorrect fallback to Common
When a feature-specific detector is disabled (e.g., uBlock syntax detection is turned off), AGTree assigns
Commonas the syntax.Example AGTree detects uBlock syntax for the following rule:
But if the user disables uBO parsing, AGTree sets the syntax to
Common, even though the actual syntax is unknown, because the relevant detection step was skipped.In such cases, the correct value should be
Unknown, notCommon.Problem 2: Mixed or ambiguous syntax is forced into
CommonFor example:
This expression is valid in AdGuard and uBlock, but AGTree still categorizes it as
Common.However, “common” is not accurate here — the rule is simply compatible with multiple products, but not all.
Proposed solution
Instead of a single enum-like syntax value, the syntax should:
Summary
This change would significantly improve the accuracy of AGTree’s syntax metadata and allow downstream tools (like AGLint) to reason about compatibility more precisely.