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

Support for the new Apex null-coalescing operator (Spring '24) #1176

Closed
pozil opened this issue Jan 18, 2024 · 15 comments
Closed

Support for the new Apex null-coalescing operator (Spring '24) #1176

pozil opened this issue Jan 18, 2024 · 15 comments

Comments

@pozil
Copy link

pozil commented Jan 18, 2024

Hi @dangmai, the Spring '24 release introduces the Apex null-coalescing operator ??. It would be great to add support for this in your plugin.

I see that the Apex team recently updated the jorje parser so it looks like you could proceed with an update of your plugin. Let me know if not and I'll raise the issue with the team.

Once again, thanks a lot for your great tool.

@pozil
Copy link
Author

pozil commented Jan 18, 2024

Update from the tooling team: the new jorje JAR should be pushed near the Spring '24 release date (Feb 10-11).

@dangmai
Copy link
Owner

dangmai commented Jan 18, 2024

Awesome, thanks for letting me know about it. I'll add support for it when the new JAR is out!

@pozil
Copy link
Author

pozil commented Feb 13, 2024

Hi @dangmai, it looks like the product team released the JAR last week.

@dangmai
Copy link
Owner

dangmai commented Feb 13, 2024

Awesome! I'll most likely add support for this this weekend, thank you for the heads up!

@dangmai
Copy link
Owner

dangmai commented Feb 18, 2024

Support for the Null-Coaslescing Exression has been added and will be included in the next release. Thanks again for raising this!

@dangmai dangmai pinned this issue Feb 18, 2024
@dangmai
Copy link
Owner

dangmai commented Feb 21, 2024

This has been released as part of v2.1.0.

@pozil
Copy link
Author

pozil commented Feb 21, 2024

Thank you so much!

@msouther-lisc
Copy link

msouther-lisc commented Feb 22, 2024

@dangmai I installed v2.1.0, but if I try to save a file that includes the null coalescing operator, it doesn't format, and I get this error message:

No handler found for apex.jorje.data.ast.Expr$NullCoalescingExpr. Please file a bug report.

@dangmai
Copy link
Owner

dangmai commented Feb 22, 2024

@msouther-lisc How are you running Prettier Apex? If you're running it via VSCode, did you try restarting VSCode yet?

Also, try running these commands and paste the results here:

npm ls prettier
npm ls prettier-plugin-apex

@msouther-lisc
Copy link

msouther-lisc commented Feb 22, 2024

@dangmai I hadn't restarted VS Code yet when I was getting the error. After restarting VS Code, I am no longer getting the error, but I'm not getting any formatting on Apex files whatsoever (other files, e.g. JavaScript files, still work OK). It looks like Prettier is disabled when I'm on an Apex file:

image

There is probably a simple reason for this, but I'm not sure what I'm doing wrong.

Here is the output of the commands you requested:

$ npm ls prettier
[email protected] C:\git\salesforce-liscerp
├─┬ @prettier/[email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
└── [email protected]
$ npm ls prettier-plugin-apex
[email protected] C:\git\salesforce-liscerp
└── [email protected]

@dangmai
Copy link
Owner

dangmai commented Feb 22, 2024

I see - for your initial issue the reason VSCode has to be restarted when a Prettier plugin is upgraded is because of this bug on their repo prettier/prettier-vscode#3179

As for your current problem, I'm not sure what the issue is, but have you applied the workaround in this ticket yet? #1168 (comment)

@msouther-lisc
Copy link

I got it working after some trial and error. I added a new comment on the workaround thread so others can benefit from my experience.

@dangmai
Copy link
Owner

dangmai commented Feb 22, 2024

That means you upgraded from 1.13.0, here is the guide to upgrade from v1 to v2: https://github.com/dangmai/prettier-plugin-apex/wiki/Upgrading-to-Prettier-Apex-v2 Generally speaking when you upgrade a major version there'll be some manual steps you need to take.

@msouther-lisc
Copy link

Yep, you nailed it. That's exactly what the issue was there. 😝 Many thanks for your support! Much admiration for the work you do.

@aminnaggar
Copy link

aminnaggar commented Feb 22, 2024

For anyone seeing this later the summary of what you need to do:

  1. upgrade prettier to "^3.x"
  2. upgrade prettier-plugin-apex to "^2.x"
  3. upgrade @prettier/plugin-xml to "^3.x" (might as well)
  4. add "plugins": ["prettier-plugin-apex", "@prettier/plugin-xml"] to your ".prettierrc" (prettier 3 needs this)
  5. add "prettier.configPath": "./.prettierrc" to your ".vscode/settings.json" (even if it looks like it's picking up the right path in your vscode output logs)
  6. restart vscode due to a known bug

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

No branches or pull requests

4 participants