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
sourceimpl<'db> MatchFinder<'db>
impl<'db> MatchFinder<'db>
sourcepub fn in_context(
db: &'db RootDatabase,
lookup_context: FilePosition,
restrict_ranges: Vec<FileRange>
) -> MatchFinder<'db>
pub fn in_context(
db: &'db RootDatabase,
lookup_context: FilePosition,
restrict_ranges: Vec<FileRange>
) -> MatchFinder<'db>
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) -> FxHashMap<FileId, TextEdit>
pub fn edits(&self) -> FxHashMap<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> !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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Cast for T
impl<T> Cast for T
fn cast<U>(self, interner: <U as HasInterner>::Interner) -> U where
Self: CastTo<U>,
U: HasInterner,
fn cast<U>(self, interner: <U as HasInterner>::Interner) -> U where
Self: CastTo<U>,
U: HasInterner,
Cast a value to type U
using CastTo
.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more