Skip to content

Commit d4d2c3f

Browse files
committed
cleanup
1 parent 89d1d05 commit d4d2c3f

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

src/fs_service.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,8 @@ impl FileSystemService {
409409
/// # Arguments
410410
/// * `root_path` - The root directory to start the search from.
411411
/// * `pattern` - A glob pattern to match file names (case-insensitive). If no wildcards are provided,
412-
/// the pattern is wrapped in `*` for partial matching.
413-
/// * `exclude_patterns` - A list of glob patterns to exclude paths (case-sensitive). If a pattern
414-
/// lacks wildcards, it is wrapped in `*` for partial matching.
412+
/// the pattern is wrapped in '*' for partial matching.
413+
/// * `exclude_patterns` - A list of glob patterns to exclude paths (case-sensitive).
415414
///
416415
/// # Returns
417416
/// A `ServiceResult` containing a vector of`walkdir::DirEntry` objects for matching files,
@@ -431,10 +430,8 @@ impl FileSystemService {
431430
///
432431
/// # Arguments
433432
/// * `root_path` - The root directory to start the search from.
434-
/// * `pattern` - A glob pattern to match file names. If no wildcards are provided,
435-
/// the pattern is wrapped in `**/*{pattern}*` for partial matching.
436-
/// * `exclude_patterns` - A list of glob patterns to exclude paths (case-sensitive). If a pattern
437-
/// lacks wildcards, it is wrapped in `*` for partial matching.
433+
/// * `pattern` - A glob pattern to match file names. If no wildcards are provided, the pattern is wrapped in `**/*{pattern}*` for partial matching.
434+
/// * `exclude_patterns` - A list of glob patterns to exclude paths (case-sensitive).
438435
///
439436
/// # Returns
440437
/// A `ServiceResult` containing an iterator yielding `walkdir::DirEntry` objects for matching files,
@@ -767,9 +764,9 @@ impl FileSystemService {
767764
/// before the start position of the `match`, and extends up to `max_length` characters
768765
/// If the snippet does not include the beginning or end of the original line, ellipses (`"..."`) are added
769766
/// to indicate the truncation.
770-
pub fn extract_snippet<'a>(
767+
pub fn extract_snippet(
771768
&self,
772-
line: &'a str,
769+
line: &str,
773770
match_result: Match,
774771
max_length: Option<usize>,
775772
backward_chars: Option<usize>,
@@ -812,12 +809,12 @@ impl FileSystemService {
812809
let files_iter = self.search_files_iter(
813810
root_path.as_ref(),
814811
pattern.to_string(),
815-
exclude_patterns.to_owned().unwrap_or(vec![]),
812+
exclude_patterns.to_owned().unwrap_or_default(),
816813
)?;
817814

818815
let results: Vec<FileSearchResult> = files_iter
819816
.filter_map(|entry| {
820-
self.content_search(&query, entry.path(), Some(is_regex))
817+
self.content_search(query, entry.path(), Some(is_regex))
821818
.ok()
822819
.and_then(|v| v)
823820
})

src/tools/search_files_content.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,12 @@ impl SearchFilesContentTool {
7676
ServiceError::FromString("No matches found in the files content.".into()),
7777
)));
7878
}
79-
return Ok(CallToolResult::text_content(
79+
Ok(CallToolResult::text_content(
8080
params.format_result(results),
8181
None,
82-
));
82+
))
8383
}
84-
Err(err) => {
85-
return Ok(CallToolResult::with_error(CallToolError::new(err)));
86-
}
87-
};
84+
Err(err) => Ok(CallToolResult::with_error(CallToolError::new(err))),
85+
}
8886
}
8987
}

tests/test_fs_service.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ async fn test_snippet_back_chars() {
999999
// larger text, truncates at the end
10001000
let line = "this is a long enough line for testing match in middles .";
10011001
let m = Match::new(40, 45);
1002-
let result = service.extract_snippet(&line, m, Some(20), Some(5));
1002+
let result = service.extract_snippet(line, m, Some(20), Some(5));
10031003
assert!(result.starts_with("..."));
10041004
assert!(result.ends_with("..."));
10051005
assert!(result.contains("match"));
@@ -1081,13 +1081,13 @@ fn search_files_content() {
10811081
);
10821082

10831083
fs::copy("/Users/ahashemi/Ali/proj/rust-mcp-stack/rust-mcp-filesystem/target/debug/librust_mcp_filesystem.d",
1084-
&temp_dir.as_path().join("dir_search").join("xyz.txt")).unwrap();
1084+
temp_dir.as_path().join("dir_search").join("xyz.txt")).unwrap();
10851085

10861086
let query = r#"Watso\d*n"#;
10871087

10881088
let results = service
10891089
.search_files_content(
1090-
&temp_dir.as_path().join("dir_search"),
1090+
temp_dir.as_path().join("dir_search"),
10911091
"*.txt",
10921092
query,
10931093
true,

0 commit comments

Comments
 (0)