Uh oh!
There was an error while loading. Please reload this page.
Add document symbols for #region - #1911
Conversation
Waiting for #1886 as I'd rather get merge conflicts here 🙂 |
Andy Jordan (andyleejordan)
commented
Feb 2, 2023
Heh, ok Frode Flaten (@fflaten) things are so cleaned up now I think you can do this again (much more easily!) |
12e63f8 to
bd28a73CompareFor consistent behavior and easier maintenance
Rewrote to use ReferenceTable for caching, but still a WIP. Todo:
|
Andy Jordan (andyleejordan)
commented
Feb 14, 2023
I'd keep using it, it'll make everything easier. We can add "region" as a symbol type and just exclude them where appropriate. |
Andy Jordan (andyleejordan)
commented
Feb 14, 2023
Hm I see what you mean now, since it's not done via AST but simply RegEx, and is only useful for the current document...I'll ponder, I'm sure there's a good way to handle that. |
Adds support for outline nesting and breadcrumbs
Regions aren't a reference. Only useful as cosmetic/navigation symbol in current document.
Andy Jordan (andyleejordan)
left a comment
There was a problem hiding this comment.
If you want to take a crack at what I'm contemplating, go for it! Otherwise I'll try to get to it later today.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| { | ||
| internal static class RegionVisitor | ||
| { | ||
| internal static void GetRegionsInDocument(ScriptFile file, Func<SymbolReference, AstVisitAction> action) |
There was a problem hiding this comment.
I like this a lot, makes reworking it much easier!
There was a problem hiding this comment.
Andy Jordan (@andschwa): I assume you meant the separate class.
Because the Func-parameter won't make much sense when moving out of ReferenceTable, would it? Unless you'd prefer Action<SymbolReference>-parameter over IEnumerable return type.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Andy Jordan (andyleejordan)
commented
Feb 23, 2023
I was wrong here 😆 |
| IEnumerable<SymbolReference> foundSymbols = ProvideDocumentSymbols(scriptFile); | ||
| if (foundSymbols is null) | ||
| { | ||
| return null; | ||
| } | ||
| foundSymbols = foundSymbols.Concat(RegionVisitor.GetRegionsInDocument(scriptFile)); | ||
There was a problem hiding this comment.
I didn't see a reason to keep the null-check. The local method ProvideDocumentSymbols() always returns a list, right?
| } | ||
| [Fact] | ||
| public void FindsRegionSymbolsInFile() |
There was a problem hiding this comment.
This technically doesn't belong here as SymbolsService isn't used for DocumentSymbolHandler. Move to own test-file? Suggestion?
Andy Jordan (andyleejordan)
commented
Feb 28, 2023
Closing since I integrated this, thanks again so much for your work! |

PR Summary
Adds symbols for regions for easier navigation. Currently available in outline + breadcrumbs and "go to symbol in current editor".
PR Context
FixPowerShell/vscode-powershell#3604
FixPowerShell/vscode-powershell#3210