Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSCode: Removing option for external formatters. #8111

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions java/java.lsp.server/vscode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Binary file not shown.
17 changes: 0 additions & 17 deletions java/java.lsp.server/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading