Skip to content

feat: add outline entry model#2703

Merged
HerringtonDarkholme merged 1 commit into
mainfrom
outline-entry-model
Jun 13, 2026
Merged

feat: add outline entry model#2703
HerringtonDarkholme merged 1 commit into
mainfrom
outline-entry-model

Conversation

@HerringtonDarkholme

@HerringtonDarkholme HerringtonDarkholme commented Jun 11, 2026

Copy link
Copy Markdown
Member

Summary

  • add the new outline entry model after removing the legacy placeholders
  • model the current design as item/member entries with item import/export flags and member publicness
  • add serializable source ranges, signatures, AST kind, optional details, and direct member nesting

Test

  • cargo fmt --check
  • cargo test -p ast-grep --lib outline::model
  • cargo test -p ast-grep --lib test_cli
  • cargo check -p ast-grep
  • cargo clippy -p ast-grep --all-targets -- -D warnings

Summary by CodeRabbit

  • New Features

    • Outline export now provides richer, nested symbol data: role/type, source ranges (start/end positions), signatures, optional details, import/export/alias flags, and member visibility; JSON uses camelCase names and omits empty fields.
  • Chores

    • Added internal, serializable outline models to support the enhanced outline format.
  • Tests

    • Unit tests cover serialization, omission of optional fields, import/export marking, and member nesting.

@coderabbitai

coderabbitai Bot commented Jun 11, 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
📝 Walkthrough

Walkthrough

Adds a private model submodule and a serde-serializable outline data model: symbol/role enums, source position/range types, shared entry metadata, top-level items and members with builder helpers, and unit tests validating nesting and JSON serialization.

Changes

Outline Data Model

Layer / File(s) Summary
Module setup and foundational types
crates/cli/src/outline.rs, crates/cli/src/outline/model.rs (lines 1–93)
The model submodule is declared. Adds SymbolType (camelCase LSP kinds), EntryRole (Item/Member), SourcePosition (zero-based line/column), and SourceRange (byte offset range with start/end positions).
Outline entry types and builders
crates/cli/src/outline/model.rs (lines 94–176)
OutlineEntry<'a> contains shared metadata. OutlineItem<'a> flattens entry fields and adds is_import, is_exported, and members with builder setters. OutlineMember<'a> flattens entry fields and adds is_public.
Tests and serialization validation
crates/cli/src/outline/model.rs (lines 177–296)
Unit tests verify import/export flagging, member nesting semantics, and JSON serialization shape/value expectations for keys like role, symbolType, name, isImport, isExported, and nested member fields.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • ast-grep/ast-grep#2700: Adds mod model plumbing in crates/cli/src/outline.rs, related to the module wiring changed here.
  • ast-grep/ast-grep#2690: Introduces an internal outline data model under crates/cli/src/outline/model.rs touching symbol/role types and tests in the same area.
  • ast-grep/ast-grep#2702: Refactors or extends the same outline::model types and serialization surface that this PR implements.

Poem

🐇 I nibble bytes and map each range,
names and kinds in tidy JSON arrange,
Builders hop in, members align—
import, export, public flags fine,
Tests tuck each detail safe and sane.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.32% 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 pull request title accurately describes the main change: adding an outline entry model with serializable types for the outline JSON contract.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch outline-entry-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.

@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: 3

🤖 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 52-66: SourcePosition is missing the required byte offset field;
add a pub(super) byte: usize field to the struct, update the doc comment to
mention zero-based byte offset, and modify the impl SourcePosition::new
signature to accept and set the byte value; ensure the serde rename_all remains
camelCase so "byte" serializes correctly and then update any call sites that
construct SourcePosition (e.g., usages of SourcePosition::new or direct struct
literals) to provide the byte argument.
- Around line 285-312: The test serializes_outline_contract is missing
assertions that the OutlineItem.range serializes to the expected
SourceRange/SourcePosition JSON shape; update the test
(serializes_outline_contract) to assert the structure and values of
json["range"] (and nested start/end positions) to match the spec used by
SourcePosition and SourceRange after their update—locate the test and add
assertions verifying keys and numeric fields (e.g., start.line, start.character,
end.line, end.character) and their expected values consistent with test_range().
- Around line 68-86: The JSON shape is wrong: currently SourceRange serializes
byte_offset as an object while the contract expects each position to include its
byte offset. Update the model so SourcePosition includes a byte: usize field
(and derive Serialize/Deserialize), remove the SourceRange.byte_offset field,
and adjust SourceRange::new signature to accept start/end SourcePosition
(containing their byte values); ensure serde rename_all stays camelCase so
range.start.byte and range.end.byte match the documented shape and update any
callers constructing SourceRange 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: eddc71c0-b928-4778-bc85-d0d8f4cdf07c

📥 Commits

Reviewing files that changed from the base of the PR and between fa4d9e3 and e425084.

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

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

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.52%. Comparing base (fa4d9e3) to head (f07fbf1).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2703      +/-   ##
==========================================
+ Coverage   86.43%   86.52%   +0.08%     
==========================================
  Files         117      118       +1     
  Lines       20212    20330     +118     
==========================================
+ Hits        17471    17590     +119     
+ Misses       2741     2740       -1     

☔ 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.

@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 201-205: OutlineMember should preserve an unknown/undetermined
publicness instead of always emitting false; change the field in the
OutlineMember struct from "is_public: bool" to "is_public: Option<bool>" and
annotate it with serde(skip_serializing_if = "Option::is_none") (and keep
#[serde(flatten)] on entry). Update any code that constructs OutlineMember
(e.g., places creating OutlineMember instances or tests) to pass
Some(true)/Some(false) when known or None when unknown, and update any
deserialization/usage sites to handle Option<bool> instead of bool.
🪄 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: 2040e11c-1f6d-4374-a548-e73b827cf33f

📥 Commits

Reviewing files that changed from the base of the PR and between e425084 and 1afc4a4.

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

Comment thread crates/cli/src/outline/model.rs Outdated
@HerringtonDarkholme
HerringtonDarkholme force-pushed the outline-entry-model branch 5 times, most recently from 18f7902 to 07acb5c Compare June 13, 2026 15:01
@HerringtonDarkholme
HerringtonDarkholme added this pull request to the merge queue Jun 13, 2026
Merged via the queue into main with commit ac802bc Jun 13, 2026
6 checks passed
@HerringtonDarkholme
HerringtonDarkholme deleted the outline-entry-model branch June 13, 2026 15:09
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