Skip to content
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

Code Folding may not work with DSC keywords #812

Closed
glennsarti opened this issue Dec 9, 2018 · 2 comments
Closed

Code Folding may not work with DSC keywords #812

glennsarti opened this issue Dec 9, 2018 · 2 comments
Labels

Comments

@glennsarti
Copy link
Contributor

Code folding is not currently tested against DSC scripts e.g.

https://github.com/PowerShell/ActiveDirectoryCSDsc/blob/79431371bd17a3a872bc71b8463b5bca29a95071/Examples/Resources/AdcsCertificationAuthority/1-InstallCertificationAthority.ps1

Configuration

Node

AdcsCertificationAuthority

glennsarti added a commit to glennsarti/PowerShellEditorServices that referenced this issue Dec 10, 2018
Previously the code folding was not tested against DSC configuration scripts.
This commit;

* Adds tests for a sample DSC script to ensure the folding occurs at the correct
  places
* Adds an AST visitor for the ParamBlockAST object.  This typically spans
  multiple lines.  This commit also adds tests for this scenario
@rjmholt
Copy link
Contributor

rjmholt commented Dec 10, 2018

@glennsarti Those should be of TokenKind DynamicKeyword: See here.

The ASTs generated come from this rule in the parser.

@glennsarti
Copy link
Contributor Author

glennsarti commented Dec 11, 2018

The PR for 814 uses AST. Although it does raise an interesting question

Where should the folding start for;

        WindowsFeature ADCS-Cert-Authority    <--- Should it start here
        {                                     <--- Or should it start here
            Ensure = 'Present'
            Name   = 'ADCS-Cert-Authority'
        }

or if you take a more extreme example

        WindowsFeature ADCS-Cert-Authority    `<--- Should it start here
        `
        `
        `
        `
        {                                     <--- Or should it start here
            Ensure = 'Present'
            Name   = 'ADCS-Cert-Authority'
        }

My gut feeling is it should be on braces as that's the "container". And containers are foldable.

glennsarti added a commit to glennsarti/PowerShellEditorServices that referenced this issue Dec 12, 2018
Previously the code folding was not tested against DSC configuration scripts.
This commit;

* Adds tests for a sample DSC script to ensure the folding occurs at the correct
  places
* Adds an AST visitor for the ParamBlockAST object.  This typically spans
  multiple lines.  This commit also adds tests for this scenario
glennsarti added a commit to glennsarti/PowerShellEditorServices that referenced this issue Dec 12, 2018
Previously the code folding was not tested against DSC configuration scripts.
This commit;

* Adds tests for a sample DSC script to ensure the folding occurs at the correct
  places
* Adds an AST visitor for the ParamBlockAST object.  This typically spans
  multiple lines.  This commit also adds tests for this scenario
glennsarti added a commit to glennsarti/PowerShellEditorServices that referenced this issue Dec 12, 2018
Previously the code folding was not tested against DSC configuration scripts.
This commit;

* Adds tests for a sample DSC script to ensure the folding occurs at the correct
  places
* Adds an AST visitor for the ParamBlockAST object.  This typically spans
  multiple lines.  This commit also adds tests for this scenario
glennsarti added a commit to glennsarti/PowerShellEditorServices that referenced this issue Dec 12, 2018
Previously the code folding was not tested against DSC configuration scripts.
This commit;

* Adds tests for a sample DSC script to ensure the folding occurs at the correct
  places
* Adds an AST visitor for the ParamBlockAST object.  This typically spans
  multiple lines.  This commit also adds tests for this scenario
glennsarti added a commit to glennsarti/PowerShellEditorServices that referenced this issue Dec 14, 2018
Previously the code folding was not tested against DSC configuration scripts.
This commit adds tests for a sample DSC script to ensure the folding occurs at the correct
places
glennsarti added a commit to glennsarti/PowerShellEditorServices that referenced this issue Dec 15, 2018
Previously the code folding was not tested against DSC configuration scripts.
This commit adds tests for a sample DSC script to ensure the folding occurs at the correct
places
glennsarti added a commit to glennsarti/PowerShellEditorServices that referenced this issue Dec 15, 2018
Previously the code folding was not tested against DSC configuration scripts.
This commit adds tests for a sample DSC script to ensure the folding occurs at the correct
places
glennsarti added a commit to glennsarti/PowerShellEditorServices that referenced this issue Dec 16, 2018
Previously the code folding was not tested against DSC configuration scripts.
This commit adds tests for a sample DSC script to ensure the folding occurs at the correct
places
glennsarti added a commit to glennsarti/PowerShellEditorServices that referenced this issue Dec 21, 2018
Previously the code folding was not tested against DSC configuration scripts.
This commit adds tests for a sample DSC script to ensure the folding occurs at the correct
places
glennsarti added a commit to glennsarti/PowerShellEditorServices that referenced this issue Dec 23, 2018
Previously the code folding was not tested against DSC configuration scripts.
This commit adds tests for a sample DSC script to ensure the folding occurs at the correct
places
glennsarti added a commit to glennsarti/PowerShellEditorServices that referenced this issue Jan 7, 2019
Previously the code folding was not tested against DSC configuration scripts.
This commit adds tests for a sample DSC script to ensure the folding occurs at the correct
places
glennsarti added a commit to glennsarti/PowerShellEditorServices that referenced this issue Jan 7, 2019
Previously the code folding was not tested against DSC configuration scripts.
This commit adds tests for a sample DSC script to ensure the folding occurs at the correct
places
glennsarti added a commit to glennsarti/PowerShellEditorServices that referenced this issue Jan 8, 2019
Previously the code folding was not tested against DSC configuration scripts.
This commit adds tests for a sample DSC script to ensure the folding occurs at the correct
places
glennsarti added a commit to glennsarti/PowerShellEditorServices that referenced this issue Jan 12, 2019
Previously the code folding was not tested against DSC configuration scripts.
This commit adds tests for a sample DSC script to ensure the folding occurs at the correct
places
glennsarti added a commit to glennsarti/PowerShellEditorServices that referenced this issue Jan 12, 2019
Previously the code folding was not tested against DSC configuration scripts.
This commit adds tests for a sample DSC script to ensure the folding occurs at the correct
places
TylerLeonhardt pushed a commit that referenced this issue Jan 15, 2019
* (maint) Add tests for code folding for PowerShell classes

Previously there were no tests for PowerShell classes.  This commit adds a simple
test for this scenario to ensure future changes do not break folding.

* (GH-824) Refactor the FoldingReference arrays and lists into it's own class

Previously the folding provider created many intermediate arrays and lists and
required post-processing.  This commit changes the behaviour to use an
accumlator patter with an extended Dictionary class.  This new class adds a
`SafeAdd` method to add FoldingRanges, which then has the logic to determine if
the range should indeed be added, for example, passing nulls or pre-existing
larger ranges.

By passing around this list using ByReference we can avoid creating many objects
which are just then thrown away.

This commit also moves the ShowLastLine code from the FoldingProvider into the
Language Server.  This reduces the number of array enumerations to one.

* (GH-824) Refactor Token Folding Operations

Previously each token type detection was separated into discrete blocks
to make reading the code easier. However this meant there were many
enumerations of the Tokens array as well as passing around intermediate
arrays/lists.  This commit takes the individual methods and overlaps them
to reduce the number of enumerations and regular expression matching to
a minimum.

Note that there are considerable code comments here due to the code now
being more complex on initial review.

* (GH-812) Update folder for DSC style scripts

Previously the code folding was not tested against DSC configuration scripts.
This commit adds tests for a sample DSC script to ensure the folding occurs at the correct
places

* (GH-824) More strict block comment folding detection

Previously the folder would search for the region markers without case sensitivity.
This commit modifies the regular expressions to be more strict on the what
is a region marker and adds a negative test to ensure that regions that are not
cased correctly are not folded .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants