PowerShell: ASTExplorer
So I’ve been working with PowerShell and abstract syntax trees as of late. Here is a tool I wish I had at my disposal when i started with all this. It takes your script, loads all the AST elements into a treeview, lists properties as each AST element is selected in the treeview, and highlights the portion of the script the element represents.
Firstly, I cannot take credit for all of the code. I just revamped another project that used winforms in a single function. The link for the project is at the top line of the script for reference (equally worth checking out, especially if you are not running a more recent version of .NET). I converted the project to be a single xaml form, revamped the textbox a little, added a load button with dialog box, and did some other minor tweaks. There are some minor problems with highlighting text in the unfocused textbox control at times. If the selected text looks ‘off’ then simply tab and shift-tab back to the treeview to correct the view. I lost patience with the xaml underpinnings of this issue. I’m welcome to suggestions on a fix to both that issue and a workable method for scrolling the textbox to the beginning of the selection automatically.
Anyway, hope the community gets some use from this little tool. I’ve uploaded it to both the Microsoft Technet Gallery and my Github repository for your convenience.