diff options
Diffstat (limited to 'crates/shirabe-class-map-generator')
| -rw-r--r-- | crates/shirabe-class-map-generator/src/class_map_generator.rs | 14 | ||||
| -rw-r--r-- | crates/shirabe-class-map-generator/src/php_file_cleaner.rs | 13 |
2 files changed, 8 insertions, 19 deletions
diff --git a/crates/shirabe-class-map-generator/src/class_map_generator.rs b/crates/shirabe-class-map-generator/src/class_map_generator.rs index 5b745b80..0ee9d992 100644 --- a/crates/shirabe-class-map-generator/src/class_map_generator.rs +++ b/crates/shirabe-class-map-generator/src/class_map_generator.rs @@ -3,7 +3,7 @@ use crate::class_map::ClassMap; use crate::file_list::FileList; use crate::php_file_parser::PhpFileParser; -use shirabe_pcre::{CaptureKey, Preg}; +use shirabe_pcre::Preg; use shirabe_php_shim::{ InvalidArgumentException, LogicException, PATHINFO_EXTENSION, RuntimeException, explode, getcwd, implode, is_dir, is_file, pathinfo, php_regex, preg_quote, realpath, str_replace, @@ -351,10 +351,7 @@ impl ClassMapGenerator { php_regex!(r"{^( [0-9a-z]{2,}+: (?: // (?: [a-z]: )? )? | [a-z]: )}ix"), &path, ) { - prefix = r#match - .get(&CaptureKey::ByIndex(1)) - .unwrap_or_default() - .to_string(); + prefix = r#match.get(1).unwrap_or_default().to_string(); path = substr(&path, strlen(&prefix), None); } @@ -377,12 +374,7 @@ impl ClassMapGenerator { // ensure c: is normalized to C: let prefix = Preg::replace_callback( php_regex!(r"{(?:^|://)[a-z]:$}i"), - |m| { - m.get(&CaptureKey::ByIndex(0)) - .unwrap_or_default() - .to_string() - .to_uppercase() - }, + |m| m.get(0).unwrap_or_default().to_string().to_uppercase(), &prefix, ); diff --git a/crates/shirabe-class-map-generator/src/php_file_cleaner.rs b/crates/shirabe-class-map-generator/src/php_file_cleaner.rs index 8b60b4db..18b051c9 100644 --- a/crates/shirabe-class-map-generator/src/php_file_cleaner.rs +++ b/crates/shirabe-class-map-generator/src/php_file_cleaner.rs @@ -1,7 +1,7 @@ //! ref: composer/vendor/composer/class-map-generator/src/PhpFileCleaner.php use indexmap::IndexMap; -use shirabe_pcre::{CaptureKey, Preg, PregMatches}; +use shirabe_pcre::{Preg, PregMatches}; use std::sync::Mutex; #[derive(Debug, Clone)] @@ -106,14 +106,14 @@ impl PhpFileCleaner { r#"{<<<[ \t]*(?:"([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)"|'([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)'|([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*))(?:\r\n|\n|\r)}A"#, ) { let matched_len = r#match - .get(&CaptureKey::ByIndex(0)) + .get(0) .map(|s| s.len()) .unwrap_or(0); let delimiter = [1, 2, 3] .iter() .find_map(|i| { r#match - .get(&CaptureKey::ByIndex(*i)) + .get(*i) .filter(|s| !s.is_empty()) .map(str::to_string) }) @@ -149,7 +149,7 @@ impl PhpFileCleaner { if let Some(r#match) = Preg::is_match4(&entry.pattern, &self.contents, offset) { - return clean + r#match.get(&CaptureKey::ByIndex(0)).unwrap_or(""); + return clean + r#match.get(0).unwrap_or(""); } } } @@ -159,10 +159,7 @@ impl PhpFileCleaner { let rest_pattern = REST_PATTERN.lock().unwrap().clone(); if let Some(rest_pattern) = rest_pattern { if let Some(r#match) = self.r#match(&rest_pattern) { - let m0 = r#match - .get(&CaptureKey::ByIndex(0)) - .unwrap_or_default() - .to_string(); + let m0 = r#match.get(0).unwrap_or_default().to_string(); clean.push(char); clean.push_str(&m0); self.index += m0.len(); |
