Skip to content

feat: add outline item model#2690

Merged
HerringtonDarkholme merged 1 commit into
mainfrom
outline-item-model
Jun 7, 2026
Merged

feat: add outline item model#2690
HerringtonDarkholme merged 1 commit into
mainfrom
outline-item-model

Conversation

@HerringtonDarkholme

@HerringtonDarkholme HerringtonDarkholme commented Jun 7, 2026

Copy link
Copy Markdown
Member

Summary

  • add the internal outline data model: files, items, positions, ranges, symbol types, and roles
  • represent roles as a de-duplicated multi-role set so one item can be both definition/export/import
  • add focused unit tests for role/type filtering and multi-role behavior

Notes

  • extraction and rendering intentionally remain out of scope for this PR
  • the model module has a scoped dead-code allowance until later slices consume it

Test

  • cargo test -p ast-grep outline::model --lib
  • commit hook: fmt, cargo check, clippy

Summary by CodeRabbit

  • Refactor
    • Simplified the internal outline representation and improved handling of multi-role outline symbols; no change to CLI behavior or public outputs.
  • Chores
    • Added and updated tests to validate multi-role behavior, flag uniqueness, and role-matching semantics.

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f58a9803-e295-4f95-9a1d-61bfdec31af1

📥 Commits

Reviewing files that changed from the base of the PR and between 0c321d5 and 6ac891b.

📒 Files selected for processing (2)
  • crates/cli/src/outline.rs
  • crates/cli/src/outline/model.rs
✅ Files skipped from review due to trivial changes (1)
  • crates/cli/src/outline.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/cli/src/outline/model.rs

📝 Walkthrough

Walkthrough

Adds a compact outline model: SymbolType enum, OutlineRole enum with OutlineRoles u8 bitflags, a borrowed OutlineItem holding name/type/roles/range, a private model submodule declaration, and unit tests verifying flag semantics.

Changes

Compact Outline Model

Layer / File(s) Summary
Symbol kinds
crates/cli/src/outline/model.rs
Adds SymbolType enum with LSP-like symbol variants used to classify outline entries.
Role enum and bitflags
crates/cli/src/outline/model.rs
Introduces OutlineRole and OutlineRoles(u8) bitflags exposing new, contains, contains_all, and is_empty, plus From<[OutlineRole; N]>.
Simplified OutlineItem
crates/cli/src/outline/model.rs
OutlineItem<'a> stores name, symbol_type, roles: OutlineRoles, and range: Range<Position> with new and has_role methods.
Module declaration
crates/cli/src/outline.rs
Declares private mod model; at module top with #[allow(dead_code)].
Unit tests for flags
crates/cli/src/outline/model.rs
Tests validate bitflag semantics: multi-role handling, duplicate-role uniqueness, subset checks, and is_empty behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰
I nibble flags of roles so small,
Symbols stand tidy, one and all,
Names and ranges snug and neat,
Bitflags march with steady beat,
A compact outline—short and sweet.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat: add outline item model' directly and clearly summarizes the main change: introducing a new outline item model with symbol types, roles, and related data structures.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch outline-item-model

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment thread crates/cli/src/outline/model.rs
Comment thread crates/cli/src/outline/model.rs
@codecov

codecov Bot commented Jun 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.47%. Comparing base (34906ec) to head (6ac891b).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2690      +/-   ##
==========================================
+ Coverage   86.42%   86.47%   +0.05%     
==========================================
  Files         117      118       +1     
  Lines       20187    20266      +79     
==========================================
+ Hits        17446    17525      +79     
  Misses       2741     2741              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread crates/cli/src/outline/model.rs Outdated
Comment thread crates/cli/src/outline/model.rs Outdated
Comment thread crates/cli/src/outline/model.rs Outdated
Comment thread crates/cli/src/outline/model.rs Outdated

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/cli/src/outline/model.rs`:
- Around line 177-178: matches_role currently uses OR via
item.roles.intersects(&self.roles), which allows an item with any one requested
role to match; change it to require all requested roles be present by checking
that the item's roles are a superset of the requested roles (e.g., replace the
intersects check with a superset/subset check such as
item.roles.is_superset(&self.roles) or self.roles.is_subset(&item.roles)) so
that matches_role returns true only when every role in self.roles is present on
OutlineItem.roles; update any downstream expectations/tests (e.g.,
role_filter_matches_any_requested_role) accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b3151f8a-e8f7-46d3-bdeb-da22d58e81e9

📥 Commits

Reviewing files that changed from the base of the PR and between a2ccbd1 and a95e36c.

📒 Files selected for processing (2)
  • crates/cli/src/outline.rs
  • crates/cli/src/outline/model.rs

Comment thread crates/cli/src/outline/model.rs Outdated
Comment thread crates/cli/src/outline/model.rs Outdated
Comment thread crates/cli/src/outline/model.rs Outdated
Comment thread crates/cli/src/outline/model.rs Outdated
Comment thread crates/cli/src/outline/model.rs Outdated
@HerringtonDarkholme
HerringtonDarkholme force-pushed the outline-item-model branch 3 times, most recently from 2d0cf94 to 0c321d5 Compare June 7, 2026 19:42
@HerringtonDarkholme
HerringtonDarkholme added this pull request to the merge queue Jun 7, 2026
Merged via the queue into main with commit 7832f0d Jun 7, 2026
4 checks passed
@HerringtonDarkholme
HerringtonDarkholme deleted the outline-item-model branch June 7, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant