From 4566ce493a765832063c726a5ca8927acd8777f7 Mon Sep 17 00:00:00 2001 From: Mickael Istria Date: Wed, 15 Mar 2023 09:52:53 +0100 Subject: [PATCH] onEnterRules add prefix on newline inside Javadoc (#176800) Add some onEnterRules to Java language configuration to add the usual prefix (` * `) when inserting a new line in Javadoc. Those were actually copied from typescript language configuration which shares the same syntax for comments. --- extensions/java/language-configuration.json | 71 ++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/extensions/java/language-configuration.json b/extensions/java/language-configuration.json index e19d2d749f875..610adc686b45c 100644 --- a/extensions/java/language-configuration.json +++ b/extensions/java/language-configuration.json @@ -29,5 +29,74 @@ "start": "^\\s*//\\s*(?:(?:#?region\\b)|(?:))" } - } + }, + "onEnterRules": [ + { + // e.g. /** | */ + "beforeText": { + "pattern": "^\\s*/\\*\\*(?!/)([^\\*]|\\*(?!/))*$" + }, + "afterText": { + "pattern": "^\\s*\\*/$" + }, + "action": { + "indent": "indentOutdent", + "appendText": " * " + } + }, + { + // e.g. /** ...| + "beforeText": { + "pattern": "^\\s*/\\*\\*(?!/)([^\\*]|\\*(?!/))*$" + }, + "action": { + "indent": "none", + "appendText": " * " + } + }, + { + // e.g. * ...| + "beforeText": { + "pattern": "^(\\t|[ ])*[ ]\\*([ ]([^\\*]|\\*(?!/))*)?$" + }, + "previousLineText": { + "pattern": "(?=^(\\s*(/\\*\\*|\\*)).*)(?=(?!(\\s*\\*/)))" + }, + "action": { + "indent": "none", + "appendText": "* " + } + }, + { + // e.g. */| + "beforeText": { + "pattern": "^(\\t|[ ])*[ ]\\*/\\s*$" + }, + "action": { + "indent": "none", + "removeText": 1 + } + }, + { + // e.g. *-----*/| + "beforeText": { + "pattern": "^(\\t|[ ])*[ ]\\*[^/]*\\*/\\s*$" + }, + "action": { + "indent": "none", + "removeText": 1 + } + }, + { + "beforeText": { + "pattern": "^\\s*(\\bcase\\s.+:|\\bdefault:)$" + }, + "afterText": { + "pattern": "^(?!\\s*(\\bcase\\b|\\bdefault\\b))" + }, + "action": { + "indent": "indent" + } + } + ] }