Skip to content

Commit beb0ae4

Browse files
committed
rust: semantic crate is part of bear
1 parent b7a720f commit beb0ae4

File tree

15 files changed

+24
-63
lines changed

15 files changed

+24
-63
lines changed

rust/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
[workspace]
22
members = [
33
"bear",
4-
"intercept",
5-
"semantic"
4+
"intercept"
65
]
76
resolver = "2"
87

rust/bear/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ path = "src/bin/main.rs"
1919

2020
[dependencies]
2121
intercept = { path = "../intercept" }
22-
semantic = { path = "../semantic" }
2322
thiserror.workspace = true
2423
anyhow.workspace = true
2524
lazy_static.workspace = true
@@ -33,3 +32,5 @@ log.workspace = true
3332
env_logger.workspace = true
3433
path-absolutize.workspace = true
3534
shell-words.workspace = true
35+
nom.workspace = true
36+
regex.workspace = true

rust/bear/src/bin/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ use std::process::ExitCode;
2020

2121
use bear::input::EventFileReader;
2222
use bear::output::OutputWriter;
23-
use bear::{args, config};
23+
use bear::{args, config, semantic};
2424
use intercept::Execution;
2525
use log;
26-
use semantic;
2726

2827
/// Driver function of the application.
2928
fn main() -> anyhow::Result<ExitCode> {

rust/bear/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ pub mod config;
33
mod fixtures;
44
pub mod input;
55
pub mod output;
6+
pub mod semantic;

rust/bear/src/output/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ use std::fs::{File, OpenOptions};
2020
use std::io::{BufReader, BufWriter};
2121
use std::path::{Path, PathBuf};
2222

23-
use super::{args, config};
23+
use super::{args, config, semantic};
2424
use anyhow::{anyhow, Context, Result};
2525
use clang::Entry;
2626
use path_absolutize::Absolutize;
27-
use semantic;
2827
use serde_json::Error;
2928

3029
pub mod clang;

rust/semantic/src/lib.rs renamed to rust/bear/src/semantic/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
You should have received a copy of the GNU General Public License
1717
along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
*/
19-
20-
mod fixtures;
2119
pub mod tools;
2220

2321
use intercept::Execution;

rust/semantic/src/tools/combinators.rs renamed to rust/bear/src/semantic/tools/combinators.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@
1717
along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
*/
1919

20-
use crate::{RecognitionResult, Tool};
20+
use super::super::{RecognitionResult, Tool};
2121
use intercept::Execution;
2222

2323
/// Represents a set of tools, where any of them can recognize the semantic.
2424
/// The evaluation is done in the order of the tools. The first one which
2525
/// recognizes the semantic will be returned as result.
26-
pub struct Any {
26+
pub(super) struct Any {
2727
tools: Vec<Box<dyn Tool>>,
2828
}
2929

3030
impl Any {
31-
pub fn new(tools: Vec<Box<dyn Tool>>) -> impl Tool {
31+
pub(super) fn new(tools: Vec<Box<dyn Tool>>) -> impl Tool {
3232
Any { tools }
3333
}
3434
}

rust/semantic/src/tools/gcc.rs renamed to rust/bear/src/semantic/tools/gcc.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ use nom::multi::many1;
2222
use nom::sequence::preceded;
2323

2424
use super::super::{Meaning, RecognitionResult, Tool};
25-
use super::gcc::internal::Argument;
25+
use internal::Argument;
2626
use intercept::Execution;
2727

28-
pub struct Gcc {}
28+
pub(super) struct Gcc {}
2929

3030
impl Gcc {
31-
pub fn new() -> Box<dyn Tool> {
31+
pub(super) fn new() -> Box<dyn Tool> {
3232
Box::new(Gcc {})
3333
}
3434
}
@@ -66,8 +66,8 @@ mod internal {
6666
use regex::Regex;
6767
use std::path::PathBuf;
6868

69-
use crate::tools::matchers::source::looks_like_a_source_file;
70-
use crate::CompilerPass;
69+
use super::super::super::CompilerPass;
70+
use super::super::matchers::source::looks_like_a_source_file;
7171

7272
#[derive(Debug, PartialEq)]
7373
enum Language {

rust/semantic/src/tools/generic.rs renamed to rust/bear/src/semantic/tools/generic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ use super::matchers::source::looks_like_a_source_file;
2525
use intercept::Execution;
2626

2727
/// A tool to recognize a compiler by executable name.
28-
pub struct Generic {
28+
pub(super) struct Generic {
2929
executables: HashSet<PathBuf>,
3030
}
3131

3232
impl Generic {
33-
pub fn from(compilers: &[PathBuf]) -> Box<dyn Tool> {
33+
pub(super) fn from(compilers: &[PathBuf]) -> Box<dyn Tool> {
3434
let executables = compilers.iter().map(|compiler| compiler.clone()).collect();
3535
Box::new(Self { executables })
3636
}

rust/semantic/src/tools/ignore.rs renamed to rust/bear/src/semantic/tools/ignore.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ use super::super::{Meaning, RecognitionResult, Tool};
2424
use intercept::Execution;
2525

2626
/// A tool to ignore a command execution by executable name.
27-
pub struct IgnoreByPath {
27+
pub(super) struct IgnoreByPath {
2828
executables: HashSet<PathBuf>,
2929
}
3030

3131
impl IgnoreByPath {
32-
pub fn new() -> Box<dyn Tool> {
32+
pub(super) fn new() -> Box<dyn Tool> {
3333
let executables = COREUTILS_FILES.iter().map(PathBuf::from).collect();
3434
Box::new(Self { executables })
3535
}
3636

37-
pub fn from(compilers: &[PathBuf]) -> Box<dyn Tool> {
37+
pub(super) fn from(compilers: &[PathBuf]) -> Box<dyn Tool> {
3838
let executables = compilers.iter().map(|compiler| compiler.clone()).collect();
3939
Box::new(Self { executables })
4040
}
@@ -51,12 +51,12 @@ impl Tool for IgnoreByPath {
5151
}
5252
}
5353

54-
pub struct IgnoreByArgs {
54+
pub(super) struct IgnoreByArgs {
5555
args: Vec<String>,
5656
}
5757

5858
impl IgnoreByArgs {
59-
pub fn new(args: &[String]) -> Box<dyn Tool> {
59+
pub(super) fn new(args: &[String]) -> Box<dyn Tool> {
6060
let clones = args.iter().map(|arg| arg.clone()).collect();
6161
Box::new(Self { args: clones })
6262
}

0 commit comments

Comments
 (0)