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

Overhaul symbols-view #829

Conversation

savetheclocktower
Copy link
Contributor

@savetheclocktower savetheclocktower commented Dec 8, 2023

I should've submitted this earlier; I know it's asking a lot to have someone review this so close to 1.112. If it gets done, great; if not, it can wait a month.

Issue or RFC Endorsed by Atom's Maintainers

#814

Description of the Change

Changes symbols-view to be a package that follows the provider/consumer model, akin to autocomplete-plus. Instead of having its own symbol generation strategy, it exposes an interface and allows other packages to act as its data source.

The goal here is that an ordinary non-bleeding-edge user — someone who was very happy with their Atom experience and who hasn't enabled experimental Tree-sitter grammars — should not notice that anything is different. A Pulsar user who has enabled experimental Tree-sitter grammars might notice that their symbol list is richer and more accurate. A Pulsar user who's using one of my experimental IDE packages may notice that the symbol list is much richer — and that they can now do project-wide symbol searches and jump to the definition of the token underneath their cursor. In each case, we expect that the symbol navigation experience will be equal to or better than what they had before.

Alternate Designs

Other options for how to bring this into core were mooted in #814. The team had a slight preference for this strategy.

Possible Drawbacks

I’ve written unit tests and I can verify that this architecture works for me locally, but I have not done aggressive integration testing across multiple platforms. I am hoping that team members on Windows and Linux can let me know if anything obvious is broken.

Verification Process

Ensure that you are not subscribed to symbols-view-redux, symbol-provider-ctags, or symbol-provider-tree-sitter. Check out this PR and relaunch Pulsar.

Here are some things to try in order to determine whether you’re using the new architecture:

  • When you’re using a file without a Tree-sitter grammar, you shouldn’t notice that anything has changed when you invoke Symbols View: Toggle File Symbols. (LESS files and CoffeeScript files are two notable examples of Tree-sitter-less languages, so maybe try opening your user stylesheet.)
  • When you’re using a file with a Tree-sitter grammar, the Tree-sitter symbol provider should be used. You’ll see evidence of it in the menu in the form of
    • “badges” for each symbol (function, class, etc.);
    • the ability to show symbols even in brand-new files that haven’t been saved to disk;
    • recursive naming behavior in certain file types (try opening a package.json and searching for a key name!).
  • If you want to put it through an even more thorough workout, try installing pulsar-ide-typescript-alpha, enabling the “Include JavaScript” setting, and reloading the window. This new package should be able to act as a symbol provider for both Toggle File Symbols and Toggle Project Symbols. In the latter case, you should be able to press Cmd-Shift-R/Ctrl-Shift-R and search for the name of a function or a class that exists anywhere in the project.

Release Notes

  • Enabled the core symbols-view package to accept symbols from a number of sources, including Tree-sitter grammars and IDE packages.

@savetheclocktower savetheclocktower marked this pull request as ready for review December 8, 2023 18:59
@savetheclocktower savetheclocktower changed the title Integrate symbols view redux Overhaul symbols-view Dec 12, 2023
@savetheclocktower savetheclocktower force-pushed the integrate-symbols-view-redux branch from fdba127 to ee86a18 Compare January 3, 2024 18:26
@savetheclocktower
Copy link
Contributor Author

I think this is in a good place for review. Let's try to get it into the 1.113 release!

@Spiker985
Copy link
Member

Testing process

  1. Cloned branch into integrate folder: git clone https://github.com/savetheclocktower/pulsar.git -b integrate-symbols-view-redux integrate
  2. Moved existing symbol-provider-tree-sitter package: mv ~/.pulsar/packages/symbol-provider-tree-sitter ~/.pulsar
  3. Copied new symbol* folders from integrate: cp -r ~/git/integrate/packages/symbol* ~/.pulsar/packages
  4. Installed required modules per package:
    cd ~/.pulsar/packages/symbol-provider-ctags; pulsar -p install
    cd ~/.pulsar/packages/symbol-provider-tree-sitter pulsar -p install
    cd ~/.pulsar/packages/symbols-view; pulsar -p install
  5. Open Pulsar instance
  6. Edit -> Stylesheet
  7. Ctrl + Shift + P -> Symbols View: Show Active Providers
    image
  8. Ctrl + Shift + P -> Symbols View: Toggle File Symbols
    image
  9. Opened Pulsar Source Code (src/main-process/win-shell.js) -> Symbols View: Toggle File Symbols
    image
  10. Opened a package.json -> Symbols View: Toggle File Symbols
    image
  11. Installed pulsar-ide-typescript alpha, Enabled Include JavaScript setting
  12. Ctrl + Shift + P -> Pulsar IDE Typescript Alpha; Start Language Server
  13. Ctrl + Shift + P -> Symbols View: Toggle Project Symbols -> "getApp"
    image
  14. Ctrl + Shift + P -> Symbols View: Show Active Providers
    image

From the above testing, it appears that the packages are working as expected, however, I only worked on .less, .js and .json files predominantly.

I did test it out on a Rust project, and the symbol-provider-ctags provider was able to parse file symbols.

Conversely, I opened a PowerShell project (which doesn't have any kind of native ctag regex or support) and, as expected, was unable to see any symbols. I also generated a tags file with ctags -R within my project root and was unable to get the completion from that (however, I don't believe that to be a current feature).

From my experience, this integration appears to be successful and I approve of its merge into Core

@savetheclocktower
Copy link
Contributor Author

I did test it out on a Rust project, and the symbol-provider-ctags provider was able to parse file symbols.

@Spiker985, are you sure those were coming from symbol-provider-ctags? I ask because we've got a tags.scm for Rust, so it would've been using that unless symbol-provider-tree-sitter had been disabled.

Just making sure we haven't got a bug we need to deal with at this late hour. If you're unsure which provider was supplying symbols, there's a setting to show the provider name in the list.

@Spiker985
Copy link
Member

Spiker985 commented Jan 6, 2024

I did test it out on a Rust project, and the symbol-provider-ctags provider was able to parse file symbols.

@Spiker985, are you sure those were coming from symbol-provider-ctags? I ask because we've got a tags.scm for Rust, so it would've been using that unless symbol-provider-tree-sitter had been disabled.

Just making sure we haven't got a bug we need to deal with at this late hour. If you're unsure which provider was supplying symbols, there's a setting to show the provider name in the list.

I toggled the setting for showing where suggestions come from, let me re-check

Edit: The symbols are coming from Tree-Sitter
image

Copy link
Member

@confused-Techie confused-Techie left a comment

Choose a reason for hiding this comment

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

I've given the code a once over, and things seem pretty awesome! Just found one little oversight that I've added a request to change for, otherwise I think on the code only end we are good to go.

Copy link
Member

Choose a reason for hiding this comment

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

We need to ensure we add symbol-provider-ctags and symbol-provider-tree-sitter to the packageDependencies section of the package.json here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does that just need to mirror what's present in dependencies? That's weird.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah it's a little odd. But if memory serves, that section has purposes two fold:

  • It is what actually determines what's considered a core package to Pulsar
  • Ensures these packages are part of the preload process

Copy link
Member

@confused-Techie confused-Techie left a comment

Choose a reason for hiding this comment

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

Alright, I'm adding my approval to the code only portion of the PR, thanks for addressing my concerns so quickly.

And with Spikers awesome review of functionality, I think we are good to go, lets get this one merged!

@savetheclocktower savetheclocktower merged commit fd908ca into pulsar-edit:master Jan 7, 2024
102 checks passed
@savetheclocktower savetheclocktower deleted the integrate-symbols-view-redux branch January 7, 2024 23:34
@Daeraxa Daeraxa mentioned this pull request Jan 16, 2024
12 tasks
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