-
Notifications
You must be signed in to change notification settings - Fork 236
Provide symbol outline for psd1 files #327
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
Conversation
@@ -89,4 +89,48 @@ private bool IsAssignedAtScriptScope(VariableExpressionAst variableExpressionAst | |||
return false; | |||
} | |||
} | |||
|
|||
internal class FindHashtabeSymbolsVisitor : AstVisitor |
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.
Slight typo, FindHashtabeSymbolsVisitor
f866b5c
to
b4874fa
Compare
@daviwil rebased on develop, fixed the typo and updated inline docs. |
b4874fa
to
3431795
Compare
This is pretty awesome! Really handy to jump down to a specific field in the file, even in nested structures. It'd be really nice if we could also jump to commented-out fields too but based on some brief research there seems to be no Ast class or visitor for comment lines. Any thoughts on how we might be able to do that? |
Hmmm, we might be able to use the list of tokens returned by the parser to find them. There's a |
I've asked Jason about this. This is one area where I wish PowerShell were more like Roslyn which retains all source code trivia (like whitespace between tokens and comments). |
I've considered creating a higher-level abstraction that can (literally) fill in the gaps of the Ast for things like that. I think we're going to need it for making code formatting rules in PSScriptAnalyzer. |
I think we can tackle some basic scenarios without needing any help from Asts. For example, @{
ModuleVersion = 0.1
Author = "XYZ"
# RootModule = ".\test.psm1"
# FunctionsToExport = @('get-foo')
} Here, we just extract out the commented fields with some regular expression help. |
@kapilmb I think this PR is done, right? Can I merge it? |
Yes, this done. |
Cool! Merging it. |
This update will show the list of keys present in a psd1 file when a user invokes
Go to Symbols in File... (Ctrl+Shift+O)
on an psd1 file.