summaryrefslogtreecommitdiff
path: root/support/texlab/src/util/regex_filter.rs
diff options
context:
space:
mode:
Diffstat (limited to 'support/texlab/src/util/regex_filter.rs')
-rw-r--r--support/texlab/src/util/regex_filter.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/support/texlab/src/util/regex_filter.rs b/support/texlab/src/util/regex_filter.rs
new file mode 100644
index 0000000000..f107ea16fe
--- /dev/null
+++ b/support/texlab/src/util/regex_filter.rs
@@ -0,0 +1,24 @@
+use crate::RegexPattern;
+
+pub fn filter(
+ text: &str,
+ allowed_patterns: &[RegexPattern],
+ ignored_patterns: &[RegexPattern],
+) -> bool {
+ if !allowed_patterns.is_empty()
+ && !allowed_patterns
+ .iter()
+ .any(|pattern| pattern.0.is_match(text))
+ {
+ return false;
+ }
+
+ if ignored_patterns
+ .iter()
+ .any(|pattern| pattern.0.is_match(text))
+ {
+ return false;
+ }
+
+ true
+}