Skip to content

Commit e577b22

Browse files
committed
Fixing build errors
1 parent 2ddc9b3 commit e577b22

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+3269
-1971
lines changed

crates/cli/src/cli.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ use std::path::PathBuf;
1010
pub struct Cli {
1111
#[command(subcommand)]
1212
pub command: Commands,
13-
13+
1414
/// Enable verbose output
1515
#[arg(short, long)]
1616
pub verbose: bool,
17-
17+
1818
/// Configuration file path
1919
#[arg(short, long)]
2020
pub config: Option<PathBuf>,
@@ -27,32 +27,32 @@ pub enum Commands {
2727
/// First file or directory to compare
2828
#[arg(value_name = "FILE1")]
2929
file1: PathBuf,
30-
30+
3131
/// Second file or directory to compare
3232
#[arg(value_name = "FILE2")]
3333
file2: PathBuf,
34-
34+
3535
/// Output format
3636
#[arg(short, long, default_value = "text")]
3737
format: OutputFormat,
38-
38+
3939
/// Compare directories recursively
4040
#[arg(short, long)]
4141
recursive: bool,
42-
42+
4343
/// Ignore whitespace changes
4444
#[arg(long)]
4545
ignore_whitespace: bool,
46-
46+
4747
/// Minimum similarity threshold (0.0-1.0)
4848
#[arg(long, default_value = "0.7")]
4949
threshold: f64,
50-
50+
5151
/// Output file path
5252
#[arg(short, long)]
5353
output: Option<PathBuf>,
5454
},
55-
55+
5656
/// Configuration management
5757
Config {
5858
#[command(subcommand)]
@@ -72,15 +72,15 @@ pub enum OutputFormat {
7272
pub enum ConfigAction {
7373
/// Show current configuration
7474
Show,
75-
75+
7676
/// Set configuration value
7777
Set {
7878
/// Configuration key
7979
key: String,
8080
/// Configuration value
8181
value: String,
8282
},
83-
83+
8484
/// Reset configuration to defaults
8585
Reset,
8686
}

crates/cli/src/commands/compare.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,30 @@ use anyhow::Result;
55

66
pub async fn run(cli: Cli) -> Result<()> {
77
println!("Compare command - placeholder implementation");
8-
9-
if let crate::cli::Commands::Compare {
10-
file1,
11-
file2,
8+
9+
if let crate::cli::Commands::Compare {
10+
file1,
11+
file2,
1212
format,
1313
recursive,
1414
ignore_whitespace,
1515
threshold,
1616
output,
17-
} = cli.command {
17+
} = cli.command
18+
{
1819
println!("Comparing {} and {}", file1.display(), file2.display());
1920
println!("Format: {:?}", format);
2021
println!("Recursive: {}", recursive);
2122
println!("Ignore whitespace: {}", ignore_whitespace);
2223
println!("Threshold: {}", threshold);
23-
24+
2425
if let Some(output_path) = output {
2526
println!("Output will be written to: {}", output_path.display());
2627
}
27-
28+
2829
// TODO: Implement actual comparison logic
2930
println!("Comparison complete (placeholder)");
3031
}
31-
32+
3233
Ok(())
3334
}

crates/cli/src/commands/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use anyhow::Result;
55

66
pub async fn run(cli: Cli) -> Result<()> {
77
println!("Config command - placeholder implementation");
8-
8+
99
if let crate::cli::Commands::Config { action } = cli.command {
1010
match action {
1111
crate::cli::ConfigAction::Show => {
@@ -24,6 +24,6 @@ pub async fn run(cli: Cli) -> Result<()> {
2424
}
2525
}
2626
}
27-
27+
2828
Ok(())
2929
}

crates/cli/src/main.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! Smart Code Diff CLI
2-
//!
2+
//!
33
//! Command-line interface for the smart code diffing tool.
44
55
use anyhow::Result;
@@ -20,11 +20,7 @@ async fn main() -> Result<()> {
2020
let cli = Cli::parse();
2121

2222
match cli.command {
23-
Commands::Compare { .. } => {
24-
commands::compare::run(cli).await
25-
}
26-
Commands::Config { .. } => {
27-
commands::config::run(cli).await
28-
}
23+
Commands::Compare { .. } => commands::compare::run(cli).await,
24+
Commands::Config { .. } => commands::config::run(cli).await,
2925
}
3026
}

crates/cli/src/output.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub struct OutputFormatter;
88
impl OutputFormatter {
99
pub fn format_diff_text(changes: &[String]) -> String {
1010
let mut output = String::new();
11-
11+
1212
for change in changes {
1313
if change.starts_with('+') {
1414
output.push_str(&format!("{}\n", change.green()));
@@ -18,17 +18,17 @@ impl OutputFormatter {
1818
output.push_str(&format!("{}\n", change));
1919
}
2020
}
21-
21+
2222
output
2323
}
24-
24+
2525
pub fn format_diff_json(changes: &[String]) -> Result<String, serde_json::Error> {
2626
serde_json::to_string_pretty(changes)
2727
}
28-
28+
2929
pub fn format_diff_html(changes: &[String]) -> String {
3030
let mut html = String::from("<div class=\"diff\">\n");
31-
31+
3232
for change in changes {
3333
if change.starts_with('+') {
3434
html.push_str(&format!(" <div class=\"addition\">{}</div>\n", change));
@@ -38,7 +38,7 @@ impl OutputFormatter {
3838
html.push_str(&format!(" <div class=\"context\">{}</div>\n", change));
3939
}
4040
}
41-
41+
4242
html.push_str("</div>");
4343
html
4444
}

crates/diff-engine/src/changes.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
//! Change classification and analysis
22
3-
use smart_diff_parser::{Change, ChangeType, CodeElement};
43
use serde::{Deserialize, Serialize};
4+
use smart_diff_parser::{Change, ChangeType, CodeElement};
55

66
/// Change classifier that categorizes detected changes
77
pub struct ChangeClassifier;
88

99
impl ChangeClassifier {
1010
/// Classify a change based on its characteristics
11-
pub fn classify_change(&self, source: Option<&CodeElement>, target: Option<&CodeElement>) -> ChangeType {
11+
pub fn classify_change(
12+
&self,
13+
source: Option<&CodeElement>,
14+
target: Option<&CodeElement>,
15+
) -> ChangeType {
1216
match (source, target) {
1317
(None, Some(_)) => ChangeType::Add,
1418
(Some(_), None) => ChangeType::Delete,
@@ -30,18 +34,20 @@ impl ChangeClassifier {
3034
(None, None) => ChangeType::Modify, // Shouldn't happen
3135
}
3236
}
33-
37+
3438
/// Detect if a change represents a function split
3539
pub fn detect_split(&self, source: &CodeElement, targets: &[CodeElement]) -> bool {
36-
targets.len() > 1 && targets.iter().all(|t| {
37-
t.name.contains(&source.name) || source.name.contains(&t.name)
38-
})
40+
targets.len() > 1
41+
&& targets
42+
.iter()
43+
.all(|t| t.name.contains(&source.name) || source.name.contains(&t.name))
3944
}
40-
45+
4146
/// Detect if changes represent a function merge
4247
pub fn detect_merge(&self, sources: &[CodeElement], target: &CodeElement) -> bool {
43-
sources.len() > 1 && sources.iter().all(|s| {
44-
s.name.contains(&target.name) || target.name.contains(&s.name)
45-
})
48+
sources.len() > 1
49+
&& sources
50+
.iter()
51+
.all(|s| s.name.contains(&target.name) || target.name.contains(&s.name))
4652
}
4753
}

crates/diff-engine/src/engine.rs

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
//! Main diff engine
22
3-
use crate::matching::FunctionMatcher;
4-
use crate::tree_edit::{TreeEditDistance, EditCost};
53
use crate::changes::ChangeClassifier;
4+
use crate::matching::FunctionMatcher;
65
use crate::refactoring::RefactoringDetector;
6+
use crate::tree_edit::{EditCost, TreeEditDistance};
7+
use serde::{Deserialize, Serialize};
78
use smart_diff_parser::{Function, MatchResult};
89
use thiserror::Error;
9-
use serde::{Deserialize, Serialize};
1010

1111
/// Main diff engine that orchestrates the comparison process
1212
pub struct DiffEngine {
@@ -41,10 +41,10 @@ pub struct DiffStatistics {
4141
pub enum DiffError {
4242
#[error("Comparison failed: {0}")]
4343
ComparisonFailed(String),
44-
44+
4545
#[error("Invalid input: {0}")]
4646
InvalidInput(String),
47-
47+
4848
#[error("Processing error: {0}")]
4949
ProcessingError(String),
5050
}
@@ -58,39 +58,55 @@ impl DiffEngine {
5858
refactoring_detector: RefactoringDetector::new(),
5959
}
6060
}
61-
61+
6262
/// Compare two sets of functions
63-
pub fn compare_functions(&self, source_functions: &[Function], target_functions: &[Function]) -> Result<DiffResult, DiffError> {
63+
pub fn compare_functions(
64+
&self,
65+
source_functions: &[Function],
66+
target_functions: &[Function],
67+
) -> Result<DiffResult, DiffError> {
6468
let start_time = std::time::Instant::now();
65-
69+
6670
// Match functions
67-
let match_result = self.function_matcher.match_functions(source_functions, target_functions);
68-
71+
let match_result = self
72+
.function_matcher
73+
.match_functions(source_functions, target_functions);
74+
6975
// Detect refactoring patterns
70-
let refactoring_patterns = self.refactoring_detector.detect_patterns(&match_result.changes);
71-
76+
let refactoring_patterns = self
77+
.refactoring_detector
78+
.detect_patterns(&match_result.changes);
79+
7280
// Calculate statistics
73-
let statistics = self.calculate_statistics(source_functions, target_functions, &match_result);
74-
81+
let statistics =
82+
self.calculate_statistics(source_functions, target_functions, &match_result);
83+
7584
let execution_time_ms = start_time.elapsed().as_millis() as u64;
76-
85+
7786
Ok(DiffResult {
7887
match_result,
7988
refactoring_patterns,
8089
execution_time_ms,
8190
statistics,
8291
})
8392
}
84-
85-
fn calculate_statistics(&self, source: &[Function], target: &[Function], match_result: &MatchResult) -> DiffStatistics {
93+
94+
fn calculate_statistics(
95+
&self,
96+
source: &[Function],
97+
target: &[Function],
98+
match_result: &MatchResult,
99+
) -> DiffStatistics {
86100
let functions_compared = source.len() + target.len();
87101
let functions_matched = match_result.mapping.len();
88102
let functions_added = match_result.unmatched_target.len();
89103
let functions_removed = match_result.unmatched_source.len();
90-
let functions_modified = match_result.changes.iter()
104+
let functions_modified = match_result
105+
.changes
106+
.iter()
91107
.filter(|c| matches!(c.change_type, smart_diff_parser::ChangeType::Modify))
92108
.count();
93-
109+
94110
DiffStatistics {
95111
functions_compared,
96112
functions_matched,

crates/diff-engine/src/lib.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
//! Smart Code Diff Engine
2-
//!
2+
//!
33
//! Core diff computation engine that implements tree edit distance algorithms,
44
//! function matching, and change classification.
55
6-
pub mod matching;
7-
pub mod tree_edit;
86
pub mod changes;
7+
pub mod engine;
8+
pub mod matching;
99
pub mod refactoring;
1010
pub mod similarity_scorer;
11-
pub mod engine;
11+
pub mod tree_edit;
1212

13-
pub use matching::{FunctionMatcher, MatchResult, SimilarityScore};
14-
pub use tree_edit::{TreeEditDistance, EditOperation, EditCost};
15-
pub use changes::{Change, ChangeType, ChangeClassifier};
13+
pub use changes::ChangeClassifier;
14+
pub use smart_diff_parser::{Change, ChangeType};
15+
pub use engine::{DiffEngine, DiffError, DiffResult};
16+
pub use matching::{FunctionMatcher, SimilarityScore};
17+
pub use smart_diff_parser::MatchResult;
1618
pub use refactoring::{RefactoringDetector, RefactoringPattern};
1719
pub use similarity_scorer::{
18-
SimilarityScorer, SimilarityScoringConfig, ComprehensiveSimilarityScore,
19-
ASTSimilarityScore, ContextSimilarityScore, SemanticSimilarityMetrics,
20-
MatchType, DetailedSimilarityBreakdown, SimilarityFactor
20+
ASTSimilarityScore, ComprehensiveSimilarityScore, ContextSimilarityScore,
21+
DetailedSimilarityBreakdown, MatchType, SemanticSimilarityMetrics, SimilarityFactor,
22+
SimilarityScorer, SimilarityScoringConfig,
2123
};
22-
pub use engine::{DiffEngine, DiffResult, DiffError};
24+
pub use tree_edit::{EditCost, EditOperation, TreeEditDistance};
2325

2426
/// Re-export commonly used types
2527
pub type Result<T> = std::result::Result<T, DiffError>;

0 commit comments

Comments
 (0)