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

(GH-813) Use AST for code folding #853

Closed

Conversation

glennsarti
Copy link
Contributor

The AST contains the most correct version of how a script is interpreted. This
includes regions of text. Currently the code folder only uses the Tokens which
requires the folder to re-implement some of the AST behaviour e.g. matching
token pairs for arrays etc. The code folder should be implemented using as much
of the AST as possible. This commit;

  • Moves most of the region detection to use the AST Extents and uses a new
    FindFoldsASTVisitor.
  • Modifies the tests and language server to use the new method fold detection
    class.
  • Moved the code to modify the end line of folding regions to the language
    server code.
  • The test fixture changes were needed due to how the tokeniser and ast
    see the beginning of some regions. Users will probably not notice.

Note that this requires a modern PowerShell version due to use of
ASTVisitor2 class.

Fixes #813

The AST contains the most correct version of how a script is interpreted. This
includes regions of text. Currently the code folder only uses the Tokens which
requires the folder to re-implement some of the AST behaviour e.g. matching
token pairs for arrays etc.  The code folder should be implemented using as much
of the AST as possible.  This commit;

* Moves most of the region detection to use the AST Extents and uses a new
  FindFoldsASTVisitor.
* Modifies the tests and language server to use the new method fold detection
  class.
* Moved the code to modify the end line of folding regions to the language
  server code.
* The test fixture changes were needed due to how the tokeniser and ast
  see the beginning of some regions.  Users will probably not notice.

Note that this requires a modern PowerShell version due to use of
ASTVisitor2 class.
@glennsarti glennsarti force-pushed the gh-813-use-ast-folding branch from 67a89ef to f9c404a Compare January 21, 2019 13:35
@TylerLeonhardt
Copy link
Member

So glad to see xplat tests doing their job 😊 what a concept! 😅

@glennsarti
Copy link
Contributor Author

So it appears that the non-Windows platforms don't have the parsing methods available. However if using tokens it all works ok. I see this as a blocker and there's basically no point in using the AST right now. maybe in the future this changes? Until then, closing this PR and the associated issue

@glennsarti glennsarti closed this Feb 3, 2019
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.

2 participants