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 index c9650cad89e4..eaff1013cdf0 100644 --- 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 @@ -46,7 +46,6 @@ import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; -import java.util.Locale; import java.util.Map; import java.util.Map.Entry; import java.util.Objects; @@ -125,7 +124,6 @@ import org.netbeans.modules.java.lsp.server.Utils; import org.netbeans.modules.java.lsp.server.debugging.attach.AttachConfigurations; import org.netbeans.modules.java.lsp.server.debugging.attach.AttachNativeConfigurations; -import org.netbeans.modules.java.lsp.server.progress.ModuleInfo; import org.netbeans.modules.java.lsp.server.project.LspProjectInfo; import org.netbeans.modules.java.lsp.server.singlesourcefile.SingleFileOptionsQueryImpl; import org.netbeans.modules.java.source.ElementHandleAccessor; @@ -152,7 +150,6 @@ import org.openide.util.Exceptions; import org.openide.util.Lookup; import org.openide.util.NbBundle; -import org.openide.util.NbPreferences; import org.openide.util.Pair; import org.openide.util.RequestProcessor; import org.openide.util.WeakListeners; @@ -1412,32 +1409,18 @@ public void didChangeConfiguration(DidChangeConfigurationParams params) { void updateJavaFormatPreferences(FileObject fo, JsonObject configuration) { if (configuration != null && client.getNbCodeCapabilities().wantsJavaSupport()) { - NbPreferences.Provider provider = Lookup.getDefault().lookup(NbPreferences.Provider.class); - Preferences prefs = provider != null ? provider.preferencesRoot().node("de/funfried/netbeans/plugins/externalcodeformatter") : null; - JsonPrimitive formatterPrimitive = configuration.getAsJsonPrimitive("codeFormatter"); - String formatter = formatterPrimitive != null ? formatterPrimitive.getAsString() : null; - JsonPrimitive pathPrimitive = configuration.getAsJsonPrimitive("settingsPath"); - String path = pathPrimitive != null ? pathPrimitive.getAsString() : null; - if (formatter == null || "NetBeans".equals(formatter)) { - if (prefs != null) { - prefs.put("enabledFormatter.JAVA", "netbeans-formatter"); - } - Path p = path != null ? Paths.get(path) : null; - File file = p != null ? p.toFile() : null; - try { - if (file != null && file.exists() && file.canRead() && file.getName().endsWith(".zip")) { - OptionsExportModel.get().doImport(file); - } else { - OptionsExportModel.get().clean(); - } - } catch (IOException ex) { - Exceptions.printStackTrace(ex); - } - } else if (prefs != null) { - prefs.put("enabledFormatter.JAVA", formatter.toLowerCase(Locale.ENGLISH).concat("-java-formatter")); - if (path != null) { - prefs.put(formatter.toLowerCase(Locale.ENGLISH).concat("FormatterLocation"), path); + JsonElement pathElement = configuration.get("settingsPath"); + String path = pathElement != null && pathElement.isJsonPrimitive() ? pathElement.getAsString() : null; + Path p = path != null ? Paths.get(path) : null; + File file = p != null ? p.toFile() : null; + try { + if (file != null && file.exists() && file.canRead() && file.getName().endsWith(".zip")) { + OptionsExportModel.get().doImport(file); + } else { + OptionsExportModel.get().clean(); } + } catch (IOException ex) { + Exceptions.printStackTrace(ex); } } } diff --git a/java/java.lsp.server/vscode/README.md b/java/java.lsp.server/vscode/README.md index 5286c9ed07c7..fac71de045b6 100644 --- a/java/java.lsp.server/vscode/README.md +++ b/java/java.lsp.server/vscode/README.md @@ -149,8 +149,8 @@ When adding JavaDoc to code NetBeans assists by suggesting to insert preformatte ![JavaDoc Completion](images/javadoc.png) ## Source Code formatting -Formatting source code is possible using also other styles than NetBeans. Eclipse, Google and Spring formatters can be used. For Eclipse formatter simply export settings from Eclipse IDE into standard file and then set `Netbeans > Format: Settings Path:` in VSCode Settings. -![Source Code formatter](images/SourceCodeFormatter.png) +Formatting source code is possible using the NetBeans code style. For using non default formatter options, simply export desired settings from NetBeans IDE into standard file and then set `Netbeans > Format: Settings Path:` in VSCode Settings. + ## Test Explorer NetBeans Language Server provides Test Explorer view which allows to run all tests in a project, examine the results, go to source code and run particular test. ![Test Explorer](images/Test_explorer.png) diff --git a/java/java.lsp.server/vscode/images/SourceCodeFormatter.png b/java/java.lsp.server/vscode/images/SourceCodeFormatter.png deleted file mode 100644 index af4e0d1c5773..000000000000 Binary files a/java/java.lsp.server/vscode/images/SourceCodeFormatter.png and /dev/null differ diff --git a/java/java.lsp.server/vscode/package.json b/java/java.lsp.server/vscode/package.json index abf47e931061..d9fda9662eea 100644 --- a/java/java.lsp.server/vscode/package.json +++ b/java/java.lsp.server/vscode/package.json @@ -192,23 +192,6 @@ "default": 10000, "description": "When code completion takes longer than this specified time (in milliseconds), there will be a warning produced (-1 to disable)" }, - "netbeans.format.codeFormatter": { - "type": "string", - "enum": [ - "NetBeans", - "Eclipse", - "Google", - "Spring" - ], - "enumDescriptions": [ - "Internal NetBeans Code Formatter", - "Eclipse Code Formatter", - "Goolge Code Formatter", - "Spring Code Formatter" - ], - "description": "Code formatter to use", - "default": "NetBeans" - }, "netbeans.format.settingsPath": { "type": "string", "description": "Path to the file containing exported formatter settings",