-
Notifications
You must be signed in to change notification settings - Fork 224
Description
In a Linter you have access to all the tokens but you have to manually find which subsequence of the tokens match what you are primarily looking for.
In an ExprLinter you can build an Expr/Pattern which will match what you are primarily looking for automatically - but you don't have access to the tokens before or after it.
Sometimes you want to start looking for a main pattern of tokens but then need to examine the surrounding context to decide if it's what you're really looking for.
A Linter can do this but you lose the ability to use Exprs.
You can work around this because an ExprLinter does have access to the full source. You can re-tokenize the parts of the source before and after the matched_tokens but this is wasteful as it can be slow and it has already been done.
Another way to work around it is to include the context around the main pattern in the pattern - but this is very difficult to reason about well. At least for me.
Perhaps we could have a companion method to match_to_lint or perhaps we need a new trait with a match_to_lint_with_context?
Perhaps this can already be done and I'm just not aware of it?