summaryrefslogtreecommitdiff
path: root/support/texlab/src/db
diff options
context:
space:
mode:
Diffstat (limited to 'support/texlab/src/db')
-rw-r--r--support/texlab/src/db/analysis.rs2
-rw-r--r--support/texlab/src/db/diagnostics.rs27
-rw-r--r--support/texlab/src/db/discovery.rs4
-rw-r--r--support/texlab/src/db/document.rs10
-rw-r--r--support/texlab/src/db/workspace.rs2
5 files changed, 17 insertions, 28 deletions
diff --git a/support/texlab/src/db/analysis.rs b/support/texlab/src/db/analysis.rs
index 79e81c963c..13b5bb1cb3 100644
--- a/support/texlab/src/db/analysis.rs
+++ b/support/texlab/src/db/analysis.rs
@@ -45,7 +45,7 @@ impl TexLink {
let import = latex::Import::cast(node)?;
let mut base_dir = import.directory()?.key()?.to_string();
- if !base_dir.ends_with("/") {
+ if !base_dir.ends_with('/') {
base_dir.push('/');
}
diff --git a/support/texlab/src/db/diagnostics.rs b/support/texlab/src/db/diagnostics.rs
index 81ed24fd2e..8abb856768 100644
--- a/support/texlab/src/db/diagnostics.rs
+++ b/support/texlab/src/db/diagnostics.rs
@@ -5,7 +5,7 @@ pub mod tex;
use lsp_types::{DiagnosticSeverity, NumberOrString, Range};
use rustc_hash::FxHashMap;
-use crate::{db::workspace::Workspace, Db};
+use crate::{db::workspace::Workspace, util, Db};
use super::document::{Document, Language};
@@ -139,24 +139,13 @@ pub fn collect_filtered(
}
if let Some(diagnostics) = all_diagnostics.get(document) {
- for diagnostic in diagnostics.iter() {
- if !options.allowed_patterns.is_empty()
- && !options
- .allowed_patterns
- .iter()
- .any(|pattern| pattern.0.is_match(&diagnostic.message))
- {
- continue;
- }
-
- if options
- .ignored_patterns
- .iter()
- .any(|pattern| pattern.0.is_match(&diagnostic.message))
- {
- continue;
- }
-
+ for diagnostic in diagnostics.iter().filter(|diag| {
+ util::regex_filter::filter(
+ &diag.message,
+ &options.allowed_patterns,
+ &options.ignored_patterns,
+ )
+ }) {
let source = match diagnostic.code {
DiagnosticCode::Tex(_) | DiagnosticCode::Bib(_) => "texlab",
DiagnosticCode::Log(_) => "latex-build",
diff --git a/support/texlab/src/db/discovery.rs b/support/texlab/src/db/discovery.rs
index 5986fcd888..12338f745e 100644
--- a/support/texlab/src/db/discovery.rs
+++ b/support/texlab/src/db/discovery.rs
@@ -110,12 +110,12 @@ pub fn source_dependency(
.as_deref()
.map_or(false, |dir| path.starts_with(dir))
})
- .flat_map(|path| Url::from_file_path(path))
+ .flat_map(Url::from_file_path)
.map(|uri| Location::new(db, uri));
for location in file_names
.iter()
- .filter_map(|file_name| base_dir.join(db, &file_name))
+ .filter_map(|file_name| base_dir.join(db, file_name))
.chain(distro_files)
{
match workspace.lookup(db, location) {
diff --git a/support/texlab/src/db/document.rs b/support/texlab/src/db/document.rs
index 1fc7d6880c..81ed22e916 100644
--- a/support/texlab/src/db/document.rs
+++ b/support/texlab/src/db/document.rs
@@ -36,10 +36,10 @@ impl Location {
}
}
- pub fn stem<'db>(self, db: &'db dyn Db) -> Option<&'db str> {
- let name = self.uri(db).path_segments()?.last()?;
- let stem = name.rsplit_once('.').map_or(name, |(stem, _)| stem);
- Some(stem)
+ pub fn stem(self, db: &dyn Db) -> Option<String> {
+ let path = self.uri(db).to_file_path().ok()?;
+ let stem = path.file_stem()?.to_str()?;
+ Some(String::from(stem))
}
pub fn join(self, db: &dyn Db, path: &str) -> Option<Location> {
@@ -126,7 +126,7 @@ pub struct Document {
impl Document {
pub fn edit(self, db: &mut dyn Db, range: TextRange, replace_with: &str) {
let mut text = self.contents(db).set_text(db).to(String::new());
- text.replace_range(std::ops::Range::<usize>::from(range), &replace_with);
+ text.replace_range(std::ops::Range::<usize>::from(range), replace_with);
self.contents(db).set_text(db).to(text);
self.set_cursor(db).to(range.start());
}
diff --git a/support/texlab/src/db/workspace.rs b/support/texlab/src/db/workspace.rs
index 8b4d755b09..123d415fd9 100644
--- a/support/texlab/src/db/workspace.rs
+++ b/support/texlab/src/db/workspace.rs
@@ -190,7 +190,7 @@ impl Workspace {
.unwrap_or(".")
.to_string();
- if !path.ends_with("/") {
+ if !path.ends_with('/') {
path.push('/');
}