mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-04-24 17:12:16 +02:00
regex: print out final regex in trace mode
This is useful for debugging to see what regex is actually being run. We put this as a trace since the regex can be quite gnarly. (It is not pretty printed.)
This commit is contained in:
parent
9f15e3b671
commit
be7d6dd9ce
@ -34,6 +34,11 @@ impl CRLFMatcher {
|
|||||||
}
|
}
|
||||||
Ok(CRLFMatcher { regex, names })
|
Ok(CRLFMatcher { regex, names })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return the underlying regex used by this matcher.
|
||||||
|
pub fn regex(&self) -> &Regex {
|
||||||
|
&self.regex
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Matcher for CRLFMatcher {
|
impl Matcher for CRLFMatcher {
|
||||||
|
@ -50,9 +50,12 @@ impl RegexMatcherBuilder {
|
|||||||
if let Some(ref re) = fast_line_regex {
|
if let Some(ref re) = fast_line_regex {
|
||||||
trace!("extracted fast line regex: {:?}", re);
|
trace!("extracted fast line regex: {:?}", re);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let matcher = RegexMatcherImpl::new(&chir)?;
|
||||||
|
trace!("final regex: {:?}", matcher.regex());
|
||||||
Ok(RegexMatcher {
|
Ok(RegexMatcher {
|
||||||
config: self.config.clone(),
|
config: self.config.clone(),
|
||||||
matcher: RegexMatcherImpl::new(&chir)?,
|
matcher: matcher,
|
||||||
fast_line_regex: fast_line_regex,
|
fast_line_regex: fast_line_regex,
|
||||||
non_matching_bytes: non_matching_bytes,
|
non_matching_bytes: non_matching_bytes,
|
||||||
})
|
})
|
||||||
@ -370,6 +373,15 @@ impl RegexMatcherImpl {
|
|||||||
Ok(RegexMatcherImpl::Standard(StandardMatcher::new(expr)?))
|
Ok(RegexMatcherImpl::Standard(StandardMatcher::new(expr)?))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return the underlying regex object used.
|
||||||
|
fn regex(&self) -> &Regex {
|
||||||
|
match *self {
|
||||||
|
RegexMatcherImpl::Word(ref x) => x.regex(),
|
||||||
|
RegexMatcherImpl::CRLF(ref x) => x.regex(),
|
||||||
|
RegexMatcherImpl::Standard(ref x) => &x.regex,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This implementation just dispatches on the internal matcher impl except
|
// This implementation just dispatches on the internal matcher impl except
|
||||||
|
@ -55,6 +55,11 @@ impl WordMatcher {
|
|||||||
}
|
}
|
||||||
Ok(WordMatcher { regex, names, locs })
|
Ok(WordMatcher { regex, names, locs })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return the underlying regex used by this matcher.
|
||||||
|
pub fn regex(&self) -> &Regex {
|
||||||
|
&self.regex
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Matcher for WordMatcher {
|
impl Matcher for WordMatcher {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user