dart-decimate 0.0.56 → 0.0.57
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.
- package/Cargo.lock +1 -1
- package/Cargo.toml +1 -1
- package/README.md +8 -8
- package/npm/scripts/postinstall.js +24 -15
- package/package.json +1 -1
- package/src/output/route_cycle/classification.rs +99 -17
- package/src/output/route_cycle/navigation.rs +29 -6
- package/src/output/route_cycle/state_context.rs +15 -0
- package/src/output/route_cycle.rs +1 -1
package/Cargo.lock
CHANGED
package/Cargo.toml
CHANGED
package/README.md
CHANGED
|
@@ -90,7 +90,7 @@ You do not need to install anything permanently. Use the command above.
|
|
|
90
90
|
For repeatable automation, pin the version:
|
|
91
91
|
|
|
92
92
|
```bash
|
|
93
|
-
pnpm dlx dart-decimate@0.0.
|
|
93
|
+
pnpm dlx dart-decimate@0.0.57
|
|
94
94
|
```
|
|
95
95
|
|
|
96
96
|
Add this to `package.json` if you want a short project command:
|
|
@@ -101,7 +101,7 @@ Add this to `package.json` if you want a short project command:
|
|
|
101
101
|
"dart-decimate": "dart-decimate json ."
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
104
|
-
"dart-decimate": "0.0.
|
|
104
|
+
"dart-decimate": "0.0.57"
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
```
|
|
@@ -117,7 +117,7 @@ pnpm run dart-decimate
|
|
|
117
117
|
If you prefer Cargo, install the matching tagged source:
|
|
118
118
|
|
|
119
119
|
```bash
|
|
120
|
-
cargo install --git https://github.com/sgaabdu4/dart-decimate.git --tag v0.0.
|
|
120
|
+
cargo install --git https://github.com/sgaabdu4/dart-decimate.git --tag v0.0.57 --locked
|
|
121
121
|
```
|
|
122
122
|
|
|
123
123
|
The npm release `X.Y.Z` and Cargo tag `vX.Y.Z` are verified against each other
|
|
@@ -128,7 +128,7 @@ Confirm a Cargo build's version with:
|
|
|
128
128
|
|
|
129
129
|
```bash
|
|
130
130
|
dart-decimate --version
|
|
131
|
-
# dart-decimate 0.0.
|
|
131
|
+
# dart-decimate 0.0.57
|
|
132
132
|
```
|
|
133
133
|
|
|
134
134
|
## pnpm dlx
|
|
@@ -538,7 +538,7 @@ Example shape:
|
|
|
538
538
|
{
|
|
539
539
|
"schema_version": "dart-decimate.report.v1",
|
|
540
540
|
"kind": "combined",
|
|
541
|
-
"tool": "dart-decimate 0.0.
|
|
541
|
+
"tool": "dart-decimate 0.0.57",
|
|
542
542
|
"command": "check",
|
|
543
543
|
"verdict": "fail",
|
|
544
544
|
"summary": {
|
|
@@ -554,7 +554,7 @@ Example shape:
|
|
|
554
554
|
|
|
555
555
|
The `dart-decimate.report.v1` field layout is unchanged. Its existing `tool`
|
|
556
556
|
string includes the producing version so saved reports identify the exact
|
|
557
|
-
build, for example `dart-decimate 0.0.
|
|
557
|
+
build, for example `dart-decimate 0.0.57`.
|
|
558
558
|
|
|
559
559
|
When grouped security findings hide additional occurrences, `next_steps` can
|
|
560
560
|
include `review-security-surface`, which reruns
|
|
@@ -642,7 +642,7 @@ you need the installed binary's exact list.
|
|
|
642
642
|
For a complete repository check, including discovered local packages:
|
|
643
643
|
|
|
644
644
|
```bash
|
|
645
|
-
pnpm dlx dart-decimate@0.0.
|
|
645
|
+
pnpm dlx dart-decimate@0.0.57 --strict
|
|
646
646
|
```
|
|
647
647
|
|
|
648
648
|
This runs every enabled check from the repository root. The default duplication
|
|
@@ -685,7 +685,7 @@ This repository forbids `unsafe_code`.
|
|
|
685
685
|
|
|
686
686
|
## Release Flow
|
|
687
687
|
|
|
688
|
-
Current source version: `0.0.
|
|
688
|
+
Current source version: `0.0.57`.
|
|
689
689
|
|
|
690
690
|
After the first public release, changes should go through pull requests. Every
|
|
691
691
|
PR to `main` must bump both `Cargo.toml` and `package.json` above the base
|
|
@@ -57,17 +57,19 @@ async function installPrebuilt() {
|
|
|
57
57
|
const archivePath = path.join(os.tmpdir(), assetName);
|
|
58
58
|
const url = `${releaseBaseUrl.replace(/\/$/, "")}/${assetName}`;
|
|
59
59
|
await download(url, archivePath, 0);
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
const staging = fs.mkdtempSync(path.join(cacheDir, ".staging-"));
|
|
61
|
+
try {
|
|
62
|
+
extractArchive(assetName, archivePath, staging);
|
|
63
|
+
activateCachedBinaries(assetName, staging);
|
|
64
|
+
} finally {
|
|
65
|
+
fs.rmSync(staging, { recursive: true, force: true });
|
|
62
66
|
}
|
|
63
|
-
extractArchive(assetName, archivePath);
|
|
64
|
-
activateCachedBinaries(assetName);
|
|
65
67
|
return true;
|
|
66
68
|
}
|
|
67
69
|
|
|
68
|
-
/** @param {string} assetName @param {string} archivePath */
|
|
69
|
-
function extractArchive(assetName, archivePath) {
|
|
70
|
-
const extract = spawnSync("tar", ["-xzf", archivePath, "-C",
|
|
70
|
+
/** @param {string} assetName @param {string} archivePath @param {string} destination */
|
|
71
|
+
function extractArchive(assetName, archivePath, destination) {
|
|
72
|
+
const extract = spawnSync("tar", ["-xzf", archivePath, "-C", destination], {
|
|
71
73
|
stdio: "pipe",
|
|
72
74
|
windowsHide: false,
|
|
73
75
|
});
|
|
@@ -84,16 +86,23 @@ function extractArchive(assetName, archivePath) {
|
|
|
84
86
|
}
|
|
85
87
|
}
|
|
86
88
|
|
|
87
|
-
/** @param {string} assetName */
|
|
88
|
-
function activateCachedBinaries(assetName) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
/** @param {string} assetName @param {string} staging */
|
|
90
|
+
function activateCachedBinaries(assetName, staging) {
|
|
91
|
+
const binaries = ["dart-decimate", "dart-decimate-mcp"].map(
|
|
92
|
+
(binary) => `${binary}${exeExt}`,
|
|
93
|
+
);
|
|
94
|
+
const missing = binaries.find(
|
|
95
|
+
(binary) => !fs.existsSync(path.join(staging, binary)),
|
|
96
|
+
);
|
|
97
|
+
if (missing) {
|
|
98
|
+
throw new Error(`${assetName} did not contain ${missing}`);
|
|
99
|
+
}
|
|
100
|
+
for (const binary of binaries) {
|
|
101
|
+
const stagedBinary = path.join(staging, binary);
|
|
94
102
|
if (process.platform !== "win32") {
|
|
95
|
-
fs.chmodSync(
|
|
103
|
+
fs.chmodSync(stagedBinary, 0o755);
|
|
96
104
|
}
|
|
105
|
+
fs.renameSync(stagedBinary, path.join(cacheDir, binary));
|
|
97
106
|
}
|
|
98
107
|
}
|
|
99
108
|
|
package/package.json
CHANGED
|
@@ -8,11 +8,11 @@ use petgraph::visit::EdgeRef;
|
|
|
8
8
|
use tree_sitter::Node;
|
|
9
9
|
|
|
10
10
|
use super::{
|
|
11
|
-
argument_list, helper_has_typed_route_navigation_call,
|
|
12
|
-
navigation::term_identifier_shadowed_at,
|
|
11
|
+
argument_list, helper_has_typed_route_navigation_call, is_identifier_text,
|
|
12
|
+
navigation::{expression_declared_type, term_identifier_shadowed_at},
|
|
13
13
|
registry_api::{VisibleNonRouteRegistryApi, visible_non_route_registry_api},
|
|
14
14
|
route_extension_navigation_call, route_location_argument, route_location_expression_member,
|
|
15
|
-
typed_route_navigation_call, visit_named,
|
|
15
|
+
simple_type_name, typed_route_navigation_call, visit_named,
|
|
16
16
|
wrappers::helper_has_typed_route_wrapper_call,
|
|
17
17
|
};
|
|
18
18
|
use crate::{
|
|
@@ -222,6 +222,14 @@ fn helper_references_imported_api(
|
|
|
222
222
|
if imported_api.member_names.contains(name)
|
|
223
223
|
&& member_reference_uses_imported_api(dependency, root, node, source)
|
|
224
224
|
&& !own_instance_member_reference(node, name, source, imported_api, route_classes)
|
|
225
|
+
&& !typed_receiver_outside_registry(
|
|
226
|
+
root,
|
|
227
|
+
node,
|
|
228
|
+
name,
|
|
229
|
+
source,
|
|
230
|
+
imported_api,
|
|
231
|
+
route_classes,
|
|
232
|
+
)
|
|
225
233
|
&& !typed_route_navigation_member_reference(root, node, source, route_classes)
|
|
226
234
|
{
|
|
227
235
|
found = true;
|
|
@@ -303,32 +311,106 @@ fn own_instance_member_reference(
|
|
|
303
311
|
_ => false,
|
|
304
312
|
};
|
|
305
313
|
own_instance_receiver
|
|
306
|
-
&& enclosing_type_header(receiver, source)
|
|
307
|
-
!header
|
|
308
|
-
|
|
309
|
-
|
|
314
|
+
&& enclosing_type_header(receiver, source)
|
|
315
|
+
.is_some_and(|header| !header_names_route_class(header, route_classes))
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
fn typed_receiver_outside_registry(
|
|
319
|
+
root: Node<'_>,
|
|
320
|
+
node: Node<'_>,
|
|
321
|
+
name: &str,
|
|
322
|
+
source: &str,
|
|
323
|
+
imported_api: &VisibleNonRouteRegistryApi,
|
|
324
|
+
route_classes: &BTreeSet<String>,
|
|
325
|
+
) -> bool {
|
|
326
|
+
let Some(receiver) = node
|
|
327
|
+
.parent()
|
|
328
|
+
.filter(|member| {
|
|
329
|
+
member
|
|
330
|
+
.child_by_field_name("property")
|
|
331
|
+
.is_some_and(|property| same_node(property, node))
|
|
310
332
|
})
|
|
333
|
+
.and_then(|member| member.child_by_field_name("object"))
|
|
334
|
+
else {
|
|
335
|
+
return false;
|
|
336
|
+
};
|
|
337
|
+
let Some(owner) = receiver
|
|
338
|
+
.utf8_text(source.as_bytes())
|
|
339
|
+
.ok()
|
|
340
|
+
.and_then(|text| expression_declared_type(root, receiver, text, source))
|
|
341
|
+
.map(|type_name| simple_type_name(&type_name))
|
|
342
|
+
else {
|
|
343
|
+
return false;
|
|
344
|
+
};
|
|
345
|
+
is_identifier_text(&owner)
|
|
346
|
+
&& owner != "dynamic"
|
|
347
|
+
&& !route_classes.contains(&owner)
|
|
348
|
+
&& !imported_api.extension_members.contains(name)
|
|
349
|
+
&& !type_parameter_declared(root, &owner, source)
|
|
350
|
+
&& local_type_header(root, &owner, source)
|
|
351
|
+
.is_none_or(|header| !header_names_route_class(header, route_classes))
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
fn type_parameter_declared(root: Node<'_>, name: &str, source: &str) -> bool {
|
|
355
|
+
let mut found = false;
|
|
356
|
+
visit_named(root, &mut |node| {
|
|
357
|
+
found = found
|
|
358
|
+
|| (node.kind() == "type_parameter"
|
|
359
|
+
&& node
|
|
360
|
+
.child_by_field_name("name")
|
|
361
|
+
.and_then(|type_name| type_name.utf8_text(source.as_bytes()).ok())
|
|
362
|
+
== Some(name));
|
|
363
|
+
});
|
|
364
|
+
found
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
fn header_names_route_class(header: &str, route_classes: &BTreeSet<String>) -> bool {
|
|
368
|
+
header
|
|
369
|
+
.split(|character: char| !is_identifier_character(character))
|
|
370
|
+
.any(|word| route_classes.contains(word))
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
fn local_type_header<'source>(
|
|
374
|
+
root: Node<'_>,
|
|
375
|
+
name: &str,
|
|
376
|
+
source: &'source str,
|
|
377
|
+
) -> Option<&'source str> {
|
|
378
|
+
let mut cursor = root.walk();
|
|
379
|
+
root.named_children(&mut cursor)
|
|
380
|
+
.find(|declaration| {
|
|
381
|
+
TYPE_DECLARATION_KINDS.contains(&declaration.kind())
|
|
382
|
+
&& declaration
|
|
383
|
+
.child_by_field_name("name")
|
|
384
|
+
.and_then(|type_name| type_name.utf8_text(source.as_bytes()).ok())
|
|
385
|
+
== Some(name)
|
|
386
|
+
})
|
|
387
|
+
.and_then(|declaration| type_header(declaration, source))
|
|
311
388
|
}
|
|
312
389
|
|
|
313
390
|
fn enclosing_type_header<'source>(node: Node<'_>, source: &'source str) -> Option<&'source str> {
|
|
314
391
|
let mut current = node.parent();
|
|
315
392
|
while let Some(parent) = current {
|
|
316
|
-
if
|
|
317
|
-
parent
|
|
318
|
-
"class_declaration"
|
|
319
|
-
| "enum_declaration"
|
|
320
|
-
| "extension_declaration"
|
|
321
|
-
| "extension_type_declaration"
|
|
322
|
-
| "mixin_declaration"
|
|
323
|
-
) {
|
|
324
|
-
let body = parent.child_by_field_name("body")?;
|
|
325
|
-
return source.get(parent.start_byte()..body.start_byte());
|
|
393
|
+
if TYPE_DECLARATION_KINDS.contains(&parent.kind()) {
|
|
394
|
+
return type_header(parent, source);
|
|
326
395
|
}
|
|
327
396
|
current = parent.parent();
|
|
328
397
|
}
|
|
329
398
|
None
|
|
330
399
|
}
|
|
331
400
|
|
|
401
|
+
fn type_header<'source>(declaration: Node<'_>, source: &'source str) -> Option<&'source str> {
|
|
402
|
+
let body = declaration.child_by_field_name("body")?;
|
|
403
|
+
source.get(declaration.start_byte()..body.start_byte())
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
const TYPE_DECLARATION_KINDS: &[&str] = &[
|
|
407
|
+
"class_declaration",
|
|
408
|
+
"enum_declaration",
|
|
409
|
+
"extension_declaration",
|
|
410
|
+
"extension_type_declaration",
|
|
411
|
+
"mixin_declaration",
|
|
412
|
+
];
|
|
413
|
+
|
|
332
414
|
fn typed_route_navigation_member_reference(
|
|
333
415
|
root: Node<'_>,
|
|
334
416
|
node: Node<'_>,
|
|
@@ -3,7 +3,8 @@ use tree_sitter::Node;
|
|
|
3
3
|
use super::{
|
|
4
4
|
argument_list, balanced_enclosed_text, class_extends_state, direct_constructor_call_text,
|
|
5
5
|
direct_named_child, direct_static_member_call_text, is_identifier_character, simple_type_name,
|
|
6
|
-
strip_constructor_keyword_prefix, strip_whitespace,
|
|
6
|
+
state_widget_type, strip_constructor_keyword_prefix, strip_whitespace,
|
|
7
|
+
unwrap_parenthesized_text,
|
|
7
8
|
};
|
|
8
9
|
|
|
9
10
|
const BUILD_CONTEXT: &str = "BuildContext";
|
|
@@ -603,8 +604,8 @@ fn visible_name_resolution_at(
|
|
|
603
604
|
if let Some(resolution) = class_member_resolution(root, scope, name, source) {
|
|
604
605
|
return Some(resolution);
|
|
605
606
|
}
|
|
606
|
-
if
|
|
607
|
-
return Some(
|
|
607
|
+
if let Some(resolution) = state_member_resolution(scope, name, source) {
|
|
608
|
+
return Some(resolution);
|
|
608
609
|
}
|
|
609
610
|
}
|
|
610
611
|
if same_node(scope, root) {
|
|
@@ -616,6 +617,19 @@ fn visible_name_resolution_at(
|
|
|
616
617
|
top_level_name_resolution(root, name, source)
|
|
617
618
|
}
|
|
618
619
|
|
|
620
|
+
fn state_member_resolution(
|
|
621
|
+
class_body: Node<'_>,
|
|
622
|
+
name: &str,
|
|
623
|
+
source: &str,
|
|
624
|
+
) -> Option<NameResolution> {
|
|
625
|
+
match name {
|
|
626
|
+
"context" => class_extends_state(class_body, source)
|
|
627
|
+
.then(|| NameResolution::Type(BUILD_CONTEXT.to_owned())),
|
|
628
|
+
"widget" => state_widget_type(class_body, source).map(NameResolution::Type),
|
|
629
|
+
_ => None,
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
|
|
619
633
|
fn top_level_name_resolution(root: Node<'_>, name: &str, source: &str) -> Option<NameResolution> {
|
|
620
634
|
let mut cursor = root.walk();
|
|
621
635
|
for declaration in root.named_children(&mut cursor) {
|
|
@@ -655,8 +669,8 @@ fn class_member_resolution_at(
|
|
|
655
669
|
if let Some(resolution) = class_member_resolution(root, scope, name, source) {
|
|
656
670
|
return Some(resolution);
|
|
657
671
|
}
|
|
658
|
-
if
|
|
659
|
-
return Some(
|
|
672
|
+
if let Some(resolution) = state_member_resolution(scope, name, source) {
|
|
673
|
+
return Some(resolution);
|
|
660
674
|
}
|
|
661
675
|
return None;
|
|
662
676
|
}
|
|
@@ -925,7 +939,16 @@ fn initializer_type(root: Node<'_>, node: Node<'_>, source: &str) -> Option<Stri
|
|
|
925
939
|
return Some(target_type.to_owned());
|
|
926
940
|
}
|
|
927
941
|
}
|
|
928
|
-
|
|
942
|
+
expression_declared_type(root, node, expression, source)
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
pub(super) fn expression_declared_type(
|
|
946
|
+
root: Node<'_>,
|
|
947
|
+
site: Node<'_>,
|
|
948
|
+
expression: &str,
|
|
949
|
+
source: &str,
|
|
950
|
+
) -> Option<String> {
|
|
951
|
+
match navigation_expression_resolution(root, site, expression, source)? {
|
|
929
952
|
NameResolution::Type(type_name) => Some(type_name),
|
|
930
953
|
NameResolution::Shadowed => None,
|
|
931
954
|
}
|
|
@@ -16,6 +16,21 @@ pub(super) fn class_extends_state(class_body: Node<'_>, source: &str) -> bool {
|
|
|
16
16
|
class_or_local_superclass_extends_state(root, class, source, &mut visited)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
pub(super) fn state_widget_type(class_body: Node<'_>, source: &str) -> Option<String> {
|
|
20
|
+
if !class_extends_state(class_body, source) {
|
|
21
|
+
return None;
|
|
22
|
+
}
|
|
23
|
+
let superclass = class_body.parent()?.child_by_field_name("superclass")?;
|
|
24
|
+
let text = superclass.utf8_text(source.as_bytes()).ok()?;
|
|
25
|
+
let widget = text
|
|
26
|
+
.split_once('<')?
|
|
27
|
+
.1
|
|
28
|
+
.split([',', '<', '>'])
|
|
29
|
+
.next()?
|
|
30
|
+
.trim();
|
|
31
|
+
is_identifier_text(widget).then(|| widget.to_owned())
|
|
32
|
+
}
|
|
33
|
+
|
|
19
34
|
fn class_or_local_superclass_extends_state(
|
|
20
35
|
root: Node<'_>,
|
|
21
36
|
class: Node<'_>,
|
|
@@ -22,7 +22,7 @@ use navigation::{
|
|
|
22
22
|
navigation_receiver_accepts_route_location, route_extension_navigation_has_context_argument,
|
|
23
23
|
};
|
|
24
24
|
use receivers::route_extension_receiver_node;
|
|
25
|
-
use state_context::class_extends_state;
|
|
25
|
+
use state_context::{class_extends_state, state_widget_type};
|
|
26
26
|
|
|
27
27
|
fn helper_has_typed_route_navigation_call(
|
|
28
28
|
root: Node<'_>,
|