Skip to content

Add position function set to Commands #496

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 9 commits into from
Jun 8, 2017

Conversation

SeeminglyScience
Copy link
Collaborator

This provides a set of functions to assist with finding and manipulating positions in script files. This also includes the Import-EditorCommand which will register any function from a module that has the EditorCommandAttribute attached to it.

This is the full list of added commands:

  • Find-Ast
  • Get-Token
  • ConvertFrom-ScriptExtent
  • ConvertTo-ScriptExtent
  • Set-ScriptExtent
  • Join-ScriptExtent
  • Test-ScriptExtent
  • Import-EditorCommand

This change adds a custom implementation of IScriptExtent similar to
InternalScriptExtent.  The major difference being the replacement of
PositionHelper with FileContext.  The PositionHelper class was used to
store the full script text and line start mapping for all ScriptExtent
objects of the same file.  FileContext is a great replacement for this
because it's already kept unique by PSES and it adapts to changes.

- Added FullScriptExtent and FullScriptPosition classes.

- Changed the scriptFile field on FileContext from private to internal.
This class will be used by Import-EditorCommand to target commands for
registration as editor commands.
This changes adds commands from PSESHelperLibrary that assist with
locating and manipulating text based on the syntax tree or position.

- Changed functions to be compatible with PowerShell 3.

- Adapted functions to use FullScriptExtent objects for position
  instead of using reflection to create InternalScriptExtents
- Add standard function loading process.

- Add functions to export list in manifest.

- Update manifest with a unique guid.

- Add localized data file loading.
This change adds markdown help for all added functions. It also adds
a step in the build process to create the MAML XML file.
- Fix an issue with parameter set resolution in ConvertTo-ScriptExtent.

- Fix importing editor commands from a module that is in the middle of
  being imported.

- Add parameter validation to FullScriptExtent constructors.
- Added online link to markdown help.

- Converted comment based help of Register-EditorCommand and
  UnregisterEditorCommand to markdown.

- Fixed psedit not being exported.

- Added cleanup of generated MAML file to build script.
@SeeminglyScience SeeminglyScience requested a review from daviwil June 8, 2017 00:31
@msftclas
Copy link

msftclas commented Jun 8, 2017

@SeeminglyScience,
Thanks for having already signed the Contribution License Agreement. Your agreement was validated by Microsoft. We will now review your pull request.
Thanks,
Microsoft Pull Request Bot

@daviwil
Copy link
Contributor

daviwil commented Jun 8, 2017

Awesome! Thanks a lot for sending this, I'll give it a full review later. Looks like AppVeyor needs to have PlatyPS installed, you can add the Install-Module line for that to appveyor.yml.

@daviwil
Copy link
Contributor

daviwil commented Jun 8, 2017

Looks like the Travis init script also needs to be updated, sorry I forgot to mention that!

https://github.com/PowerShell/PowerShellEditorServices/blob/master/scripts/travis.ps1

Copy link
Contributor

@daviwil daviwil left a comment

Choose a reason for hiding this comment

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

This is really excellent work, man. It is definitely the foundation of the new scripting interface for the PSES C# API changes I'm making!

@@ -15,7 +15,7 @@ RootModule = 'PowerShellEditorServices.Commands.psm1'
ModuleVersion = '1.0.0'

# ID used to uniquely identify this module
GUID = '9ca15887-53a2-479a-9cda-48d26bcb6c47'
GUID = '6064d846-0fa0-4b6d-afc1-11e5bed3c4a9'
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! I realized I screwed that up after I merged the PR ;)

@daviwil daviwil added this to the 1.3.0 milestone Jun 8, 2017
@daviwil daviwil merged commit 2798d02 into PowerShell:master Jun 8, 2017
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.

3 participants