|
1 | 1 | use super::{FileAnalyzer, ProjectMetadata}; |
2 | 2 | use crate::context::StagedFile; |
3 | | -use once_cell::sync::Lazy; |
4 | 3 | use regex::Regex; |
5 | 4 | use std::collections::HashSet; |
6 | 5 |
|
7 | 6 | // Regex for extracting Maven version from pom.xml |
8 | | -static MAVEN_VERSION_RE: Lazy<Regex> = Lazy::new(|| { |
| 7 | +static MAVEN_VERSION_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| { |
9 | 8 | Regex::new(r"<version>(.+?)</version>").expect("Should compile: MAVEN_VERSION_RE") |
10 | 9 | }); |
11 | 10 | // Regex for extracting Maven dependencies from pom.xml |
12 | | -static MAVEN_DEPENDENCY_RE: Lazy<Regex> = Lazy::new(|| { |
| 11 | +static MAVEN_DEPENDENCY_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| { |
13 | 12 | Regex::new(r"<dependency>\s*<groupId>(.+?)</groupId>\s*<artifactId>(.+?)</artifactId>") |
14 | 13 | .expect("Should compile: MAVEN_DEPENDENCY_RE") |
15 | 14 | }); |
16 | 15 | // Regex for extracting Gradle version from build.gradle |
17 | | -static GRADLE_VERSION_RE: Lazy<Regex> = Lazy::new(|| { |
| 16 | +static GRADLE_VERSION_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| { |
18 | 17 | Regex::new(r#"version\s*=\s*['"](.*?)['"]"#).expect("Should compile: GRADLE_VERSION_RE") |
19 | 18 | }); |
20 | 19 | // Regex for extracting Gradle dependencies from build.gradle |
21 | | -static GRADLE_DEPENDENCY_RE: Lazy<Regex> = Lazy::new(|| { |
| 20 | +static GRADLE_DEPENDENCY_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| { |
22 | 21 | Regex::new(r#"implementation\s+['"](.+?):(.+?):"#) |
23 | 22 | .expect("Should compile: GRADLE_DEPENDENCY_RE") |
24 | 23 | }); |
25 | 24 | // Regex for extracting modified Java classes |
26 | | -static JAVA_CLASS_RE: Lazy<Regex> = Lazy::new(|| { |
| 25 | +static JAVA_CLASS_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| { |
27 | 26 | Regex::new(r"(?m)^[+-]\s*(public\s+|private\s+)?(class|interface|enum)\s+(\w+)") |
28 | 27 | .expect("Should compile: JAVA_CLASS_RE") |
29 | 28 | }); |
30 | 29 | // Regex for extracting modified Java methods |
31 | | -static JAVA_METHOD_RE: Lazy<Regex> = Lazy::new(|| { |
| 30 | +static JAVA_METHOD_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| { |
32 | 31 | Regex::new(r"(?m)^[+-]\s*(public|protected|private)?\s*\w+\s+(\w+)\s*\([^\)]*\)") |
33 | 32 | .expect("Should compile: JAVA_METHOD_RE") |
34 | 33 | }); |
35 | 34 | // Regex for checking Java import changes |
36 | | -static JAVA_IMPORT_RE: Lazy<Regex> = |
37 | | - Lazy::new(|| Regex::new(r"(?m)^[+-]\s*import\s+").expect("Should compile: JAVA_IMPORT_RE")); |
| 35 | +static JAVA_IMPORT_RE: std::sync::LazyLock<Regex> = |
| 36 | + std::sync::LazyLock::new(|| Regex::new(r"(?m)^[+-]\s*import\s+").expect("Should compile: JAVA_IMPORT_RE")); |
38 | 37 |
|
39 | 38 | pub struct JavaAnalyzer; |
40 | 39 |
|
|
0 commit comments