Skip to content

Commit b1e6afe

Browse files
committed
Exposing formatting options settings.
1) New settings key jdk.format.options 2) Netbeans formatting options can be specified inside the jdk.format.options as key-value pairs 3) Wiki for formatting to be updated with valid list of key-values and description.
1 parent 0eef9c5 commit b1e6afe

File tree

6 files changed

+32
-1
lines changed

6 files changed

+32
-1
lines changed

build.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
patches/java-notebooks.diff
7878
patches/update-commons-lang3-3.19.0.diff
7979
patches/update-testng-7.11.0.diff
80+
patches/formatOptions.diff
8081
</string>
8182
<filterchain>
8283
<tokenfilter delimoutput=" ">

patches/formatOptions.diff

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
diff --git a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/WorkspaceServiceImpl.java b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/WorkspaceServiceImpl.java
2+
index eaff1013cd..107daefbfb 100644
3+
--- a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/WorkspaceServiceImpl.java
4+
+++ b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/WorkspaceServiceImpl.java
5+
@@ -1423,6 +1423,13 @@ public final class WorkspaceServiceImpl implements WorkspaceService, LanguageCli
6+
Exceptions.printStackTrace(ex);
7+
}
8+
}
9+
+ // When no path set or wanting to override specific option
10+
+ Preferences prefs = CodeStylePreferences.get(fo, "text/x-java").getPreferences();
11+
+ JsonObject formatOptions = configuration.getAsJsonObject("options");
12+
+ Map<String,JsonElement> options = formatOptions.asMap();
13+
+ for(String key:options.keySet()){
14+
+ prefs.put(key, options.get(key).getAsString());
15+
+ }
16+
}
17+
18+
void updateJavaImportPreferences(FileObject fo, JsonObject configuration) {

vscode/package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,13 @@
269269
"jdk.format.settingsPath": {
270270
"type": "string",
271271
"description": "%jdk.configuration.formatterSettings.description%",
272-
"default": null
272+
"default": null,
273+
"deprecationMessage": "%jdk.configuration.formatterSettings.deprecationMessage%"
274+
},
275+
"jdk.format.options": {
276+
"type": "object",
277+
"description": "%jdk.configuration.formatOptions.description%",
278+
"default": {}
273279
}
274280
}
275281
},

vscode/package.nls.ja.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
"jdk.configuration.testEditor.description": "エディタで実行/デバッグ・テストを有効にします",
5151
"jdk.configuration.javadoc.timeout.description": "コード補完でのJavadocのロードのタイムアウト(ミリ秒)(無制限は-1)",
5252
"jdk.configuration.formatterSettings.description": "エクスポート済のフォーマッタ設定を含むファイルへのパス",
53+
"jdk.configuration.formatterSettings.deprecationMessage": "This settings is about to deprecated use the jdk.format.settings instead",
54+
"jdk.configuration.formatOptions.description" : "Holder for the formatting options. For the list of valid keys and corresponding values see https://github.com/oracle/javavscode/wiki/Java-formatting-preferences",
5355
"jdk.configuration.hints.preferences.description": "エクスポート済のヒント・プリファレンスを含むファイルへのパス",
5456
"jdk.configuration.organiseImports.description": "ドキュメントの保存でインポートの編成アクションを有効化します",
5557
"jdk.configuration.organiseImports.sortingOrder.description": "import文のグループ(パッケージ接頭辞により指定)およびソート順。グループ内のImport文はアルファベット順です",

vscode/package.nls.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
"jdk.configuration.testEditor.description": "Enable Run/Debug test in editor",
5151
"jdk.configuration.javadoc.timeout.description": "Timeout (in milliseconds) for loading Javadoc in code completion (-1 for unlimited)",
5252
"jdk.configuration.formatterSettings.description": "Path to the file containing exported formatter settings",
53+
"jdk.configuration.formatterSettings.deprecationMessage": "This settings is about to deprecated use the jdk.format.settings instead",
54+
"jdk.configuration.formatOptions.description" : "Holder for the formatting options. For the list of valid keys and corresponding values see https://github.com/oracle/javavscode/wiki/Java-formatting-preferences",
5355
"jdk.configuration.hints.preferences.description": "Path to the file containing exported hints preferences",
5456
"jdk.configuration.organiseImports.description": "Enable organize imports action on a document save",
5557
"jdk.configuration.organiseImports.sortingOrder.description": "Groups of import statements (specified by their package prefixes) and their sorting order. Import statements within a group are ordered alphabetically",

vscode/package.nls.zh-cn.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
"jdk.configuration.testEditor.description": "在编辑器中启用运行/调试测试",
5151
"jdk.configuration.javadoc.timeout.description": "在代码完成时加载 Javadoc 的超时(毫秒)(-1 表示无限制)",
5252
"jdk.configuration.formatterSettings.description": "包含导出的格式化工具设置的文件的路径",
53+
"jdk.configuration.formatterSettings.deprecationMessage": "This settings is about to deprecated use the jdk.format.settings instead",
54+
"jdk.configuration.formatOptions.description" : "Holder for the formatting options. For the list of valid keys and corresponding values see https://github.com/oracle/javavscode/wiki/Java-formatting-preferences",
5355
"jdk.configuration.hints.preferences.description": "包含导出的提示首选项的文件的路径",
5456
"jdk.configuration.organiseImports.description": "允许在保存文档时进行调整导入操作",
5557
"jdk.configuration.organiseImports.sortingOrder.description": "包含导入语句的组(由其程序包前缀指定)及其排序顺序。组中的导入语句按字母顺序排序",

0 commit comments

Comments
 (0)