Skip to content

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

Merged
merged 4 commits into from
Jan 17, 2017
Merged

Conversation

kapilmb
Copy link

@kapilmb kapilmb commented Dec 19, 2016

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.

@@ -89,4 +89,48 @@ private bool IsAssignedAtScriptScope(VariableExpressionAst variableExpressionAst
return false;
}
}

internal class FindHashtabeSymbolsVisitor : AstVisitor
Copy link
Contributor

Choose a reason for hiding this comment

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

Slight typo, FindHashtabeSymbolsVisitor

@kapilmb kapilmb force-pushed the kapilmb/provide-psd1-symbols branch from f866b5c to b4874fa Compare December 19, 2016 23:33
@kapilmb
Copy link
Author

kapilmb commented Dec 19, 2016

@daviwil rebased on develop, fixed the typo and updated inline docs.

@kapilmb kapilmb force-pushed the kapilmb/provide-psd1-symbols branch from b4874fa to 3431795 Compare December 19, 2016 23:43
@daviwil
Copy link
Contributor

daviwil commented Dec 20, 2016

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?

@daviwil
Copy link
Contributor

daviwil commented Dec 20, 2016

Hmmm, we might be able to use the list of tokens returned by the parser to find them. There's a TokenKind.Comment here: https://msdn.microsoft.com/en-us/library/system.management.automation.language.tokenkind%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

@rkeithhill
Copy link
Contributor

there seems to be no Ast class or visitor for comment lines

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).

@daviwil
Copy link
Contributor

daviwil commented Dec 20, 2016

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.

@kapilmb
Copy link
Author

kapilmb commented Dec 20, 2016

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.

@daviwil
Copy link
Contributor

daviwil commented Jan 17, 2017

@kapilmb I think this PR is done, right? Can I merge it?

@kapilmb
Copy link
Author

kapilmb commented Jan 17, 2017

Yes, this done.

@daviwil
Copy link
Contributor

daviwil commented Jan 17, 2017

Cool! Merging it.

@daviwil daviwil merged commit 7551864 into develop Jan 17, 2017
@daviwil daviwil deleted the kapilmb/provide-psd1-symbols branch January 17, 2017 20:20
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.

4 participants