Skip to content

feat(semantic): add scope_is_descendant_of api#22313

Merged
graphite-app[bot] merged 1 commit into
mainfrom
c/scope-descendant-of
Jun 10, 2026
Merged

feat(semantic): add scope_is_descendant_of api#22313
graphite-app[bot] merged 1 commit into
mainfrom
c/scope-descendant-of

Conversation

@camc314

@camc314 camc314 commented May 11, 2026

Copy link
Copy Markdown
Contributor

I plan to make use of this in the linter in some followup refactor PRs

Copilot AI review requested due to automatic review settings May 11, 2026 09:50
@camc314 camc314 requested a review from Dunqing as a code owner May 11, 2026 09:50
@github-actions github-actions Bot added the A-semantic Area - Semantic label May 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a small Scoping helper API to check ancestor/descendant relationships between scopes, intended for upcoming linter refactors.

Changes:

  • Introduce Scoping::is_scope_descendant_of(scope_id, ancestor_scope_id) implemented via existing scope_ancestors traversal.

Comment thread crates/oxc_semantic/src/scoping.rs Outdated
@camc314 camc314 force-pushed the c/scope-descendant-of branch from 712bae8 to 14d2c00 Compare May 11, 2026 09:56
@camc314 camc314 changed the title feat(semantic): add is_scope_descendant_of api feat(semantic): add scope_is_descendant_of api May 11, 2026
@codspeed-hq

codspeed-hq Bot commented May 11, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 48 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing c/scope-descendant-of (14d2c00) with main (d3d0b18)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Dunqing

Dunqing commented May 14, 2026

Copy link
Copy Markdown
Member

How do you use it? Can you create a follow-up with a few changes first that would be good to understand what you are doing?

@camc314

camc314 commented May 14, 2026

Copy link
Copy Markdown
Contributor Author

How do you use it? Can you create a follow-up with a few changes first that would be good to understand what you are doing?

#22314

@camc314

camc314 commented May 18, 2026

Copy link
Copy Markdown
Contributor Author

Dunqing going to merge this to stop it from hanging around - please feel free to revert if you don't think this should go in

@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label May 18, 2026
@camc314 camc314 assigned camc314 and unassigned Dunqing May 18, 2026

camc314 commented May 18, 2026

Copy link
Copy Markdown
Contributor Author

Merge activity

  • May 18, 9:23 AM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • May 18, 9:23 AM UTC: camc314 added this pull request to the Graphite merge queue.
  • May 18, 9:25 AM UTC: The Graphite merge queue couldn't merge this PR because it was in draft mode.
  • Jun 10, 12:47 PM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Jun 10, 12:47 PM UTC: camc314 added this pull request to the Graphite merge queue.
  • Jun 10, 12:51 PM UTC: Merged by the Graphite merge queue.

@camc314 camc314 marked this pull request as draft May 18, 2026 09:24
graphite-app Bot pushed a commit that referenced this pull request May 18, 2026
I plan to make use of this in the linter in some followup refactor PRs
@graphite-app graphite-app Bot force-pushed the c/scope-descendant-of branch from 14d2c00 to 3ccf46c Compare May 18, 2026 09:24
@camc314 camc314 assigned Dunqing and unassigned camc314 May 18, 2026
@camc314 camc314 removed the 0-merge Merge with Graphite Merge Queue label May 18, 2026
@camc314 camc314 marked this pull request as ready for review June 10, 2026 12:46
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Jun 10, 2026
I plan to make use of this in the linter in some followup refactor PRs
@graphite-app graphite-app Bot force-pushed the c/scope-descendant-of branch from 3ccf46c to 44313da Compare June 10, 2026 12:48
@graphite-app graphite-app Bot merged commit 44313da into main Jun 10, 2026
29 checks passed
@graphite-app graphite-app Bot removed the 0-merge Merge with Graphite Merge Queue label Jun 10, 2026
@graphite-app graphite-app Bot deleted the c/scope-descendant-of branch June 10, 2026 12:51
graphite-app Bot pushed a commit that referenced this pull request Jun 10, 2026
graphite-app Bot pushed a commit that referenced this pull request Jun 11, 2026
…f` API (#23269)

Make use of `Scoping::scope_is_descendant_of` introduced in #22313 for the `no-unused-vars` fixer conflict scope check.

The local helper still preserves the previous same-scope behavior explicitly before delegating descendant checks to the shared scoping API.
graphite-app Bot pushed a commit that referenced this pull request Jun 11, 2026
…f` API (#23270)

Make use of `Scoping::scope_is_descendant_of` introduced in #22313 for ancestor scope checks in `react/exhaustive-deps`.

Both call sites already excluded the same-scope case with `.skip(1)`, so this delegates directly to the shared scoping API without changing behavior.
graphite-app Bot pushed a commit that referenced this pull request Jun 11, 2026
…of` API (#23272)

Make use of `Scoping::scope_is_descendant_of` introduced in #22313 for the `block-scoped-var` outside-scope check.

The helper now preserves the previous same-scope behavior with an explicit equality check before delegating descendant checks to the shared scoping API.
graphite-app Bot pushed a commit that referenced this pull request Jun 11, 2026
…API (#23273)

Make use of `Scoping::scope_is_descendant_of` introduced in #22313 for `prefer-const` control-flow scope checks.

These call sites already checked whether a symbol scope was a proper descendant of a loop or control-flow scope, so this delegates that logic to the shared scoping API without changing behavior.
graphite-app Bot pushed a commit that referenced this pull request Jun 11, 2026
…descendant_of` API (#23275)

Make use of `Scoping::scope_is_descendant_of` introduced in #22313 for `consistent-function-scoping` parent-scope checks.

The rule previously built a set of parent scope IDs for each function scope. The shared scoping API now expresses the same proper-descendant relationship directly, so the temporary set allocation is no longer needed.
graphite-app Bot pushed a commit that referenced this pull request Jun 11, 2026
…descendant_of` API (#23275)

Make use of `Scoping::scope_is_descendant_of` introduced in #22313 for `consistent-function-scoping` parent-scope checks.

The rule previously built a set of parent scope IDs for each function scope. The shared scoping API now expresses the same proper-descendant relationship directly, so the temporary set allocation is no longer needed.
Boshen added a commit that referenced this pull request Jun 15, 2026
### 💥 BREAKING CHANGES

- 7a24911 codegen: [**BREAKING**] Borrow sourcemaps from codegen
(#23422) (Boshen)
- bb0ed44 transformer: [**BREAKING**] Disable styled-components
transpileTemplateLiterals by default (#23171) (Boshen)

### 🚀 Features

- 1490a0a linter/react: Implement react-compiler rule (#23202) (Boshen)
- 6c0bdf0 transformer/react-refresh: Support `module.property.useHook()`
(#23190) (Dunqing)
- 47991bd semantic: Report TS1228 for invalid type predicates (#23174)
(camc314)
- 1d3af58 parser: Add TS2398 parameter property diagnostic (#23216)
(camc314)
- 44313da semantic: Add `scope_is_descendant_of` api (#22313) (camc314)
- e5050c0 parser: Improve diagnostic for rest initializer (#23205)
(camc314)
- ec266bb transformer: Run React Compiler as a feature-gated transform
pass (#23201) (Boshen)
- e7374fe parser: Report error for `const` modifier on interface type
parameter (#23173) (camc314)
- a7c1c9b parser: Report ambient definite variable assertions (#23165)
(camc314)
- d169fcd parser: Report invalid class definite assertions (#23164)
(camc314)
- 00244d8 parser: Report definite property initializer errors (#23160)
(camc314)

### 🐛 Bug Fixes

- 52d0c31 transformer: Replace ambient dot defines (#23231) (camc314)
- 2c28748 transformer/class: Parent generated constructors to class
scope (#23222) (camc314)
- 8edd234 parser: Report accessor definite assertion on token (#23203)
(camc314)
- de38a3f react_compiler: Keep imports referenced only by a local
re-export (#23176) (Boshen)
- f5721c2 codegen: Preserve parentheses around `intrinsic` type
reference (#23156) (Boshen)
- e89f81d parser: Don't emit TS1477 for parenthesized instantiation
expression (#23147) (Boshen)
- 8a04149 parser: Reject module-referencing imports/exports in a
namespace body (#22829) (Boshen)

### ⚡ Performance

- 2783295 parser: Table-driven operator precedence lookup (#23346)
(Boshen)
- 231d5de parser: Single-match member expression dispatch (#23347)
(Boshen)
- e89729b codegen: Accept one-shot wrap closures (#23265) (camc314)
- a6c11fa parser: Force-inline read_non_decimal to fold per-digit number
dispatch (#23157) (Boshen)
- d74964c parser: Store class definite assertion offset (#23170)
(camc314)
- f0fda4d parser: Shrink-wrap cold diagnostic tails out of hot frames
(#23159) (Boshen)
- a082180 parser: Store definite assertion offset (#23167) (camc314)
- 534f9c6 oxc: Conditionally rebuild semantic in compiler pipeline
(#23153) (Boshen)
- b435c6a parser: Skip checkpoint for `infer T extends U` constraint in
disallow context (#23128) (Boshen)
- 7464dce parser: Peek instead of checkpoint/rewind for `export default`
modifier (#23124) (Boshen)
- 80a9a32 parser: Fast-path single-keyword TS declarations (#23083)
(Boshen)
- da1a6c6 diagnostics: Migrate to allocation-optimized oxc-miette
(#23094) (Boshen)
- b7b08ce parser: Peek once for the static modifier disambiguation
(#23079) (Boshen)
- e7e07a3 parser: Fold unary dispatch into a single match (#23076)
(Boshen)

### 📚 Documentation

- d241add semantic: Add `AGENTS.md` test guidance for agents (#23441)
(camc314)
- 026f1ae parser: Add `AGENTS.md` test guidance for agents (#23440)
(camc314)
- 09755ac transformer: Add `AGENTS.md` test guidance for agents (#23439)
(camc314)
- e6bdfd4 lexer: Correct reference link for `byte_handlers!` (#23313)
(Dunqing)
- 65b6d7a allocator: Fix memory leaks in `Arena` examples (#23257)
(overlookmotel)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
camc314 added a commit that referenced this pull request Jul 3, 2026
I plan to make use of this in the linter in some followup refactor PRs
camc314 added a commit that referenced this pull request Jul 3, 2026
camc314 added a commit that referenced this pull request Jul 3, 2026
…f` API (#23269)

Make use of `Scoping::scope_is_descendant_of` introduced in #22313 for the `no-unused-vars` fixer conflict scope check.

The local helper still preserves the previous same-scope behavior explicitly before delegating descendant checks to the shared scoping API.
camc314 added a commit that referenced this pull request Jul 3, 2026
…f` API (#23270)

Make use of `Scoping::scope_is_descendant_of` introduced in #22313 for ancestor scope checks in `react/exhaustive-deps`.

Both call sites already excluded the same-scope case with `.skip(1)`, so this delegates directly to the shared scoping API without changing behavior.
camc314 added a commit that referenced this pull request Jul 3, 2026
…of` API (#23272)

Make use of `Scoping::scope_is_descendant_of` introduced in #22313 for the `block-scoped-var` outside-scope check.

The helper now preserves the previous same-scope behavior with an explicit equality check before delegating descendant checks to the shared scoping API.
camc314 added a commit that referenced this pull request Jul 3, 2026
…API (#23273)

Make use of `Scoping::scope_is_descendant_of` introduced in #22313 for `prefer-const` control-flow scope checks.

These call sites already checked whether a symbol scope was a proper descendant of a loop or control-flow scope, so this delegates that logic to the shared scoping API without changing behavior.
camc314 added a commit that referenced this pull request Jul 3, 2026
…descendant_of` API (#23275)

Make use of `Scoping::scope_is_descendant_of` introduced in #22313 for `consistent-function-scoping` parent-scope checks.

The rule previously built a set of parent scope IDs for each function scope. The shared scoping API now expresses the same proper-descendant relationship directly, so the temporary set allocation is no longer needed.
camc314 pushed a commit that referenced this pull request Jul 3, 2026
### 💥 BREAKING CHANGES

- 7a24911 codegen: [**BREAKING**] Borrow sourcemaps from codegen
(#23422) (Boshen)
- bb0ed44 transformer: [**BREAKING**] Disable styled-components
transpileTemplateLiterals by default (#23171) (Boshen)

### 🚀 Features

- 1490a0a linter/react: Implement react-compiler rule (#23202) (Boshen)
- 6c0bdf0 transformer/react-refresh: Support `module.property.useHook()`
(#23190) (Dunqing)
- 47991bd semantic: Report TS1228 for invalid type predicates (#23174)
(camc314)
- 1d3af58 parser: Add TS2398 parameter property diagnostic (#23216)
(camc314)
- 44313da semantic: Add `scope_is_descendant_of` api (#22313) (camc314)
- e5050c0 parser: Improve diagnostic for rest initializer (#23205)
(camc314)
- ec266bb transformer: Run React Compiler as a feature-gated transform
pass (#23201) (Boshen)
- e7374fe parser: Report error for `const` modifier on interface type
parameter (#23173) (camc314)
- a7c1c9b parser: Report ambient definite variable assertions (#23165)
(camc314)
- d169fcd parser: Report invalid class definite assertions (#23164)
(camc314)
- 00244d8 parser: Report definite property initializer errors (#23160)
(camc314)

### 🐛 Bug Fixes

- 52d0c31 transformer: Replace ambient dot defines (#23231) (camc314)
- 2c28748 transformer/class: Parent generated constructors to class
scope (#23222) (camc314)
- 8edd234 parser: Report accessor definite assertion on token (#23203)
(camc314)
- de38a3f react_compiler: Keep imports referenced only by a local
re-export (#23176) (Boshen)
- f5721c2 codegen: Preserve parentheses around `intrinsic` type
reference (#23156) (Boshen)
- e89f81d parser: Don't emit TS1477 for parenthesized instantiation
expression (#23147) (Boshen)
- 8a04149 parser: Reject module-referencing imports/exports in a
namespace body (#22829) (Boshen)

### ⚡ Performance

- 2783295 parser: Table-driven operator precedence lookup (#23346)
(Boshen)
- 231d5de parser: Single-match member expression dispatch (#23347)
(Boshen)
- e89729b codegen: Accept one-shot wrap closures (#23265) (camc314)
- a6c11fa parser: Force-inline read_non_decimal to fold per-digit number
dispatch (#23157) (Boshen)
- d74964c parser: Store class definite assertion offset (#23170)
(camc314)
- f0fda4d parser: Shrink-wrap cold diagnostic tails out of hot frames
(#23159) (Boshen)
- a082180 parser: Store definite assertion offset (#23167) (camc314)
- 534f9c6 oxc: Conditionally rebuild semantic in compiler pipeline
(#23153) (Boshen)
- b435c6a parser: Skip checkpoint for `infer T extends U` constraint in
disallow context (#23128) (Boshen)
- 7464dce parser: Peek instead of checkpoint/rewind for `export default`
modifier (#23124) (Boshen)
- 80a9a32 parser: Fast-path single-keyword TS declarations (#23083)
(Boshen)
- da1a6c6 diagnostics: Migrate to allocation-optimized oxc-miette
(#23094) (Boshen)
- b7b08ce parser: Peek once for the static modifier disambiguation
(#23079) (Boshen)
- e7e07a3 parser: Fold unary dispatch into a single match (#23076)
(Boshen)

### 📚 Documentation

- d241add semantic: Add `AGENTS.md` test guidance for agents (#23441)
(camc314)
- 026f1ae parser: Add `AGENTS.md` test guidance for agents (#23440)
(camc314)
- 09755ac transformer: Add `AGENTS.md` test guidance for agents (#23439)
(camc314)
- e6bdfd4 lexer: Correct reference link for `byte_handlers!` (#23313)
(Dunqing)
- 65b6d7a allocator: Fix memory leaks in `Arena` examples (#23257)
(overlookmotel)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-semantic Area - Semantic

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants