Search code examples
javavisual-studio-codevscode-snippets

Why aren't choice snippets working properly in new files in VS Code 1.80.0?


For example, choice-type snippet suggestions are not showing up as I expect in version 1.20.0 of the redhat.java extension for VS Code. That includes snippet suggestions and other code suggestions. I observe this every time I create a new file.

In the Java Output log, I see messages like this:

!ENTRY org.eclipse.jdt.ls.core 4 0 2023-07-11 19:09:12.705
!MESSAGE Error occured while building workspace. Details: 
 message: Syntax error, insert ";" to complete BlockStatements; code: 1610612976; resource: <path>.java; line: 6
 message: sout cannot be resolved; code: 570425394; resource: <path>.java; line: 6
 message: Syntax error, insert "VariableDeclarators" to complete LocalVariableDeclaration; code: 1610612976; resource: <path>.java; line: 6

Why is this happening? How can the issue be resolved?


Solution

  • This is a VS Code regression with choice snippets. There's an issue ticket tracking it here: Are choice snippets dangerous now? Breaking extensions completions #187642. There was a regression from commit 3e232a8. The issue is reportedly fixed in version 1.80.1, which has been released. If it's not available to you yet for some reason, use VS Code Insiders.

    The Java extension issue is tracked here: https://github.com/redhat-developer/vscode-java/issues/3194. Notably, if you look in the release notes for the Red Hat Java Language Support extension, the 1.20.0 section says:

    • enhancement - Use choice syntax as placeholder for constructor/method/field snippets. See #3018, #3140.