Skip to content
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

Add SymbolInformation.enclosing_symbol #164

Merged
merged 3 commits into from
Jun 4, 2023
Merged

Conversation

olafurpg
Copy link
Member

Towards #154

Previously, it was not possible to determine the enclosing symbol of a local because the syntax for local symbols has no hierarchy (unlike global symbols). This PR closes the gap by adding a field SymbolInformation.enclosing_symbol to allow documenting the "parent" or "owner" of a local symbol.

Test plan

Green CI.

// documentation. However, in the situation that you wish to include a local
// symbol in the hierarchy, then you can use `enclosing_symbol` to locate the
// "parent" or "owner" of this local symbol.
string enclosing_symbol = 8;
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 debated using owner or parent, which is commonly the name of this functionality in compiler APIs that I have worked with (Java, Scala, C#, and TypeScript). However, I went with enclosing_symbol to make it more self-descriptive and also to reflect that I don't expect this to be a high-traffic API (unlike owner in the compiler that you use all the time).

@olafurpg
Copy link
Member Author

cc/ @donsbot this PR implements the last remaining proposal from #154

scip.proto Outdated
Comment on lines 334 to 339
// The primary use-case for this field is to allow local symbol to be displayed
// in a symbol hierarchy for API documentation. It's OK to leave this field
// empty for local variables since local variables usually don't belong in API
// documentation. However, in the situation that you wish to include a local
// symbol in the hierarchy, then you can use `enclosing_symbol` to locate the
// "parent" or "owner" of this local symbol.
Copy link
Contributor

Choose a reason for hiding this comment

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

Reading this as someone writing an indexer, it's not clear under what circumstances I would want to include a local symbol in a symbol hierarchy. Could you add an example here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. I added an example.

@varungandhi-src
Copy link
Contributor

The Haskell bindings also need to be updated.

Towards #154

Previously, it was not possible to determine the enclosing symbol of a
local because the syntax for local symbols has no hierarchy (unlike
global symbols). This PR closes the gap by adding a field
`SymbolInformation.enclosing_symbol` to allow documenting the "parent"
or "owner" of a local symbol.
@olafurpg
Copy link
Member Author

The Haskell bindings are now automatically updated \o/

@olafurpg olafurpg merged commit 6b8102d into main Jun 4, 2023
@olafurpg olafurpg deleted the olafurpg/enclosing_symbol branch June 4, 2023 10:35
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