pub struct CodeTools { /* private fields */ }Expand description
Code analysis service
Implementations§
Source§impl CodeTools
impl CodeTools
Sourcepub fn new(work_dir: Option<PathBuf>) -> CodeTools
pub fn new(work_dir: Option<PathBuf>) -> CodeTools
Create a new CodeTools.
If work_dir is set, relative paths passed to methods will be resolved
against it.
Sourcepub fn resolve_path(&self, path: &Path) -> PathBuf
pub fn resolve_path(&self, path: &Path) -> PathBuf
Resolve a path, making it absolute if relative and work_dir is set. Returns the original path if it’s already absolute or no work_dir is configured.
Sourcepub fn stats(&self, path: &Path) -> Result<CodeStats, AppError>
pub fn stats(&self, path: &Path) -> Result<CodeStats, AppError>
Get code statistics for a directory. Resolves relative paths using the configured work_dir.
Sourcepub fn repository_map(
&self,
root: &Path,
max_depth: usize,
) -> Result<RepositoryMap, AppError>
pub fn repository_map( &self, root: &Path, max_depth: usize, ) -> Result<RepositoryMap, AppError>
Generate a repository map for root up to max_depth.
Hidden entries and common non-source directories (target, node_modules)
are skipped.
Sourcepub fn symbols(&self, path: &Path) -> Result<Vec<Symbol>, AppError>
pub fn symbols(&self, path: &Path) -> Result<Vec<Symbol>, AppError>
Extract top-level Rust-like symbols from a single file.
This is a lightweight, regex-based approach meant for quick inspection. It is not a full parser.
Sourcepub fn references(
&self,
symbol: &str,
root: &Path,
) -> Result<Vec<ReferenceHit>, AppError>
pub fn references( &self, symbol: &str, root: &Path, ) -> Result<Vec<ReferenceHit>, AppError>
Find references to symbol under root.
This performs a simple word-boundary search (\bSYMBOL\b) and returns
line-level hits.
Sourcepub fn definition(
&self,
symbol: &str,
root: &Path,
) -> Result<Option<DefinitionHit>, AppError>
pub fn definition( &self, symbol: &str, root: &Path, ) -> Result<Option<DefinitionHit>, AppError>
Find the first definition of symbol under root.
The search is regex-based (functions/structs/enums/types/consts). If multiple definitions exist, the first encountered in directory traversal order is returned.
Sourcepub fn cargo_dependencies(
&self,
root: &Path,
) -> Result<Vec<DependencyGroup>, AppError>
pub fn cargo_dependencies( &self, root: &Path, ) -> Result<Vec<DependencyGroup>, AppError>
Parse Rust/Cargo dependencies from a Cargo.toml at root.
If root is a directory, this looks for root/Cargo.toml.
If root is a file, it is treated as the manifest.
Sourcepub fn cargo_clippy(
&self,
root: &Path,
fix: bool,
) -> Result<CommandResult, AppError>
pub fn cargo_clippy( &self, root: &Path, fix: bool, ) -> Result<CommandResult, AppError>
Run cargo clippy within root and return captured stdout/stderr.
This is intended for local developer tooling (CLI) and should not be used for untrusted inputs.
Sourcepub fn cargo_test(
&self,
root: &Path,
filter: Option<&str>,
) -> Result<CommandResult, AppError>
pub fn cargo_test( &self, root: &Path, filter: Option<&str>, ) -> Result<CommandResult, AppError>
Run cargo test within root and return captured stdout/stderr.
The optional filter is passed as the standard cargo test filter argument.
Sourcepub fn glob_search(
&self,
pattern: &str,
root: &Path,
max_results: usize,
) -> Result<Vec<GlobMatch>, AppError>
pub fn glob_search( &self, pattern: &str, root: &Path, max_results: usize, ) -> Result<Vec<GlobMatch>, AppError>
Find all files whose paths (relative to root) match the glob pattern.
Supports ** (any path depth), * (any filename chars), ? (one char).
Hidden directories and common build directories (target, node_modules) are skipped.
Sourcepub fn grep(
&self,
pattern: &str,
root: &Path,
file_glob: Option<&str>,
context_lines: usize,
case_sensitive: bool,
max_matches: usize,
) -> Result<Vec<GrepMatch>, AppError>
pub fn grep( &self, pattern: &str, root: &Path, file_glob: Option<&str>, context_lines: usize, case_sensitive: bool, max_matches: usize, ) -> Result<Vec<GrepMatch>, AppError>
Search file contents under root for lines matching the regex pattern.
file_glob: optional glob to restrict which files are searched (e.g.*.rs)context_lines: number of context lines to include before and after each matchcase_sensitive: whether the match is case-sensitivemax_matches: maximum number ofGrepMatchentries to return
Sourcepub fn batch_read(&self, paths: &[&str]) -> Vec<BatchReadEntry>
pub fn batch_read(&self, paths: &[&str]) -> Vec<BatchReadEntry>
Read multiple files in one call.
Each path is resolved through the configured work_dir. Failures are
captured per-entry rather than aborting the batch.
Sourcepub fn batch_edit(&self, edits: &[EditOp]) -> Vec<EditOpResult>
pub fn batch_edit(&self, edits: &[EditOp]) -> Vec<EditOpResult>
Apply multiple str-replace edits across files in one call.
Each EditOp replaces all occurrences of old_str with new_str in
the target file. Failures are captured per-entry rather than aborting
the batch, so callers must inspect EditOpResult::success for each entry.
Sourcepub fn outline(&self, path: &Path) -> Result<Vec<OutlineNode>, AppError>
pub fn outline(&self, path: &Path) -> Result<Vec<OutlineNode>, AppError>
Return a structured outline of all top-level symbols in path.
This is a lightweight wrapper around Self::symbols that strips the
absolute path from each entry so the result is presentation-friendly.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CodeTools
impl RefUnwindSafe for CodeTools
impl Send for CodeTools
impl Sync for CodeTools
impl Unpin for CodeTools
impl UnwindSafe for CodeTools
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().