diff --git a/README.md b/README.md index bdf6a30e7..25cc83005 100644 --- a/README.md +++ b/README.md @@ -199,6 +199,9 @@ The following settings are supported: * `java.import.gradle.java.home`: Specifies the location to the JVM used to run the Gradle daemon. * `java.project.resourceFilters`: Excludes files and folders from being refreshed by the Java Language Server, which can improve the overall performance. For example, ["node_modules","\.git"] will exclude all files and folders named 'node_modules' or '.git'. Pattern expressions must be compatible with `java.util.regex.Pattern`. Defaults to ["node_modules","\.git"]. * `java.templates.fileHeader`: Specifies the file header comment for new Java file. Supports configuring multi-line comments with an array of strings, and using ${variable} to reference the [predefined variables](https://github.com/redhat-developer/vscode-java/wiki/Predefined-Variables-for-Java-Template-Snippets). +* `java.templates.methodBody`: Specifies the method body snippet for unimplemented methods (e.g. generated by "Add unimplemented methods"). Supports configuring multi-line content with an array of strings, and using ${variable} to reference the [predefined variables](https://github.com/redhat-developer/vscode-java/wiki/Predefined-Variables-for-Java-Template-Snippets). +* `java.templates.methodBodySuper`: Specifies the method body snippet for overridden methods that call `super` (e.g. generated by "Override/Implement Methods"). Supports configuring multi-line content with an array of strings, and using ${variable} to reference the [predefined variables](https://github.com/redhat-developer/vscode-java/wiki/Predefined-Variables-for-Java-Template-Snippets). +* `java.templates.catchBody`: Specifies the catch block body snippet (e.g. generated by "Surround with try/catch"). Supports configuring multi-line content with an array of strings, and using ${variable} to reference the [predefined variables](https://github.com/redhat-developer/vscode-java/wiki/Predefined-Variables-for-Java-Template-Snippets). * `java.templates.typeComment`: Specifies the type comment for new Java type. Supports configuring multi-line comments with an array of strings, and using ${variable} to reference the [predefined variables](https://github.com/redhat-developer/vscode-java/wiki/Predefined-Variables-for-Java-Template-Snippets). * `java.templates.newFile.enabled` : Enable/disable automatic generation of class body and package declaration when creating a new Java file. Set to `false` to create empty Java files. Defaults to `true`. * `java.references.includeAccessors`: Include getter, setter and builder/constructor when finding references. Default to true. diff --git a/document/_java.templateVariables.md b/document/_java.templateVariables.md index f3f78c5d0..2b4f0fcec 100644 --- a/document/_java.templateVariables.md +++ b/document/_java.templateVariables.md @@ -13,3 +13,7 @@ Below are the predefined variables you could use in the template settings such a - `${day}` - current day of the month - `${hour}` - current hour - `${minute}` - current minute +- `${todo}` - the configured task tag (e.g. "TODO") +- `${enclosing_method}` - name of the method being implemented or overridden +- `${body_statement}` - the generated body statement (e.g. a call to the overridden `super` method) +- `${exception_var}` - name of the caught exception variable diff --git a/package.json b/package.json index eaceef004..4edf3b533 100644 --- a/package.json +++ b/package.json @@ -1237,6 +1237,36 @@ "default": [], "order": 20 }, + "java.templates.methodBody": { + "type": "array", + "markdownDescription": "Specifies the method body snippet for unimplemented methods (e.g. generated by \"Add unimplemented methods\"). Supports configuring multi-line content with an array of strings, and using ${variable} to reference the [predefined variables](command:_java.templateVariables).", + "scope": "window", + "default": [ + "// ${todo} Auto-generated method stub", + "throw new UnsupportedOperationException(\"Unimplemented method '${enclosing_method}'\");" + ], + "order": 30 + }, + "java.templates.methodBodySuper": { + "type": "array", + "markdownDescription": "Specifies the method body snippet for overridden methods that call `super` (e.g. generated by \"Override/Implement Methods\"). Supports configuring multi-line content with an array of strings, and using ${variable} to reference the [predefined variables](command:_java.templateVariables).", + "scope": "window", + "default": [ + "// ${todo} Auto-generated method stub", + "${body_statement}" + ], + "order": 31 + }, + "java.templates.catchBody": { + "type": "array", + "markdownDescription": "Specifies the catch block body snippet (e.g. generated by \"Surround with try/catch\"). Supports configuring multi-line content with an array of strings, and using ${variable} to reference the [predefined variables](command:_java.templateVariables).", + "scope": "window", + "default": [ + "// ${todo} Auto-generated catch block", + "${exception_var}.printStackTrace();" + ], + "order": 32 + }, "java.codeGeneration.insertionLocation": { "type": "string", "enum": [