Repository navigation
Fix synthetic location hangs, position lookups, and snippet bounds - #1913
Merged
Merged
Conversation
Parsed positions describe where code came from, so the deprecated `location` setters are removed. - `setLocation()` can map into a real `SourceInfo`, and synthetic sources compute lines arithmetically (no growing `lineStarts`), clamping sentinel ranges like `MAX_SAFE_INTEGER` lines instead of hanging - `findChildAtPosition()` only matches nodes from the searched source; source-less and snippet nodes are stepped into but never matched themselves - `setBounds()` prefers a source with a uri over a snippet's, and source maps leave uri-less (snippet) code unmapped - a lone `\r` in a template string is a line start, like everywhere else in the lexer - `BrsFile.sourceInfo` is public so plugins can pass it to `setLocation()` Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nothing in bsc calls `setLocation()`, and synthetic sources only existed to back the removed `location` setter. `setLocation(target, location, sourceInfo)` now maps into the given source, or leaves the item without a position when the location doesn't fit it. This drops the per-uri synthetic source map and the `lineLength` field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #1845. Fixes weak spots in the
pos/end/sourcepattern found while reviewing it. Parsed positions describe where code came from, so they shouldn't be changed after parsing.locationsetters on tokens and nodes (the getters stay)util.setLocation(target, location, sourceInfo)now requires a real source (i.e.file.sourceInfo, now public) and maps the location into it, or leaves the item without a position when the location doesn't fit. This also fixes a hang when a location ended at a sentinel line likeMAX_SAFE_INTEGERfindChildAtPosition()only matches nodes from the source being searched. Source-less nodes (i.e. a syntheticifwrapping real code) and snippet nodes are stepped into, but never matched on their ownsrcPath) keeps itspos/end, butsetBounds()prefers a source with a uri, and source maps leave uri-less code unmapped instead of pointing at the host file's lines\rinside a template string is now a line start, like everywhere else in the lexerBehavior change: a synthetic node no longer matches every position in
findChildAtPosition().Verified with
npm run test:nocoverandnpm run lint.🤖 Generated with Claude Code