Search code examples
javavisual-studio-codecode-snippetsvscode-snippets

VS Code suggests a code snippet that is not listed with the "insert snippets" command. Where/how is it defined?


when I type if, there's a snippet suggestion as below: But I can't find this snippet by insert snippets command:

it shows nothing:

I just wonder why and the content of the if snippet ain't what I want. I want to edit it but I just can't even find where it is.

I think it might have something to do with the extension Language Support for Java(TM) by Red Hat, since if I disable it, all the snippets are gone. But I didn't see any if related snippets in the snippet file offered by this extension. And I don't want to disable it simply just to inhibit those suggestions because this extension does more than suggest snippets.


Solution

  • Finally, I just figured out why it acts like that. Basically, it's because those snippets are defined on the server side as the comment said. Hence, we can't check and modify them in VS Code.

    For those who don't know what server side means here, plz check out this: Language Server Protocol.

    So if you modify those snippets offered by the server, the only approach you can take is to modify the source code of the server and compile it again, and then replace the one located in the extension. Though, it's quite cumbersome.

    You can reference to editing server.json doesn't work for the detailed steps for this extension Language Support for Java(TM) by Red Hat.