Skip to content

Fix todo-writer misses for override vals, annotated defs, and symboli… - #69

Merged
bvenners merged 4 commits into
feature-todo-writerfrom
feature-ticket-110
Jul 31, 2026
Merged

Fix todo-writer misses for override vals, annotated defs, and symboli…#69
bvenners merged 4 commits into
feature-todo-writerfrom
feature-ticket-110

Conversation

@cheeseng

Copy link
Copy Markdown
Collaborator

In scala#26657, several declarations were noticed missing Scaladoc stubs that the todo-writer tool failed to
generate. Three root causes were identified:

Root Causes & Fixes

  1. Public val/var declarations were not detected (Declaration.scala, ScaladocChecker.scala)

findUndocumentedResults in ScaladocChecker.scala only checked for DeclKind.Def, DeclKind.Class, and DeclKind.Trait ΓÇö
Val and Var were excluded. For example, override val typeArguments = args.toList in
ClassManifestDeprecatedApis.scala was silently skipped.

Fix: Added DeclKind.Val and DeclKind.Var to the kind check, and added matching Val => "val " / Var => "var " cases
to declKeywordOnLine.

  1. Annotations on the same line as the declaration broke keyword detection (ScaladocChecker.scala)

declKeywordOnLine and declLeadingKeyword used a greedy regex @[\w()\s,."]+ to strip annotations. Because \s
(whitespace) was included in the character class, replaceAll would consume @inline override as part of the
"annotation," stripping def along with it. (This only affected replaceAll ΓÇö findFirstMatchIn in DeclStartPattern
still worked via backtracking.)

Fix: Replaced the greedy replaceAll-based annotation stripping with calls to the existing
Declaration.dropLeadingAnnotations() helper, which properly handles annotation arguments with strings, balanced
parentheses, and nested brackets. Made dropLeadingAnnotations public (was private) for cross-file reuse.

  1. Symbolic method names (e.g. <:<, +=) were not parsed (Declaration.scala)

The name-parsing loop in parseDef only accepted identifier-style characters (isLetterOrDigit, _, $). Symbolic
characters were rejected, producing an empty name "", which then failed the decl.name.nonEmpty check.

Fix: Added isSymbolChar() predicate for Scala operator characters (+, -, =, !, ?, :, ~, /, %, &, *, <, >, |, ^, ),
and modified parseDef to branch: if the name starts with a letter/digit/_/$, use identifier parsing; otherwise, use
symbol-name parsing.

Also updated DeclStartPattern regex with a more precise annotation-stripping regex (proper balanced bracket/paren
matching) for consistency.

…c names

     Three classes of declarations were silently skipped by the todo-writer,
     causing Scaladoc stubs to not be generated for them:

     1. `override val` / `override var` declarations were excluded from
        `findUndocumentedResults` (only Def/Class/Trait were checked).

     2. Declarations with an annotation on the same line (e.g.
        `@inline override def newArray`) were missed because a greedy regex
        in `declKeywordOnLine` / `declLeadingKeyword` consumed following
        keywords (like `def`) alongside the annotation, due to `\s` being
        included in the annotation character class.

     3. Methods with symbolic names (e.g. `<:<`, `::`, `+=`) were skipped
        because `parseDef` only accepted identifier-style name characters
        (letters, digits, `_`, `$`) and produced empty names for operator
        names.

     Fix: extend the kind check to include Val/Var, replace the greedy
     annotation-stripping regex with the existing `dropLeadingAnnotations`
     helper in both methods, and add a symbolic-name parsing branch to
     `parseDef` using a new `isSymbolChar` predicate. Update `DeclStartPattern`
     with a more precise annotation regex for consistency.

     Also make `dropLeadingAnnotations` public to allow reuse across files.
@bvenners

Copy link
Copy Markdown
Collaborator

@codex review

bvenners added 3 commits July 31, 2026 14:08
LLM-assisted fix and regression tests, reviewed and validated locally.
LLM-assisted fix and regression tests, reviewed and validated locally.
@bvenners
bvenners merged commit 2a5ff10 into feature-todo-writer Jul 31, 2026
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.

2 participants