Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ The following settings are supported:
* `java.hover.javadoc.enabled` : Enable/disable displaying Javadoc on hover. Defaults to `true`.

New in 1.53.0
* `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.updateImportsOnPaste.enabled` : Enable/disable auto organize imports when pasting code. Defaults to `true`.

Semantic Highlighting
Expand Down
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1191,6 +1191,13 @@
"title": "Code Generation",
"order": 100,
"properties": {
"java.templates.newFile.enabled": {
"type": "boolean",
"default": true,
"markdownDescription": "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`.",
"scope": "window",
"order": 5
},
"java.templates.fileHeader": {
"type": "array",
"markdownDescription": "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](command:_java.templateVariables).",
Expand Down
3 changes: 3 additions & 0 deletions src/fileEventHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export function registerFileEventHandlers(client: LanguageClient, context: Exten
}

async function handleNewJavaFiles(e: FileCreateEvent) {
if (!getJavaConfiguration().get<boolean>('templates.newFile.enabled', true)) {
return;
}
const emptyFiles: Uri[] = [];
const textDocuments: TextDocument[] = [];
for (const uri of e.files) {
Expand Down
Loading