Skip to content

Commit 5a16ee5

Browse files
chore: bump version to 0.2.4
1 parent 9104409 commit 5a16ee5

File tree

14 files changed

+70
-35
lines changed

14 files changed

+70
-35
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ chrono = { version = "0.4", features = ["serde"] }
3636
fuzzy-matcher = "0.3"
3737

3838
# Validation system dependencies
39-
raz-validation = { path = "raz-validation", version = "0.2.3" }
39+
raz-validation = { path = "raz-validation", version = "0.2.4" }
4040

4141
[profile.release]
4242
opt-level = 3

raz-adapters/cli/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "raz-cli"
3-
version = "0.2.3"
3+
version = "0.2.4"
44
edition = "2024"
55
description = "Universal command runner for Rust - Run any Rust file from anywhere with cursor-aware test targeting and override persistence"
66
license = "MIT"
@@ -18,10 +18,10 @@ name = "raz"
1818
path = "src/main.rs"
1919

2020
[dependencies]
21-
raz-common = { path = "../../raz-common", version = "0.2.3" }
22-
raz-core = { path = "../../raz-core", version = "0.2.3" }
23-
raz-config = { path = "../../raz-config", version = "0.2.3" }
24-
raz-override = { path = "../../raz-override", version = "0.2.3" }
21+
raz-common = { path = "../../raz-common", version = "0.2.4" }
22+
raz-core = { path = "../../raz-core", version = "0.2.4" }
23+
raz-config = { path = "../../raz-config", version = "0.2.4" }
24+
raz-override = { path = "../../raz-override", version = "0.2.4" }
2525
clap = { workspace = true }
2626
tokio = { workspace = true }
2727
serde_json = { workspace = true }

raz-adapters/vscode/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

raz-adapters/vscode/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"author": "Uriah Galang <[email protected]>",
66
"icon": "images/raz-logo.gif",
77
"license": "MIT",
8-
"version": "0.2.3",
8+
"version": "0.2.4",
99
"repository": {
1010
"type": "git",
1111
"url": "https://github.com/codeitlikemiley/raz"

raz-common/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "raz-common"
3-
version = "0.2.3"
3+
version = "0.2.4"
44
edition = "2024"
55
authors = ["raz contributors"]
66
description = "Common utilities and shared types for the raz project"

raz-config/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "raz-config"
3-
version = "0.2.3"
3+
version = "0.2.4"
44
edition = "2024"
55
description = "Configuration management for RAZ - handles loading, saving, validation, and inheritance"
66
license = "MIT"

raz-core/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "raz-core"
3-
version = "0.2.3"
3+
version = "0.2.4"
44
edition = "2024"
55
description = "Universal command generator for Rust projects - Core library with stateless file analysis and cursor-aware execution"
66
license = "MIT"
@@ -14,9 +14,9 @@ categories = ["command-line-utilities", "development-tools", "development-tools:
1414
exclude = ["tests/fixtures/", "benches/"]
1515

1616
[dependencies]
17-
raz-common = { path = "../raz-common", version = "0.2.3" }
18-
raz-config = { path = "../raz-config", version = "0.2.3" }
19-
raz-override = { path = "../raz-override", version = "0.2.3" }
17+
raz-common = { path = "../raz-common", version = "0.2.4" }
18+
raz-config = { path = "../raz-config", version = "0.2.4" }
19+
raz-override = { path = "../raz-override", version = "0.2.4" }
2020
serde = { workspace = true }
2121
serde_json = { workspace = true }
2222
toml = { workspace = true }

raz-core/src/file_detection.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,7 @@ impl FileDetector {
366366
#[cfg(feature = "tree-sitter-support")]
367367
{
368368
if let Ok(mut detector) = TreeSitterTestDetector::new() {
369-
if let Ok(mut tree_sitter_entries) =
370-
detector.detect_test_entry_points(&content, cursor)
369+
if let Ok(mut tree_sitter_entries) = detector.detect_entry_points(&content, cursor)
371370
{
372371
// Build module path from file location for cargo projects
373372
let file_module_path =

raz-core/src/tree_sitter_test_detector.rs

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ impl TreeSitterTestDetector {
2929
Ok(Self { parser })
3030
}
3131

32-
/// Detect all test-related entry points in the file
33-
pub fn detect_test_entry_points(
32+
/// Detect all entry points in the file (tests, main, benchmarks, etc.)
33+
pub fn detect_entry_points(
3434
&mut self,
3535
source: &str,
3636
cursor: Option<Position>,
@@ -339,12 +339,11 @@ impl TreeSitterTestDetector {
339339
}
340340
"function_item" => {
341341
let fn_name = self.get_function_name(&node, source)?;
342+
let start_line = node.start_position().row as u32 + 1;
343+
let end_line = node.end_position().row as u32 + 1;
342344

343345
// Check if this is a test function
344346
if self.is_test_function(&node, source) {
345-
let start_line = node.start_position().row as u32 + 1;
346-
let end_line = node.end_position().row as u32 + 1;
347-
348347
// Build full path including module hierarchy
349348
let full_path = if module_stack.is_empty() {
350349
fn_name.clone()
@@ -368,6 +367,26 @@ impl TreeSitterTestDetector {
368367
line_range: (start_line, end_line),
369368
full_path: Some(full_path),
370369
});
370+
} else if fn_name == "main" {
371+
// Detect main function with proper line range
372+
entry_points.push(EntryPoint {
373+
name: "main".to_string(),
374+
entry_type: EntryPointType::Main,
375+
line: start_line,
376+
column: node.start_position().column as u32,
377+
line_range: (start_line, end_line),
378+
full_path: None,
379+
});
380+
} else if self.is_bench_function(&node, source) {
381+
// Detect benchmark function with proper line range
382+
entry_points.push(EntryPoint {
383+
name: fn_name,
384+
entry_type: EntryPointType::Benchmark,
385+
line: start_line,
386+
column: node.start_position().column as u32,
387+
line_range: (start_line, end_line),
388+
full_path: None,
389+
});
371390
}
372391
}
373392
_ => {}
@@ -419,7 +438,24 @@ impl TreeSitterTestDetector {
419438
let attr_text = prev_sibling.utf8_text(source.as_bytes());
420439
if let Ok(text) = attr_text {
421440
// Match various test attributes
422-
if text.contains("test") {
441+
if text.contains("test") && !text.contains("bench") {
442+
return true;
443+
}
444+
}
445+
}
446+
}
447+
448+
false
449+
}
450+
451+
/// Check if a function node is a benchmark function (#[bench])
452+
fn is_bench_function(&self, node: &Node, source: &str) -> bool {
453+
// Check previous sibling for bench attributes
454+
if let Some(prev_sibling) = node.prev_sibling() {
455+
if prev_sibling.kind() == "attribute_item" {
456+
let attr_text = prev_sibling.utf8_text(source.as_bytes());
457+
if let Ok(text) = attr_text {
458+
if text.contains("bench") {
423459
return true;
424460
}
425461
}

raz-core/src/universal_command_generator.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,11 +1695,11 @@ impl UniversalCommandGenerator {
16951695
fn find_main_at_cursor(entry_points: &[EntryPoint], cursor: Position) -> Option<&EntryPoint> {
16961696
let cursor_line = cursor.line + 1; // Convert to 1-based
16971697

1698-
// Check if cursor is on or near main function
1698+
// Check if cursor is within main function scope
16991699
for ep in entry_points {
17001700
if ep.entry_type == EntryPointType::Main {
1701-
// Check if cursor is on the main function line or within 2 lines
1702-
if cursor_line >= ep.line.saturating_sub(1) && cursor_line <= ep.line + 2 {
1701+
// Check if cursor is within the full scope of the main function
1702+
if cursor_line >= ep.line_range.0 && cursor_line <= ep.line_range.1 {
17031703
return Some(ep);
17041704
}
17051705
}

0 commit comments

Comments
 (0)