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 findDocumentSymbols #7
Conversation
A question was asked in gitter if VS Code has an equivalent of WebStorm's "File Structure Popup" in HTML. The closest that vscode has is "Show document symbols", but the html language service does not provide that. To attempt parity with webstorm in this area, I have implemented findDocumentSymbols. I have augmented the parser to track tag attributes and their values (I could see nowhere before that attributes were being used) and combine the tag name with id and class attributes to build a symbol name. For example, <div id='test' class='my classes'></div> will have the symbol name div#id.my.classes. For child elements, I set the containerName to be the symbol name of their parent tag. So in <div id='container1'><span></span></div>, the span element would have the symbol name span and the container name div#container1 I set the SymbolKind to field just to have something as I am unsure what the convention is for non-code related symbols. For this to appear in vscode, it would necessitate a change there as well. I have a pull request ready to submit if this is accepted.
Awesome, looks good @hoovercj ! |
Changing attributeNames to attributes is strictly speaking an API breakage. I added attributeNames back but only in the implementation as to stay compatible. @hoovercj Actually all that's missing is a full test. I'll add these. |
@aeschli what tests are missing? I tried to add tests to avoid putting extra effort on the team to accept the PR, so I'd like to know what I missed for future reference. |
Np, see my commit above. I'll adopt the change to VSCode so that it gets in today. |
@aeschli how is the test you added different than the one I added in src/test/documentSymbols.test.ts? Yours are organized slightly differently than mine, but they essentially cover the same thing:
Given that you've added |
@hoovercj Sorry, I completely didn't see these tests. I must have been sleeping. Sorry. |
:-) Glad we both had similar ideas. Thanks for accepting the pull request, cheers! |
I merged the tests |
A question was asked in gitter if VS Code has an equivalent of WebStorm's "File Structure Popup" in HTML. The closest that vscode has is "Show document symbols", but the html language service does not provide that.
To attempt parity with webstorm in this area, I have implemented findDocumentSymbols. I have augmented the parser to track tag attributes and their values (I could see nowhere before that attributes were being used) and combine the tag name with id and class attributes to build a symbol name.
For example,
<div id='test' class='my classes'></div>
will have the symbol namediv#id.my.classes
. For child elements, I set the containerName to be the symbol name of their parent tag. So in<div id='container1'><span></span></div>
, the span element would have the symbol namespan
and the container namediv#container1
I set the SymbolKind to field just to have something as I am unsure what the convention is for non-code related symbols.
For this to appear in vscode, it would necessitate a change there as well. I have a pull request ready to submit if this is accepted.