Skip to content

Commit 7de955d

Browse files
committed
Some prune fixes for the extension
1 parent 900bfc2 commit 7de955d

3 files changed

Lines changed: 35 additions & 11 deletions

File tree

cli/src/imports.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ fn process_file(text: &str, manifest: &Manifest) -> (Vec<LocalReport>, Vec<UseEd
9090

9191
match classify_use(&use_item.tree, manifest) {
9292
UseShape::Single { leaf } => {
93-
if !referenced_in_body.contains(&leaf.local_name) {
93+
if is_alive(&leaf.local_name, &referenced_in_body) {
94+
} else {
9495
reports.push(LocalReport {
9596
start_line,
9697
ident: leaf.local_name.clone(),
@@ -109,7 +110,7 @@ fn process_file(text: &str, manifest: &Manifest) -> (Vec<LocalReport>, Vec<UseEd
109110
for m in &members {
110111
match &m.kind {
111112
MemberKind::Engage { leaf } => {
112-
if referenced_in_body.contains(&leaf.local_name) {
113+
if is_alive(&leaf.local_name, &referenced_in_body) {
113114
live_text_parts.push(m.original_text.clone());
114115
any_live_engage = true;
115116
} else {
@@ -283,6 +284,19 @@ fn classify_use(tree: &UseTree, manifest: &Manifest) -> UseShape {
283284
}
284285
}
285286

287+
fn is_alive(local_name: &str, referenced_in_body: &BTreeSet<String>) -> bool {
288+
if referenced_in_body.contains(local_name) {
289+
return true;
290+
}
291+
292+
let bytes = local_name.as_bytes();
293+
if bytes.len() >= 2 && bytes[0] == b'I' && bytes[1].is_ascii_uppercase() {
294+
return true;
295+
}
296+
297+
false
298+
}
299+
286300
fn leading_indent(text: &str, start_line: usize) -> String {
287301
let line = text.lines().nth(start_line).unwrap_or("");
288302
line.chars().take_while(|c| c.is_whitespace() && *c != '\n').collect()

cli/src/scan.rs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,27 @@ fn rewrite_synthetic_trait(segments: &[String]) -> Vec<String> {
120120
let mut out = Vec::new();
121121
let last = segments.last().unwrap();
122122

123-
if let Some(inner) = last.strip_prefix('I') {
123+
let class_name: Option<String> = last.strip_prefix('I').and_then(|inner| {
124124
if let Some(stripped) = inner.strip_suffix("Methods") {
125-
if !stripped.is_empty() {
126-
out.push(replace_last_segment(segments, stripped));
127-
}
125+
(!stripped.is_empty()).then(|| stripped.to_string())
126+
} else if !inner.is_empty() {
127+
Some(inner.to_string())
128+
} else {
129+
None
128130
}
131+
});
129132

130-
if !inner.is_empty() && !inner.ends_with("Methods") {
131-
out.push(replace_last_segment(segments, inner));
132-
}
133-
}
133+
let Some(name) = class_name else {
134+
return out;
135+
};
136+
137+
out.push(replace_last_segment(segments, &name));
138+
139+
let mut canonical: Vec<&str> = segments[..segments.len() - 1].iter().map(String::as_str).collect();
140+
let lowered = name.to_lowercase();
141+
canonical.push(&lowered);
142+
canonical.push(&name);
143+
out.push(canonical.join("::"));
134144

135145
out
136146
}

vscode/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "engage-vscode",
33
"displayName": "engage",
44
"description": "Manage engage-il2cpp Cargo features from VS Code",
5-
"version": "0.2.0",
5+
"version": "0.2.1",
66
"publisher": "DivineDragonFanClub",
77
"repository": {
88
"type": "git",

0 commit comments

Comments
 (0)