feat: add Igniter.Code.Pattern for ExAST-powered pattern matching#375
Merged
zachdaniel merged 3 commits intoash-project:mainfrom Apr 21, 2026
Merged
feat: add Igniter.Code.Pattern for ExAST-powered pattern matching#375zachdaniel merged 3 commits intoash-project:mainfrom
zachdaniel merged 3 commits intoash-project:mainfrom
Conversation
Contributor
|
Lets just make it a required dependency 😄 Easier to wrangle since igniter itself is typically an optional dependency used only in dev. This is awesome! ❤️ |
zachdaniel
reviewed
Apr 20, 2026
| end | ||
|
|
||
| defp elixir_source?(source) do | ||
| path = Rewrite.Source.get(source, :path) |
Contributor
There was a problem hiding this comment.
I believe there is a better way to check the source. There is like a source type or a source implementation.
Contributor
|
Okay, only one last small comment, just a nitpick really. |
zachdaniel
approved these changes
Apr 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
Igniter.Code.Pattern— pattern-based AST navigation and rewriting powered by ExAST as an optional dependency.Motivation
Writing zipper predicates for code search/replace is verbose:
With
Igniter.Code.Pattern:Particularly useful for upgrade tasks and broad API migrations.
API
Zipper-level (follows existing
Igniter.Code.*conventions):matches?(zipper, pattern)— predicate, for use inCommon.move_tocallbacksmove_to(zipper, pattern, opts)→{:ok, zipper} | :errorfind_all(zipper, pattern, opts)→[zipper]replace(zipper, pattern, replacement, opts)→{:ok, zipper} | :errorreplace_all(zipper, pattern, replacement, opts)→{:ok, zipper} | :errorProject-level:
replace_in_file(igniter, path, pattern, replacement, opts)→Igniter.t()replace_in_all_files(igniter, pattern, replacement, opts)→Igniter.t()All accept
:inside/:not_insideoptions for ancestor context filtering.Pattern syntax
Patterns are valid Elixir — strings, quoted expressions, or
~psigil:_or_nameexpr,name...Dependency
ExAST is optional — all functions gracefully return
:erroror[]when not available: