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

Add missing scopes for correct symbol navigation #189

Merged
merged 5 commits into from
Jan 11, 2025

Conversation

matteocoder
Copy link
Contributor

I added a meta.function-call scope to the command context, so that references to commands written in the recommended PowerShell style can be found by using shift+F12

I also added a new syntax context for class methods, so that instance and static method definitions are marked as functions. Similarly, this change allows F12 and shift+F12 to work correctly for methods.

This enables Sublime Text to correctly find references to functions being called,
at least for functions written according to the recommended style.
Static and instance methods are now identified as functions.
F12 and shift+F12 can now correctly find definitions and references of class methods.
@matteocoder
Copy link
Contributor Author

@deathaxe thank you for your feedback. Is the C syntax file a good start to learn how to properly apply scopes to functions?

@deathaxe
Copy link
Member

deathaxe commented Jan 11, 2025

C also requires some refactoring to make use of latest best practices. Better use Java or PHP.

Maybe Batch or ShellScript may also provide some inspiration as they are of same language family.

I haven't analyzed PowerShell syntax too much, but my hunch is it possibly still requiring significant work to get to Bash/Zsh quality of parsing/scoping expressions. Especially its support of C# blocks may provide some extra challenges to not run into issues with exotic scripts.

@matteocoder
Copy link
Contributor Author

I see. Would you still be comfortable merging in these changes once I fix the tests, at least to provide basic working support for symbol search and navigation?

@deathaxe
Copy link
Member

Anything which improves this syntax is welcome. A major overhaul like for Bash etc. may not take place in the near future.

@deathaxe
Copy link
Member

Note: You proabably want/need to merge master branch into your PR to receive latest CI syntax test fixes.

* master:
  Fix syntax test action (SublimeText#190)
  (Re-)add PowerShell 6+ number suffixes
@matteocoder
Copy link
Contributor Author

@deathaxe sure! In this case, the CI complains about the missing definitions of commands like "Invoke-Something" and "Test-Path". Should I write dummy definitions like

function Invoke-Something {}

Or should I leave those tests be?

@matteocoder matteocoder marked this pull request as ready for review January 11, 2025 19:25
@matteocoder matteocoder requested a review from deathaxe January 11, 2025 19:25
@deathaxe deathaxe merged commit 7b9767e into SublimeText:master Jan 11, 2025
2 checks passed
@michaelblyons
Copy link
Collaborator

@matteocoder if you're still looking for flaws to correct, some missing functionality is mentioned in various posts on #165

@matteocoder
Copy link
Contributor Author

@michaelblyons thank you for pointing me to thee issue. I want to thank you all for the remarkable job you did with the syntax. Having it rewritten in YAML and become more tightly integrated with the plugin gave me the confidence to start contributing.

@matteocoder matteocoder deleted the function-and-method-meta branch January 12, 2025 17:19
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