Skip to content

Minor cleanups in enclosing_range path#143

Open
rvandermeulen wants to merge 1 commit into
sourcegraph:mainfrom
rvandermeulen:cleanup-enclosing-range
Open

Minor cleanups in enclosing_range path#143
rvandermeulen wants to merge 1 commit into
sourcegraph:mainfrom
rvandermeulen:cleanup-enclosing-range

Conversation

@rvandermeulen
Copy link
Copy Markdown

Two small cleanups around the enclosing_range plumbing added in #123. No behavior change.

LineMap: semanticdbEnclosingRange looked up the same end offset twice. lineNumberForOffset called getLineByOffset, and columnForOffset called getLineAndColumnByOffset (which already includes the line). This PR drops both single-purpose helpers and uses the existing offsetToLineAndCol (now public) once at the call site, so a single FIR lookup yields both line and column.

Field order: semanticdbEnclosingRange assigned the Range builder fields in (startLine, startCharacter, endLine, endCharacter) order while its sibling semanticdbRange uses (startCharacter, startLine, endCharacter, endLine). Align the new function with the existing one for local readability.

Spotted while integrating #123 into a downstream fork. Filing without prior issue since the diff is minimal and self-contained; happy to revise if you'd prefer a different shape.

semanticdbEnclosingRange used two separate lookups against
file.sourceFileLinesMapping for the same end offset:
lineNumberForOffset() called getLineByOffset, columnForOffset() called
getLineAndColumnByOffset. Replace both single-purpose helpers with one
call through the existing offsetToLineAndCol (now public) so the line
and column come from a single FIR lookup.

Also align the field-assignment order in semanticdbEnclosingRange with
semanticdbRange (startCharacter, startLine, endCharacter, endLine) for
local readability.

No behavior change.
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