Skip to content

Render documentation and relationships in the snapshot tests #97

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

Merged
merged 2 commits into from
Apr 28, 2022

Conversation

olafurpg
Copy link
Member

Previously, the snapshot tests only displayed occurrence roles and symbols. Now, the additionally display the SymbolInformation.{documentation,relationships} fields for definition occurrences.

Test plan

See updated snapshot tests.


const lsiftyped = lsif.lib.codeintel.lsiftyped

export function formatSnapshot(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took the liberty to extract this functionality into a separate file so that it's easier to reuse between projects.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to copy-paste this logic for now while the format is still evolving. The actual formatting logic is fairly simple to port between languages

@@ -141,16 +141,17 @@ export class FileIndexer {
sym: ts.Symbol,
symbol: LsifSymbol
): void {
const documentation = [
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff in the snapshots was difficult to understand with this bugfix so I included it in the PR

Comment on lines +7 to +8
// documentation ```ts\nProps\n```
// documentation Takes loading prop, input component as child
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is repeating the documentation on multiple lines intentional? TJ's PR uses a separate character from the second line.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation part is repeated for separate documentation elements. The formatting of multiline docstrings is different, here newlines are rendered as an escaped \n character
CleanShot 2022-04-28 at 18 02 33

Comment on lines +44 to +45
const isDefinition =
(occurrence.symbol_roles & lsiftyped.SymbolRole.Definition) > 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe !! or !== 0 would be more idiomatic here rather than > 0?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what's most idiomatic, this is how I would have written it in Java :/

@olafurpg olafurpg merged commit 71505e4 into main Apr 28, 2022
@olafurpg olafurpg deleted the olafurpg/snapshots branch April 28, 2022 16:04
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