polyglot-piranha 0.3.31__tar.gz → 0.3.33__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/Cargo.lock +12 -13
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/Cargo.toml +4 -2
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/PKG-INFO +1 -1
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/models/default_configs.rs +2 -2
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/models/matches.rs +20 -10
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/models/rule.rs +12 -10
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/models/unit_tests/concrete_syntax_test.rs +17 -1
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/models/unit_tests/rule_test.rs +8 -9
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/LICENSE +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/NOTICE +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/README.md +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/plugins/pyproject.toml +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/pyproject.toml +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/cleanup_rules/go/edges.toml +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/cleanup_rules/go/rules.toml +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/cleanup_rules/go/scope_config.toml +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/cleanup_rules/java/edges.toml +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/cleanup_rules/java/rules.toml +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/cleanup_rules/java/scope_config.toml +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/cleanup_rules/java_cs/edges.toml +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/cleanup_rules/java_cs/rules.toml +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/cleanup_rules/java_cs/scope_config.toml +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/cleanup_rules/kt/edges.toml +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/cleanup_rules/kt/rules.toml +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/cleanup_rules/kt/scope_config.toml +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/cleanup_rules/ruby/edges.toml +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/cleanup_rules/ruby/rules.toml +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/cleanup_rules/ruby/scope_config.toml +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/cleanup_rules/scala/scope_config.toml +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/cleanup_rules/swift/edges.toml +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/cleanup_rules/swift/rules.toml +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/cleanup_rules/swift/scope_config.toml +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/df/README.md +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/df/analysis.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/df/mod.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/df/tag_analysis.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/df/unit_tests/tag_analysis_test.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/df/utils.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/lib.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/main.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/models/capture_group_patterns.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/models/concrete_syntax.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/models/edit.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/models/filter.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/models/language.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/models/mod.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/models/outgoing_edges.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/models/piranha_arguments.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/models/piranha_output.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/models/rule_graph.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/models/rule_store.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/models/scopes.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/models/source_code_unit.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/models/unit_tests/piranha_arguments_test.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/models/unit_tests/rule_graph_validation_test.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/models/unit_tests/scopes_test.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/models/unit_tests/source_code_unit_test.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/models/unit_tests/testdata/custom_builtin/edges.toml +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/models/unit_tests/testdata/custom_builtin/rules.toml +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/tests/mod.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/tests/test_piranha_go.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/tests/test_piranha_java.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/tests/test_piranha_kt.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/tests/test_piranha_python.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/tests/test_piranha_scala.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/tests/test_piranha_scm.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/tests/test_piranha_strings.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/tests/test_piranha_swift.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/tests/test_piranha_thrift.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/tests/test_piranha_ts.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/tests/test_piranha_tsx.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/tests/test_piranha_yaml.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/utilities/mod.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/utilities/regex_utilities.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/utilities/tree_sitter_utilities.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/utilities/unit_tests/tree_sitter_utilities_test.rs +0 -0
- {polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/utilities/unit_tests/utilities_test.rs +0 -0
@@ -126,9 +126,9 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
|
|
126
126
|
|
127
127
|
[[package]]
|
128
128
|
name = "clap"
|
129
|
-
version = "4.5.
|
129
|
+
version = "4.5.39"
|
130
130
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
131
|
-
checksum = "
|
131
|
+
checksum = "fd60e63e9be68e5fb56422e397cf9baddded06dae1d2e523401542383bc72a9f"
|
132
132
|
dependencies = [
|
133
133
|
"clap_builder",
|
134
134
|
"clap_derive",
|
@@ -136,9 +136,9 @@ dependencies = [
|
|
136
136
|
|
137
137
|
[[package]]
|
138
138
|
name = "clap_builder"
|
139
|
-
version = "4.5.
|
139
|
+
version = "4.5.39"
|
140
140
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
141
|
-
checksum = "
|
141
|
+
checksum = "89cc6392a1f72bbeb820d71f32108f61fdaf18bc526e1d23954168a67759ef51"
|
142
142
|
dependencies = [
|
143
143
|
"anstream",
|
144
144
|
"anstyle",
|
@@ -502,9 +502,9 @@ checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa"
|
|
502
502
|
|
503
503
|
[[package]]
|
504
504
|
name = "lock_api"
|
505
|
-
version = "0.4.
|
505
|
+
version = "0.4.13"
|
506
506
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
507
|
-
checksum = "
|
507
|
+
checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765"
|
508
508
|
dependencies = [
|
509
509
|
"autocfg",
|
510
510
|
"scopeguard",
|
@@ -572,9 +572,9 @@ checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad"
|
|
572
572
|
|
573
573
|
[[package]]
|
574
574
|
name = "parking_lot"
|
575
|
-
version = "0.12.
|
575
|
+
version = "0.12.4"
|
576
576
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
577
|
-
checksum = "
|
577
|
+
checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13"
|
578
578
|
dependencies = [
|
579
579
|
"lock_api",
|
580
580
|
"parking_lot_core",
|
@@ -582,9 +582,9 @@ dependencies = [
|
|
582
582
|
|
583
583
|
[[package]]
|
584
584
|
name = "parking_lot_core"
|
585
|
-
version = "0.9.
|
585
|
+
version = "0.9.11"
|
586
586
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
587
|
-
checksum = "
|
587
|
+
checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5"
|
588
588
|
dependencies = [
|
589
589
|
"cfg-if",
|
590
590
|
"libc",
|
@@ -595,7 +595,7 @@ dependencies = [
|
|
595
595
|
|
596
596
|
[[package]]
|
597
597
|
name = "piranha"
|
598
|
-
version = "0.3.
|
598
|
+
version = "0.3.33"
|
599
599
|
dependencies = [
|
600
600
|
"assert_cmd",
|
601
601
|
"cc",
|
@@ -1087,8 +1087,7 @@ dependencies = [
|
|
1087
1087
|
[[package]]
|
1088
1088
|
name = "tree-sitter-kotlin"
|
1089
1089
|
version = "0.3.5"
|
1090
|
-
source = "
|
1091
|
-
checksum = "8df217a0e1fec649f3e13157de932439f3d37ea4e265038dd0873971ef56e726"
|
1090
|
+
source = "git+https://github.com/danieltrt/tree-sitter-kotlin?rev=5e0b07cb2ba628842028313b60b97699cc5e0fee#5e0b07cb2ba628842028313b60b97699cc5e0fee"
|
1092
1091
|
dependencies = [
|
1093
1092
|
"cc",
|
1094
1093
|
"tree-sitter",
|
@@ -2,7 +2,7 @@
|
|
2
2
|
authors = ["Uber Technologies Inc."]
|
3
3
|
name = "piranha"
|
4
4
|
description = "Polyglot Piranha is a library for performing structural find and replace with deep cleanup."
|
5
|
-
version = "0.3.
|
5
|
+
version = "0.3.33"
|
6
6
|
edition = "2021"
|
7
7
|
include = ["pyproject.toml", "src/"]
|
8
8
|
exclude = ["legacy"]
|
@@ -47,7 +47,9 @@ serde_json = "1.0.82"
|
|
47
47
|
ctrlc = "3.4"
|
48
48
|
|
49
49
|
# TODO: Update if we upgrade tree-sitter to >=0.21
|
50
|
-
|
50
|
+
# Kotlin's grammar needs to fix the way it parses unary expressions (currently -a + b gets parsed as - (a +b)).
|
51
|
+
# Once we upstream the fix, we can point to the official version.
|
52
|
+
tree-sitter-kotlin = { git = "https://github.com/danieltrt/tree-sitter-kotlin", rev = "5e0b07cb2ba628842028313b60b97699cc5e0fee" }
|
51
53
|
tree-sitter-java = "0.20.2"
|
52
54
|
# TODO: Update after: https://github.com/alex-pinkus/tree-sitter-swift/issues/278 resolves
|
53
55
|
tree-sitter-swift = { git = "https://github.com/satyam1749/tree-sitter-swift.git", rev = "08a28993599f1968bc81631a89690503e1db7704" }
|
@@ -192,8 +192,8 @@ pub(crate) fn default_is_seed_rule() -> bool {
|
|
192
192
|
true
|
193
193
|
}
|
194
194
|
|
195
|
-
pub(crate) fn
|
196
|
-
|
195
|
+
pub(crate) fn default_keep_comment_regexes() -> HashSet<String> {
|
196
|
+
HashSet::new()
|
197
197
|
}
|
198
198
|
|
199
199
|
pub(crate) fn default_allow_dirty_ast() -> bool {
|
@@ -18,6 +18,7 @@ use getset::{Getters, MutGetters};
|
|
18
18
|
use itertools::Itertools;
|
19
19
|
use log::trace;
|
20
20
|
use pyo3::prelude::{pyclass, pymethods};
|
21
|
+
use regex::Regex;
|
21
22
|
use serde_derive::{Deserialize, Serialize};
|
22
23
|
use tree_sitter::Node;
|
23
24
|
|
@@ -120,10 +121,10 @@ impl Match {
|
|
120
121
|
// Populates the leading and trailing comma and comment ranges for the match.
|
121
122
|
fn populate_associated_elements(
|
122
123
|
&mut self, node: &Node, code: &String, piranha_arguments: &PiranhaArguments,
|
123
|
-
|
124
|
+
compiled_regexes: Vec<Regex>,
|
124
125
|
) {
|
125
|
-
self.get_associated_elements(node, code, piranha_arguments, true,
|
126
|
-
self.get_associated_elements(node, code, piranha_arguments, false,
|
126
|
+
self.get_associated_elements(node, code, piranha_arguments, true, &compiled_regexes);
|
127
|
+
self.get_associated_elements(node, code, piranha_arguments, false, &compiled_regexes);
|
127
128
|
self.get_associated_leading_empty_lines(node, code);
|
128
129
|
}
|
129
130
|
|
@@ -183,7 +184,7 @@ impl Match {
|
|
183
184
|
/// We currently capture leading and trailing comments and commas.
|
184
185
|
fn get_associated_elements(
|
185
186
|
&mut self, node: &Node, code: &String, piranha_arguments: &PiranhaArguments, trailing: bool,
|
186
|
-
|
187
|
+
keep_comment_regexes: &[Regex],
|
187
188
|
) {
|
188
189
|
let mut current_node = *node;
|
189
190
|
let mut buf = *piranha_arguments.cleanup_comments_buffer();
|
@@ -201,11 +202,14 @@ impl Match {
|
|
201
202
|
self.associated_comma = Some(sibling.range().into());
|
202
203
|
current_node = sibling;
|
203
204
|
continue; // Continue the inner loop (i.e. evaluate next sibling)
|
204
|
-
} else if
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
205
|
+
} else if self._is_comment_safe_to_delete(&sibling, node, piranha_arguments, trailing) {
|
206
|
+
let comment_text = sibling.utf8_text(code.as_bytes()).unwrap();
|
207
|
+
if !keep_comment_regexes
|
208
|
+
.iter()
|
209
|
+
.any(|re| re.is_match(comment_text))
|
210
|
+
{
|
211
|
+
self.associated_comments.push(sibling.range().into());
|
212
|
+
}
|
209
213
|
current_node = sibling;
|
210
214
|
continue; // Continue the inner loop (i.e. evaluate next sibling)
|
211
215
|
}
|
@@ -494,11 +498,17 @@ impl SourceCodeUnit {
|
|
494
498
|
p_match.range().end_byte,
|
495
499
|
);
|
496
500
|
if self.is_satisfied(matched_node, rule, p_match.matches(), rule_store) {
|
501
|
+
let compiled_regexes: Vec<Regex> = rule
|
502
|
+
.rule()
|
503
|
+
.keep_comment_regexes()
|
504
|
+
.iter()
|
505
|
+
.filter_map(|pattern| Regex::new(pattern).ok())
|
506
|
+
.collect();
|
497
507
|
p_match.populate_associated_elements(
|
498
508
|
&matched_node,
|
499
509
|
self.code(),
|
500
510
|
self.piranha_arguments(),
|
501
|
-
|
511
|
+
compiled_regexes,
|
502
512
|
);
|
503
513
|
trace!("Found match {:#?}", p_match);
|
504
514
|
output.push(p_match.clone());
|
@@ -25,8 +25,9 @@ use crate::utilities::Instantiate;
|
|
25
25
|
use super::{
|
26
26
|
capture_group_patterns::CGPattern,
|
27
27
|
default_configs::{
|
28
|
-
|
29
|
-
default_query, default_replace, default_replace_idx,
|
28
|
+
default_filters, default_groups, default_holes, default_is_seed_rule,
|
29
|
+
default_keep_comment_regexes, default_query, default_replace, default_replace_idx,
|
30
|
+
default_replace_node, default_rule_name,
|
30
31
|
},
|
31
32
|
filter::Filter,
|
32
33
|
Validator,
|
@@ -97,11 +98,11 @@ pub struct Rule {
|
|
97
98
|
is_seed_rule: bool,
|
98
99
|
|
99
100
|
/// Marks comments as deletable
|
100
|
-
#[builder(default = "
|
101
|
-
#[serde(default = "
|
101
|
+
#[builder(default = "default_keep_comment_regexes()")]
|
102
|
+
#[serde(default = "default_keep_comment_regexes")]
|
102
103
|
#[get = "pub"]
|
103
104
|
#[pyo3(get)]
|
104
|
-
|
105
|
+
keep_comment_regexes: HashSet<String>,
|
105
106
|
}
|
106
107
|
|
107
108
|
impl Rule {
|
@@ -148,7 +149,7 @@ macro_rules! piranha_rule {
|
|
148
149
|
$(, is_seed_rule = $is_seed_rule:expr)?
|
149
150
|
$(, groups = [$($group_name: expr)*])?
|
150
151
|
$(, filters = [$($filter:tt)*])?
|
151
|
-
$(,
|
152
|
+
$(, keep_comment_regexes = [$($rgex: expr)*])?
|
152
153
|
) => {
|
153
154
|
$crate::models::rule::RuleBuilder::default()
|
154
155
|
.name($name.to_string())
|
@@ -160,7 +161,7 @@ macro_rules! piranha_rule {
|
|
160
161
|
$(.holes(std::collections::HashSet::from([$($hole.to_string(),)*])))?
|
161
162
|
$(.groups(std::collections::HashSet::from([$($group_name.to_string(),)*])))?
|
162
163
|
$(.filters(std::collections::HashSet::from([$($filter)*])))?
|
163
|
-
$(.
|
164
|
+
$(.keep_comment_regexes(std::collections::HashSet::from([$($rgex.to_string(),)*])))?
|
164
165
|
.build().unwrap()
|
165
166
|
};
|
166
167
|
}
|
@@ -171,7 +172,8 @@ impl Rule {
|
|
171
172
|
fn py_new(
|
172
173
|
name: String, query: Option<String>, replace: Option<String>, replace_idx: Option<u8>,
|
173
174
|
replace_node: Option<String>, holes: Option<HashSet<String>>, groups: Option<HashSet<String>>,
|
174
|
-
filters: Option<HashSet<Filter>>, is_seed_rule: Option<bool>,
|
175
|
+
filters: Option<HashSet<Filter>>, is_seed_rule: Option<bool>,
|
176
|
+
keep_comment_regexes: Option<HashSet<String>>,
|
175
177
|
) -> Self {
|
176
178
|
let mut rule_builder = RuleBuilder::default();
|
177
179
|
|
@@ -208,8 +210,8 @@ impl Rule {
|
|
208
210
|
rule_builder.is_seed_rule(is_seed_rule);
|
209
211
|
}
|
210
212
|
|
211
|
-
if let Some(
|
212
|
-
rule_builder.
|
213
|
+
if let Some(keep_comment_regexes) = keep_comment_regexes {
|
214
|
+
rule_builder.keep_comment_regexes(keep_comment_regexes);
|
213
215
|
}
|
214
216
|
|
215
217
|
rule_builder.build().unwrap()
|
{polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/models/unit_tests/concrete_syntax_test.rs
RENAMED
@@ -14,7 +14,10 @@
|
|
14
14
|
use crate::models::capture_group_patterns::ConcreteSyntax;
|
15
15
|
use crate::models::concrete_syntax::get_all_matches_for_concrete_syntax;
|
16
16
|
use crate::models::default_configs::GO;
|
17
|
-
use crate::models::{
|
17
|
+
use crate::models::{
|
18
|
+
default_configs::{JAVA, KOTLIN},
|
19
|
+
language::PiranhaLanguage,
|
20
|
+
};
|
18
21
|
|
19
22
|
fn run_test(
|
20
23
|
code: &str, pattern: &str, expected_matches: usize, expected_vars: Vec<Vec<(&str, &str)>>,
|
@@ -39,6 +42,19 @@ fn run_test(
|
|
39
42
|
}
|
40
43
|
}
|
41
44
|
|
45
|
+
#[test]
|
46
|
+
fn test_single_match_kotlin() {
|
47
|
+
run_test(
|
48
|
+
"class Something : BaseParameters(namespace = \"data\") {
|
49
|
+
val something_else: Boolean by parameter(\"something_else\")
|
50
|
+
}",
|
51
|
+
"val :[stale_property_name] : Boolean by parameter(\"something_else\")",
|
52
|
+
1,
|
53
|
+
vec![vec![("stale_property_name", "something_else")]],
|
54
|
+
KOTLIN,
|
55
|
+
);
|
56
|
+
}
|
57
|
+
|
42
58
|
#[test]
|
43
59
|
fn test_single_match() {
|
44
60
|
run_test(
|
@@ -393,14 +393,17 @@ fn test_rule_delete_comments() {
|
|
393
393
|
query= "((method_invocation) @m (#eq? @m \"variable.set_value(true)\"))",
|
394
394
|
replace_node = "m",
|
395
395
|
replace = "",
|
396
|
-
|
396
|
+
keep_comment_regexes = ["// Given .*"]
|
397
397
|
};
|
398
398
|
|
399
399
|
let rule = InstantiatedRule::new(&_rule, &HashMap::new());
|
400
400
|
let source_code = "class Test {
|
401
401
|
public void foobar(){
|
402
|
-
// Given
|
402
|
+
// Given something
|
403
|
+
// This is an explanatory comment
|
404
|
+
// This is another explanatory comment
|
403
405
|
variable.set_value(true);
|
406
|
+
other_variable.set_value(false);
|
404
407
|
|
405
408
|
// When
|
406
409
|
var result = data.Something();
|
@@ -433,16 +436,12 @@ fn test_rule_delete_comments() {
|
|
433
436
|
let edit = source_code_unit.get_edit(&rule, &mut rule_store, node, true);
|
434
437
|
assert!(edit.is_some());
|
435
438
|
let edit = edit.unwrap();
|
436
|
-
|
437
439
|
// Apply the edit to the source code unit
|
438
440
|
source_code_unit.apply_edit(&edit, &mut parser);
|
439
441
|
|
440
|
-
// Inspect the resulting code
|
441
442
|
let edited_code = source_code_unit.code();
|
442
|
-
|
443
|
-
//
|
444
|
-
assert!(edited_code.contains("//
|
445
|
-
assert!(edited_code.contains("// When"));
|
446
|
-
assert!(edited_code.contains("// Then"));
|
443
|
+
assert!(edited_code.contains("// Given something"));
|
444
|
+
assert!(!edited_code.contains("// This is another explanatory comment"));
|
445
|
+
assert!(!edited_code.contains("// This is an explanatory comment"));
|
447
446
|
assert!(!edited_code.contains("variable.set_value(true);"));
|
448
447
|
}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/cleanup_rules/java/scope_config.toml
RENAMED
File without changes
|
File without changes
|
File without changes
|
{polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/cleanup_rules/java_cs/scope_config.toml
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/cleanup_rules/ruby/scope_config.toml
RENAMED
File without changes
|
{polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/cleanup_rules/scala/scope_config.toml
RENAMED
File without changes
|
File without changes
|
File without changes
|
{polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/cleanup_rules/swift/scope_config.toml
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/models/unit_tests/piranha_arguments_test.rs
RENAMED
File without changes
|
File without changes
|
File without changes
|
{polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/models/unit_tests/source_code_unit_test.rs
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{polyglot_piranha-0.3.31 → polyglot_piranha-0.3.33}/src/utilities/unit_tests/utilities_test.rs
RENAMED
File without changes
|