Crate ide_ssr

Crate ide_ssr 

Source
Expand description

Structural Search Replace

Allows searching the AST for code that matches one or more patterns and then replacing that code based on a template.

Modulesยง

errors ๐Ÿ”’
Code relating to errors produced by SSR.
fragments ๐Ÿ”’
When specifying SSR rule, you generally want to map one kind of thing to the same kind of thing: path to path, expression to expression, type to type.
from_comment ๐Ÿ”’
This module allows building an SSR MatchFinder by parsing the SSR rule from a comment.
matching ๐Ÿ”’
This module is responsible for matching a search pattern against a node in the AST. In the process of matching, placeholder values are recorded.
nester ๐Ÿ”’
Converts a flat collection of matches into a nested form suitable for replacement. When there are multiple matches for a node, or that overlap, priority is given to the earlier rule. Nested matches are only permitted if the inner match is contained entirely within a placeholder of an outer match.
parsing ๐Ÿ”’
This file contains code for parsing SSR rules, which look something like foo($a) ==>> bar($b). We first split everything before and after the separator ==>>. Next, both the search pattern and the replacement template get tokenized by the Rust tokenizer. Tokens are then searched for placeholders, which start with $. For replacement templates, this is the final form. For search patterns, we go further and parse the pattern as each kind of thing that we can match. e.g. expressions, type references etc.
replacing ๐Ÿ”’
Code for applying replacement templates for matches that have previously been found.
resolving ๐Ÿ”’
This module is responsible for resolving paths within rules.
search ๐Ÿ”’
Searching for matches.

Structsยง

Match
Information about a match that was found.
MatchDebugInfo
MatchFinder
Searches a crate for pattern matches and possibly replaces them with something else.
SsrError
SsrMatches
SsrPattern
SsrRule

Functionsยง

ssr_from_comment
Attempts to build an SSR MatchFinder from a comment at the given file range. If successful, returns the MatchFinder and a TextRange covering comment.