-
-
Notifications
You must be signed in to change notification settings - Fork 12
Add Outline View Support for AppleScript and JXA #42
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
Conversation
- Add document symbol providers for outline view - Implement function/handler detection and parsing - Add activation events for AppleScript and JXA languages - Enhance documentation for FunctionBlock interface
The appleScriptSymbolProvider was adding function symbols twice: - Once inside the emitSymbols() function - Again after calling emitSymbols() This caused duplicate entries for all handlers/functions in the outline.
- Update Biome from 1.9.4 to 2.2.0 to fix config compatibility - Remove invalid organizeImports key from biome config - Fix map/forEach usage in processes.ts (lint error) - Fix function naming conflict in outline.ts (_makeFuncSymbol) - Apply import ordering and formatting fixes
I saw that the initial CI workflow failed. I have attempted to update the PR to solve that. Apologies for the unclean PR than mixes the biome update in with the feature. |
Oh wow, this is awesome. Please allow me a couple of days to properly review it. |
Ugh I already found a bug. The AppleScript works great but it appears that leveraging VSCode's existing JavaScript parsing for JXA as a passthrough, has problems. For some reason it passes back only the top-level entities which isn't very helpful if the file has classes that have nested functions. Originally I didn't look at the output very closely because I could see the outline view was populated and I assumed that it would have the same output as if the file had a .js extension. Anyway I have implemented an acorn parser based tree walker that produces output which more closely matches what one would expect. Apologies for not finding the problem earlier. Once I moved onto working on the project, which had made me want to have outline view in the first place, it became blindingly obvious! Let me know how you would like to proceed in terms of replacing, fixing or creating a second additive PR. |
To be honest, I've been thinking about branching out the JXA support into a separate package for the longest time. I never used it, have practically no knowledge about it, and it would make it easier if someone else wants to take over the package. So I guess it would be okay to limit the outline view support to AppleScript. |
The corrected version is in the PR now. I understand why you might want to break out the JXA stuff to a separate project but doing that might be more work than just leaving it in. Unless you plan to add a lot more features in which case the work of pulling everything apart could eventually pay off. For what it's worth I found that, because they both deal with JSON well, JXA was a good fit when I wanted to access data in Notes.app from something I created in Node.js. If you already know AppleScript and Javascript, it should be trivial to work with JXA if you ever need to. |
VariableDeclaration, | ||
WhileStatement, | ||
WithStatement, | ||
} from "../types/acorn-types"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: could you please use the full filename, i.e. add the file extension?
@@ -1,10 +1,8 @@ | |||
{ | |||
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", | |||
"organizeImports": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is organizeImports
no longer supported in Biome 2.x? You can actually leave this to me, I've updated some of my projects and would love to continue using my config.
Just to give you an update: I managed to verify the functionality, but I'm not yet through with the review. I really do appreciate the effort!
I can only go by what users reported. Seemingly, some are missing some JS features that VSCode provides out of the box or that are provided by other extensions. Ideally, the JXA portion of this extension would inherit all the JavaScript specifics and only provide build commands. Since I only do JavaScript (not JXA), I have no more insights than what others have reported. Maybe a question for you: is the outline view for JXA any different from a JS outline? |
I think this was a misunderstanding. I appreciate you recreating the JS functionality for JXA. I was just thinking that in an ideal world this wouldn't be necessary and some VSCode API would allow you to inherit the functionality from JavaScript (rather than maintaining it yourself and playing catch up). Anyway, how would you feel about me merging the PR as-is and I will take care of the remaining issues (e.g. the broken pipeline and my change request). |
The first failed approach was exactly that to pass JXA through as javascript but unfortunately I could find no way to pass it through to whatever extension the user happened to have installed for JS. What I did originally was create a virtual document that was marked as js with the hope that it would be be parsed correctly but the virtual document seemed to have side effects and the outline was not correct either. I have never worked on a VSCode extension before. What extension was being used and what errors it might be encountering were opaque to me.
Please proceed with the merge in any way you want to. I already built a version for myself and have been using it for the last couple of weeks. I’d love to be able to use an official release instead though.
—
Geordie Korper, pronounced jor-dee
***@***.*** ***@***.***>e
mobile +1-571-276-0476 <tel:+1-571-276-0476>
… On Sep 6, 2025, at 6:23 AM, Jan T. Sott ***@***.***> wrote:
idleberg
left a comment
(idleberg/vscode-applescript#42)
<#42 (comment)>
I think this was a misunderstanding. I appreciate you recreating the JS functionality for JXA. I was just thinking that in an ideal world this wouldn't be necessary and some VSCode API would allow you to inherit the functionality from JavaScript (rather than maintaining it yourself and playing catch up).
Anyway, how would you feel about me merging the PR as-is and I will take care of the remaining issues (e.g. the broken pipeline and my change request).
—
Reply to this email directly, view it on GitHub <#42 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAGHPGDV3Q5UDYFFC2OQJY33RKY33AVCNFSM6AAAAACEKCY4VWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTENRRG43TGMJZGI>.
You are receiving this because you authored the thread.
|
This PR adds document outline support for AppleScript and JXA files, enabling developers to navigate their code more efficiently through VSCode's Outline view.
What's New
Bug Fixes
Technical Details
Changes
Testing
The outline functionality has been tested with various AppleScript and JXA files, including:
Impact
This is a non-breaking enhancement that adds new functionality without modifying existing features.
Users will immediately see an Outline view populated with their script's structure when opening
AppleScript or JXA files.