From 2915c8897c4d1172dcadda68d5c347fe38e9e191 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Paku=C5=82a?= Date: Tue, 3 Oct 2023 21:05:30 +0200 Subject: [PATCH] Implement lsp4e configuration provider --- org.eclipse.wildwebdeveloper/plugin.xml | 28 ++++++++++++- .../jsts/JSTSLanguageServer.java | 37 ++--------------- .../javascript/JSTSConfigurationProvider.java | 40 +++++++++++++++++++ 3 files changed, 69 insertions(+), 36 deletions(-) create mode 100644 org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/javascript/JSTSConfigurationProvider.java diff --git a/org.eclipse.wildwebdeveloper/plugin.xml b/org.eclipse.wildwebdeveloper/plugin.xml index 810ef401ce..72d14b9623 100644 --- a/org.eclipse.wildwebdeveloper/plugin.xml +++ b/org.eclipse.wildwebdeveloper/plugin.xml @@ -550,14 +550,38 @@ priority="normal"> - + + + + + + + + + + + + + + + + + + + + + + + + label="JavaScript-TypeScript Language Server" + watchConfiguration="javascript,typescript"> commands = new ArrayList<>(); commands.add(NodeJSManager.getNodeJsLocation().getAbsolutePath()); try { @@ -99,24 +88,4 @@ public Object getInitializationOptions(URI rootUri) { return options; } - @Override - protected Object createSettings() { - Map settings = new HashMap<>(); - // javascript - settings.putAll(JavaScriptPreferenceServerConstants.getGlobalSettings()); - // typescript - settings.putAll(TypeScriptPreferenceServerConstants.getGlobalSettings()); - return settings; - } - - @Override - public void handleMessage(Message message, LanguageServer languageServer, URI rootUri) { - if (message instanceof ResponseMessage responseMessage) { - if (responseMessage.getResult() instanceof InitializeResult) { - // enable validation: so far, no better way found than changing conf after init. - DidChangeConfigurationParams params = new DidChangeConfigurationParams(createSettings()); - languageServer.getWorkspaceService().didChangeConfiguration(params); - } - } - } } diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/javascript/JSTSConfigurationProvider.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/javascript/JSTSConfigurationProvider.java new file mode 100644 index 0000000000..6d090dc29b --- /dev/null +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/javascript/JSTSConfigurationProvider.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2023 Dawid Pakuła and others. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Dawid Pakuła - initial implementation + *******************************************************************************/ +package org.eclipse.wildwebdeveloper.jsts.ui.preferences.javascript; + +import org.eclipse.lsp4e.configuration.EclipsePreferenceProvider; +import org.eclipse.wildwebdeveloper.Activator; +import org.eclipse.wildwebdeveloper.jsts.ui.preferences.typescript.TypeScriptPreferenceServerConstants; + +public class JSTSConfigurationProvider extends EclipsePreferenceProvider { + + public JSTSConfigurationProvider() { + super(Activator.PLUGIN_ID); + + addBool(JavaScriptPreferenceServerConstants.JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_ENUM_MEMBER_VALUE_HINTS); + addBool(JavaScriptPreferenceServerConstants.JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_FUNCTION_LIKE_RETURN_TYPE_HINTS); + addBool(JavaScriptPreferenceServerConstants.JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_FUNCTION_PARAMETER_TYPE_HINTS); + add(JavaScriptPreferenceServerConstants.JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS); + addBool(JavaScriptPreferenceServerConstants.JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS_WHEN_ARGUMENT_MATCHES_NAME); + addBool(JavaScriptPreferenceServerConstants.JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PROPERTY_DECLARATION_TYPE_HINTS); + addBool(JavaScriptPreferenceServerConstants.JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_VARIABLE_TYPE_HINTS_WHEN_TYPE_MATCHES_NAME); + + addBool(TypeScriptPreferenceServerConstants.TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_ENUM_MEMBER_VALUE_HINTS); + addBool(TypeScriptPreferenceServerConstants.TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_FUNCTION_LIKE_RETURN_TYPE_HINTS); + addBool(TypeScriptPreferenceServerConstants.TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_FUNCTION_PARAMETER_TYPE_HINTS); + add(TypeScriptPreferenceServerConstants.TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS); + addBool(TypeScriptPreferenceServerConstants.TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS_WHEN_ARGUMENT_MATCHES_NAME); + addBool(TypeScriptPreferenceServerConstants.TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PROPERTY_DECLARATION_TYPE_HINTS); + addBool(TypeScriptPreferenceServerConstants.TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_VARIABLE_TYPE_HINTS_WHEN_TYPE_MATCHES_NAME); + } + +}