Struct ra_ap_ide_ssr::MatchFinder
source · pub struct MatchFinder<'db> { /* private fields */ }
Expand description
Searches a crate for pattern matches and possibly replaces them with something else.
Implementations§
source§impl<'db> MatchFinder<'db>
impl<'db> MatchFinder<'db>
sourcepub fn in_context(
db: &'db RootDatabase,
lookup_context: FilePosition,
restrict_ranges: Vec<FileRange>
) -> Result<MatchFinder<'db>, SsrError>
pub fn in_context( db: &'db RootDatabase, lookup_context: FilePosition, restrict_ranges: Vec<FileRange> ) -> Result<MatchFinder<'db>, SsrError>
Constructs a new instance where names will be looked up as if they appeared at
lookup_context
.
sourcepub fn at_first_file(
db: &'db RootDatabase
) -> Result<MatchFinder<'db>, SsrError>
pub fn at_first_file( db: &'db RootDatabase ) -> Result<MatchFinder<'db>, SsrError>
Constructs an instance using the start of the first file in db
as the lookup context.
sourcepub fn add_rule(&mut self, rule: SsrRule) -> Result<(), SsrError>
pub fn add_rule(&mut self, rule: SsrRule) -> Result<(), SsrError>
Adds a rule to be applied. The order in which rules are added matters. Earlier rules take precedence. If a node is matched by an earlier rule, then later rules won’t be permitted to match to it.
sourcepub fn edits(&self) -> IntMap<FileId, TextEdit>
pub fn edits(&self) -> IntMap<FileId, TextEdit>
Finds matches for all added rules and returns edits for all found matches.
sourcepub fn add_search_pattern(
&mut self,
pattern: SsrPattern
) -> Result<(), SsrError>
pub fn add_search_pattern( &mut self, pattern: SsrPattern ) -> Result<(), SsrError>
Adds a search pattern. For use if you intend to only call find_matches_in_file
. If you
intend to do replacement, use add_rule
instead.
sourcepub fn matches(&self) -> SsrMatches
pub fn matches(&self) -> SsrMatches
Returns matches for all added rules.
sourcepub fn debug_where_text_equal(
&self,
file_id: FileId,
snippet: &str
) -> Vec<MatchDebugInfo>
pub fn debug_where_text_equal( &self, file_id: FileId, snippet: &str ) -> Vec<MatchDebugInfo>
Finds all nodes in file_id
whose text is exactly equal to snippet
and attempts to match
them, while recording reasons why they don’t match. This API is useful for command
line-based debugging where providing a range is difficult.
Auto Trait Implementations§
impl<'db> !Freeze for MatchFinder<'db>
impl<'db> !RefUnwindSafe for MatchFinder<'db>
impl<'db> !Send for MatchFinder<'db>
impl<'db> !Sync for MatchFinder<'db>
impl<'db> Unpin for MatchFinder<'db>
impl<'db> !UnwindSafe for MatchFinder<'db>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Cast for T
impl<T> Cast for T
source§fn cast<U>(self, interner: <U as HasInterner>::Interner) -> Uwhere
Self: CastTo<U>,
U: HasInterner,
fn cast<U>(self, interner: <U as HasInterner>::Interner) -> Uwhere
Self: CastTo<U>,
U: HasInterner,
U
using CastTo
.