|
46 | 46 | import java.util.LinkedHashSet; |
47 | 47 | import java.util.LinkedList; |
48 | 48 | import java.util.List; |
49 | | -import java.util.Locale; |
50 | 49 | import java.util.Map; |
51 | 50 | import java.util.Map.Entry; |
52 | 51 | import java.util.Objects; |
|
125 | 124 | import org.netbeans.modules.java.lsp.server.Utils; |
126 | 125 | import org.netbeans.modules.java.lsp.server.debugging.attach.AttachConfigurations; |
127 | 126 | import org.netbeans.modules.java.lsp.server.debugging.attach.AttachNativeConfigurations; |
128 | | -import org.netbeans.modules.java.lsp.server.progress.ModuleInfo; |
129 | 127 | import org.netbeans.modules.java.lsp.server.project.LspProjectInfo; |
130 | 128 | import org.netbeans.modules.java.lsp.server.singlesourcefile.SingleFileOptionsQueryImpl; |
131 | 129 | import org.netbeans.modules.java.source.ElementHandleAccessor; |
|
152 | 150 | import org.openide.util.Exceptions; |
153 | 151 | import org.openide.util.Lookup; |
154 | 152 | import org.openide.util.NbBundle; |
155 | | -import org.openide.util.NbPreferences; |
156 | 153 | import org.openide.util.Pair; |
157 | 154 | import org.openide.util.RequestProcessor; |
158 | 155 | import org.openide.util.WeakListeners; |
@@ -1412,32 +1409,18 @@ public void didChangeConfiguration(DidChangeConfigurationParams params) { |
1412 | 1409 |
|
1413 | 1410 | void updateJavaFormatPreferences(FileObject fo, JsonObject configuration) { |
1414 | 1411 | if (configuration != null && client.getNbCodeCapabilities().wantsJavaSupport()) { |
1415 | | - NbPreferences.Provider provider = Lookup.getDefault().lookup(NbPreferences.Provider.class); |
1416 | | - Preferences prefs = provider != null ? provider.preferencesRoot().node("de/funfried/netbeans/plugins/externalcodeformatter") : null; |
1417 | | - JsonPrimitive formatterPrimitive = configuration.getAsJsonPrimitive("codeFormatter"); |
1418 | | - String formatter = formatterPrimitive != null ? formatterPrimitive.getAsString() : null; |
1419 | | - JsonPrimitive pathPrimitive = configuration.getAsJsonPrimitive("settingsPath"); |
1420 | | - String path = pathPrimitive != null ? pathPrimitive.getAsString() : null; |
1421 | | - if (formatter == null || "NetBeans".equals(formatter)) { |
1422 | | - if (prefs != null) { |
1423 | | - prefs.put("enabledFormatter.JAVA", "netbeans-formatter"); |
1424 | | - } |
1425 | | - Path p = path != null ? Paths.get(path) : null; |
1426 | | - File file = p != null ? p.toFile() : null; |
1427 | | - try { |
1428 | | - if (file != null && file.exists() && file.canRead() && file.getName().endsWith(".zip")) { |
1429 | | - OptionsExportModel.get().doImport(file); |
1430 | | - } else { |
1431 | | - OptionsExportModel.get().clean(); |
1432 | | - } |
1433 | | - } catch (IOException ex) { |
1434 | | - Exceptions.printStackTrace(ex); |
1435 | | - } |
1436 | | - } else if (prefs != null) { |
1437 | | - prefs.put("enabledFormatter.JAVA", formatter.toLowerCase(Locale.ENGLISH).concat("-java-formatter")); |
1438 | | - if (path != null) { |
1439 | | - prefs.put(formatter.toLowerCase(Locale.ENGLISH).concat("FormatterLocation"), path); |
| 1412 | + JsonElement pathElement = configuration.get("settingsPath"); |
| 1413 | + String path = pathElement != null && pathElement.isJsonPrimitive() ? pathElement.getAsString() : null; |
| 1414 | + Path p = path != null ? Paths.get(path) : null; |
| 1415 | + File file = p != null ? p.toFile() : null; |
| 1416 | + try { |
| 1417 | + if (file != null && file.exists() && file.canRead() && file.getName().endsWith(".zip")) { |
| 1418 | + OptionsExportModel.get().doImport(file); |
| 1419 | + } else { |
| 1420 | + OptionsExportModel.get().clean(); |
1440 | 1421 | } |
| 1422 | + } catch (IOException ex) { |
| 1423 | + Exceptions.printStackTrace(ex); |
1441 | 1424 | } |
1442 | 1425 | } |
1443 | 1426 | } |
|
0 commit comments