Skip to content

Commit be328ad

Browse files
committed
Split large files
1 parent 3b15e5c commit be328ad

6 files changed

Lines changed: 5783 additions & 5803 deletions

File tree

docs/todo/refactor.md

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -214,23 +214,6 @@ Each item must include:
214214

215215
## Outstanding items
216216

217-
### Split `unknown_members.rs` (5,755 lines)
218-
219-
- **What to do:** `src/diagnostics/unknown_members.rs` is the second
220-
largest file in the project. Sprint 5 adds four new diagnostic
221-
modules (D4, D10, D11, D12, D14) and one large diagnostic feature
222-
(D15) that will use `unknown_members` as a reference. Identify
223-
natural seams — the file likely contains resolution helpers, display
224-
formatting, and per-member-kind logic that can be split into
225-
submodules (e.g. `diagnostics/unknown_members/resolution.rs`,
226-
`diagnostics/unknown_members/helpers.rs`). The goal is to get the
227-
main file under 3,000 lines so new diagnostic work has a clean
228-
model to follow.
229-
- **Which files to change:** `src/diagnostics/unknown_members.rs`
230-
(split into submodules under `src/diagnostics/unknown_members/`).
231-
- **Why it matters for the sprint:** Sprint 5 is diagnostics-heavy
232-
(D4, D10, D11, D12, D14, D15). A 5,700-line diagnostic file sets a
233-
bad precedent for new diagnostic modules and makes it harder to
234-
extract shared helpers that the new modules will need.
217+
No outstanding items.
235218

236219

src/completion/source/throws_analysis.rs

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,60 +1081,62 @@ pub(crate) fn find_uncaught_throw_types_with_context(
10811081

10821082
// 1. Direct `throw new Type(…)` statements
10831083
for throw in &throws {
1084-
if let Some(exc_type) = normalize_throw_type(&throw.type_name) {
1085-
if !is_caught_by(&catches, throw.offset, &exc_type) && seen.insert(exc_type.to_string())
1086-
{
1087-
uncaught.push(exc_type);
1088-
}
1084+
if let Some(exc_type) = normalize_throw_type(&throw.type_name)
1085+
&& !is_caught_by(&catches, throw.offset, &exc_type)
1086+
&& seen.insert(exc_type.to_string())
1087+
{
1088+
uncaught.push(exc_type);
10891089
}
10901090
}
10911091

10921092
// 2. `throw $this->method()` -- return type of method is the thrown type
10931093
for te in &throw_expr_types {
1094-
if let Some(exc_type) = normalize_throw_type(&te.type_name) {
1095-
if !is_caught_by(&catches, te.offset, &exc_type) && seen.insert(exc_type.to_string()) {
1096-
uncaught.push(exc_type);
1097-
}
1094+
if let Some(exc_type) = normalize_throw_type(&te.type_name)
1095+
&& !is_caught_by(&catches, te.offset, &exc_type)
1096+
&& seen.insert(exc_type.to_string())
1097+
{
1098+
uncaught.push(exc_type);
10981099
}
10991100
}
11001101

11011102
// 3. Propagated @throws from called methods (same-file text search)
11021103
for prop in &propagated {
1103-
if let Some(exc_type) = normalize_throw_type(&prop.type_name) {
1104-
if !is_caught_by(&catches, prop.offset, &exc_type) && seen.insert(exc_type.to_string())
1105-
{
1106-
uncaught.push(exc_type);
1107-
}
1104+
if let Some(exc_type) = normalize_throw_type(&prop.type_name)
1105+
&& !is_caught_by(&catches, prop.offset, &exc_type)
1106+
&& seen.insert(exc_type.to_string())
1107+
{
1108+
uncaught.push(exc_type);
11081109
}
11091110
}
11101111

11111112
// 4. Inline `/** @throws ExceptionType */` annotations in the body
11121113
let inline = find_inline_throws_annotations(&body);
11131114
for info in &inline {
1114-
if let Some(exc_type) = normalize_throw_type(&info.type_name) {
1115-
if !is_caught_by(&catches, info.offset, &exc_type) && seen.insert(exc_type.to_string())
1116-
{
1117-
uncaught.push(exc_type);
1118-
}
1115+
if let Some(exc_type) = normalize_throw_type(&info.type_name)
1116+
&& !is_caught_by(&catches, info.offset, &exc_type)
1117+
&& seen.insert(exc_type.to_string())
1118+
{
1119+
uncaught.push(exc_type);
11191120
}
11201121
}
11211122

11221123
// 5. `throw $variable` — resolved from catch clause variable type
11231124
for tv in &throw_vars {
1124-
if let Some(exc_type) = normalize_throw_type(&tv.type_name) {
1125-
if !is_caught_by(&catches, tv.offset, &exc_type) && seen.insert(exc_type.to_string()) {
1126-
uncaught.push(exc_type);
1127-
}
1125+
if let Some(exc_type) = normalize_throw_type(&tv.type_name)
1126+
&& !is_caught_by(&catches, tv.offset, &exc_type)
1127+
&& seen.insert(exc_type.to_string())
1128+
{
1129+
uncaught.push(exc_type);
11281130
}
11291131
}
11301132

11311133
// 6. Cross-file propagated @throws from all call patterns
11321134
for prop in &cross_file_propagated {
1133-
if let Some(exc_type) = normalize_throw_type(&prop.type_name) {
1134-
if !is_caught_by(&catches, prop.offset, &exc_type) && seen.insert(exc_type.to_string())
1135-
{
1136-
uncaught.push(exc_type);
1137-
}
1135+
if let Some(exc_type) = normalize_throw_type(&prop.type_name)
1136+
&& !is_caught_by(&catches, prop.offset, &exc_type)
1137+
&& seen.insert(exc_type.to_string())
1138+
{
1139+
uncaught.push(exc_type);
11381140
}
11391141
}
11401142

src/completion/variable/resolution.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3080,8 +3080,7 @@ pub(in crate::completion) fn check_expression_for_assignment<'b>(
30803080
if let Expression::ArrayAccess(array_access) = assignment.lhs {
30813081
// Extract the base variable name and chain of keys from
30823082
// potentially nested array accesses like `$var['a']['b']['c']`.
3083-
if let Some((base_name, key_chain)) =
3084-
extract_nested_array_access_chain(array_access)
3083+
if let Some((base_name, key_chain)) = extract_nested_array_access_chain(array_access)
30853084
&& base_name == var_name
30863085
{
30873086
// ── Skip when cursor is inside the RHS ────────

0 commit comments

Comments
 (0)