Skip to content

Commit d72b592

Browse files
authored
Merge pull request #8111 from dbalek/dbalek/vscode-ext-formatter-settings-remove
VSCode: Removing option for external formatters.
2 parents b9ac871 + de61868 commit d72b592

File tree

4 files changed

+13
-47
lines changed

4 files changed

+13
-47
lines changed

java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/WorkspaceServiceImpl.java

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import java.util.LinkedHashSet;
4747
import java.util.LinkedList;
4848
import java.util.List;
49-
import java.util.Locale;
5049
import java.util.Map;
5150
import java.util.Map.Entry;
5251
import java.util.Objects;
@@ -125,7 +124,6 @@
125124
import org.netbeans.modules.java.lsp.server.Utils;
126125
import org.netbeans.modules.java.lsp.server.debugging.attach.AttachConfigurations;
127126
import org.netbeans.modules.java.lsp.server.debugging.attach.AttachNativeConfigurations;
128-
import org.netbeans.modules.java.lsp.server.progress.ModuleInfo;
129127
import org.netbeans.modules.java.lsp.server.project.LspProjectInfo;
130128
import org.netbeans.modules.java.lsp.server.singlesourcefile.SingleFileOptionsQueryImpl;
131129
import org.netbeans.modules.java.source.ElementHandleAccessor;
@@ -152,7 +150,6 @@
152150
import org.openide.util.Exceptions;
153151
import org.openide.util.Lookup;
154152
import org.openide.util.NbBundle;
155-
import org.openide.util.NbPreferences;
156153
import org.openide.util.Pair;
157154
import org.openide.util.RequestProcessor;
158155
import org.openide.util.WeakListeners;
@@ -1412,32 +1409,18 @@ public void didChangeConfiguration(DidChangeConfigurationParams params) {
14121409

14131410
void updateJavaFormatPreferences(FileObject fo, JsonObject configuration) {
14141411
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();
14401421
}
1422+
} catch (IOException ex) {
1423+
Exceptions.printStackTrace(ex);
14411424
}
14421425
}
14431426
}

java/java.lsp.server/vscode/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ When adding JavaDoc to code NetBeans assists by suggesting to insert preformatte
149149
![JavaDoc Completion](images/javadoc.png)
150150

151151
## Source Code formatting
152-
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.
153-
![Source Code formatter](images/SourceCodeFormatter.png)
152+
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.
153+
154154
## Test Explorer
155155
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.
156156
![Test Explorer](images/Test_explorer.png)
-24 KB
Binary file not shown.

java/java.lsp.server/vscode/package.json

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -192,23 +192,6 @@
192192
"default": 10000,
193193
"description": "When code completion takes longer than this specified time (in milliseconds), there will be a warning produced (-1 to disable)"
194194
},
195-
"netbeans.format.codeFormatter": {
196-
"type": "string",
197-
"enum": [
198-
"NetBeans",
199-
"Eclipse",
200-
"Google",
201-
"Spring"
202-
],
203-
"enumDescriptions": [
204-
"Internal NetBeans Code Formatter",
205-
"Eclipse Code Formatter",
206-
"Goolge Code Formatter",
207-
"Spring Code Formatter"
208-
],
209-
"description": "Code formatter to use",
210-
"default": "NetBeans"
211-
},
212195
"netbeans.format.settingsPath": {
213196
"type": "string",
214197
"description": "Path to the file containing exported formatter settings",

0 commit comments

Comments
 (0)