-
Notifications
You must be signed in to change notification settings - Fork 714
Document highlights #1699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document highlights #1699
Conversation
@microsoft-github-policy-service agree company="Microsoft" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for "Document highlights" functionality in the testing framework. Document highlights show related occurrences of symbols in a document when the user hovers or selects a symbol.
- Adds a new baseline test type for documentHighlights test cases
- Creates extensive test coverage for various TypeScript language constructs including classes, interfaces, keywords, modifiers, and control flow statements
- Includes test cases for edge cases like inherited properties, parameter properties, and JSX elements
Reviewed Changes
Copilot reviewed 224 out of 224 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDefaultImportDifferentName.baseline.jsonc.diff | Diff file showing baseline changes for rename functionality |
testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDefaultImportDifferentName.baseline.jsonc | Baseline for testing rename operations on default imports with different names |
testdata/baselines/reference/fourslash/findAllReferences/renameDefaultImportDifferentName.baseline.jsonc | Baseline for find all references functionality on default imports |
testdata/baselines/reference/fourslash/findAllReferences/findReferencesJSXTagName3.baseline.jsonc | Baseline for finding references in JSX tag names |
testdata/baselines/reference/fourslash/documentHighlights/*.baseline.jsonc | 100+ baseline files covering document highlights for various TypeScript constructs including keywords, modifiers, classes, interfaces, control flow, and edge cases |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a pattern among the failing tests, i.e. something they’re blocked on or a specific follow-up task?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests are giving an incorrect output due to a missing case in getReferencedSymbolsForNode()
in findAllReferences
- I'll update the PR description with cases that could be updated as a follow-up task
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great first PR 👏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Seems like you've quickly gotten a good hang of the codebase :D
Requesting changes because I noticed an incorrect port of some logic, and I also left comments on some refactors and code/comment clean up
Co-authored-by: Isabel Duan <isabelduan@microsoft.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Great work!
TestGetOccurrencesAsyncAwait3 | ||
TestGetOccurrencesClassExpressionConstructor | ||
TestGetOccurrencesConstructor | ||
TestGetOccurrencesConstructor2 | ||
TestGetOccurrencesIfElseBroken | ||
TestGetOccurrencesOfAnonymousFunction | ||
TestGetOccurrencesStringLiteralTypes | ||
TestGetOccurrencesStringLiterals |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious, what kinds of failures are these? Crashes? If they're crashes, I would definitely want to double check these because document highlight is something that happens automatically on cursor move, which means we could be spamming panics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, these must be https://github.com/microsoft/typescript-go/pull/1699/files#r2360590494, which I didn't notice since it was attached to an old rev.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are because of unimplemented cases in FAR, so the test fails when no highlights are returned (which is fine in editor)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String references and a lot of the keyword references aren't implemented
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only two tests fail, and it's due to unexpected responses in fourslash.go
from modules that arent documentHighlights
. The tests are FindAllRefsForModule
and TestJsdocTypedefTagServices
, which return an unexpected response from FindAllReferences
and QuickInfo
respectively.
Fixes #1500
This PR implements provideDocumentHighlights and the corresponding fourslash tests/functions; the implementation covers syntactic highlights fully, but is missing several cases in semantic highlights due to unimplemented cases in
getReferencedSymbolsForNode
. Some prevalent examples from the failing test cases include:getReferencedSymbolsForSymbol
getDocumentHighlightInExport
, getDocumentHighlightInTypeExport`getReferencesForStringLiteral
ingetReferencedSymbolsForNode
getDocumentHighlightTemplateStrings
,getOccurrencesStringLiterals
,getOccurrencesStringLiteralTypes
getReferencesAtLocation
getOccurencesClassExpressionConstructor
,getOccurrencesConstructor
,getOccurrencesConstructor2