From cd46281ff136b9d355b6b900fc17c6ee0a640d89 Mon Sep 17 00:00:00 2001 From: azerr Date: Mon, 14 Nov 2022 06:11:26 +0100 Subject: [PATCH] Inlay Hint preferences for JS/TS --- RELEASE_NOTES.md | 1 + .../plugin.properties | 7 ++ org.eclipse.wildwebdeveloper/plugin.xml | 60 ++++++++++++- .../jsts/JSTSLanguageServer.java | 53 +++++++++-- .../wildwebdeveloper/jsts/ui/Messages.java | 39 ++++++++ .../jsts/ui/messages.properties | 25 ++++++ .../ui/preferences/JSTSPreferencePage.java | 38 ++++++++ .../JavaScriptInlayHintPreferencePage.java | 88 ++++++++++++++++++ .../JavaScriptPreferenceInitializer.java | 27 ++++++ .../javascript/JavaScriptPreferencePage.java | 38 ++++++++ .../JavaScriptPreferenceServerConstants.java | 89 +++++++++++++++++++ .../TypeScriptInlayHintPreferencePage.java | 89 +++++++++++++++++++ .../TypeScriptPreferenceInitializer.java | 27 ++++++ .../typescript/TypeScriptPreferencePage.java | 38 ++++++++ .../TypeScriptPreferenceServerConstants.java | 89 +++++++++++++++++++ .../IndentedBooleanFieldEditor.java | 46 ++++++++++ 16 files changed, 744 insertions(+), 10 deletions(-) create mode 100644 org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/Messages.java create mode 100644 org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/messages.properties create mode 100644 org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/JSTSPreferencePage.java create mode 100644 org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/javascript/JavaScriptInlayHintPreferencePage.java create mode 100644 org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/javascript/JavaScriptPreferenceInitializer.java create mode 100644 org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/javascript/JavaScriptPreferencePage.java create mode 100644 org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/javascript/JavaScriptPreferenceServerConstants.java create mode 100644 org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/typescript/TypeScriptInlayHintPreferencePage.java create mode 100644 org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/typescript/TypeScriptPreferenceInitializer.java create mode 100644 org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/typescript/TypeScriptPreferencePage.java create mode 100644 org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/typescript/TypeScriptPreferenceServerConstants.java create mode 100644 org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/ui/preferences/IndentedBooleanFieldEditor.java diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 08b4d8e019..34bf1db5da 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -6,6 +6,7 @@ This page describes the noteworthy improvements provided by each release of Ecli #### Editing improvements * Bind schema/grammar (XSD, DTD, RelaxNG) with codelens in XML file + * UI preferences for TypeScript/ Javascript Inlay Hints ## 1.0.0 diff --git a/org.eclipse.wildwebdeveloper/plugin.properties b/org.eclipse.wildwebdeveloper/plugin.properties index 99ae0c1fbb..6025ef1aae 100644 --- a/org.eclipse.wildwebdeveloper/plugin.properties +++ b/org.eclipse.wildwebdeveloper/plugin.properties @@ -38,6 +38,13 @@ HTMLFormatPreferencePage.name=Format HTMLHoverPreferencePage.name=Hover HTMLValidationPreferencePage.name=Validation +# JST/TS +JSTSPreferencePage.name=JS/TS (Wild Web Developer) +TypeScriptPreferencePage.name=TypeScript +TypeScriptInlayHintPreferencePage.name=Inlay Hint +JavaScriptPreferencePage.name=JavaScript +JavaScriptInlayHintPreferencePage.name=Inlay Hint + # YAML YAMLPreferencePage.name=YAML (Wild Web Developer) YAMLCompletionPreferencePage.name=Completion diff --git a/org.eclipse.wildwebdeveloper/plugin.xml b/org.eclipse.wildwebdeveloper/plugin.xml index 7ff988c3ed..9f2c6be812 100644 --- a/org.eclipse.wildwebdeveloper/plugin.xml +++ b/org.eclipse.wildwebdeveloper/plugin.xml @@ -535,18 +535,22 @@ label="JavaScript-TypeScript Language Server"> @@ -612,8 +616,7 @@ path="language-configurations/typescript/language-configuration.jsonc"> - - + + + + + + + + + + + + + + + + + + + + + + + + + + commands = new ArrayList<>(); commands.add(NodeJSManager.getNodeJsLocation().getAbsolutePath()); try { - URL url = FileLocator.toFileURL(getClass().getResource("/node_modules/typescript-language-server/lib/cli.js")); + URL url = FileLocator + .toFileURL(getClass().getResource("/node_modules/typescript-language-server/lib/cli.js")); commands.add(new File(url.getPath()).getAbsolutePath()); commands.add("--stdio"); URL nodeDependencies = FileLocator.toFileURL(getClass().getResource("/")); setCommands(commands); - setWorkingDirectory(nodeDependencies.getPath()); //Required for typescript-eslint-language-service to find it's dependencies + setWorkingDirectory(nodeDependencies.getPath()); // Required for typescript-eslint-language-service to find + // it's dependencies } catch (IOException e) { - Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), e.getMessage(), e)); + Activator.getDefault().getLog().log( + new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), e.getMessage(), e)); } } - + @Override public Object getInitializationOptions(URI rootUri) { Map options = new HashMap<>(); + // plugins List plugins = new ArrayList<>(); try { // plugins.add(new TypeScriptPlugin("@angular/language-service")); @@ -57,9 +73,30 @@ public Object getInitializationOptions(URI rootUri) { plugins.add(new TypeScriptPlugin("typescript-lit-html-plugin")); options.put("plugins", plugins.stream().map(TypeScriptPlugin::toMap).toArray()); } catch (IOException e) { - Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), e.getMessage(), e)); + Activator.getDefault().getLog().log( + new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), e.getMessage(), e)); } 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/Messages.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/Messages.java new file mode 100644 index 0000000000..57b7f226e5 --- /dev/null +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/Messages.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2022 Red Hat Inc. 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: + * Angelo ZERR (Red Hat Inc.) - initial implementation + *******************************************************************************/ +package org.eclipse.wildwebdeveloper.jsts.ui; + +import org.eclipse.osgi.util.NLS; + +/** + * JS/TS messages keys. + * + */ +public class Messages extends NLS { + + // --------- TypeScript Inlay Hints preference page + public static String TypeScriptInlayHintPreferencePage_showInlayHintsFor_label; + public static String TypeScriptInlayHintPreferencePage_includeInlayEnumMemberValueHints; + public static String TypeScriptInlayHintPreferencePage_includeInlayFunctionLikeReturnTypeHints; + public static String TypeScriptInlayHintPreferencePage_includeInlayFunctionParameterTypeHints; + public static String TypeScriptInlayHintPreferencePage_includeInlayParameterNameHints; + public static String TypeScriptInlayHintPreferencePage_includeInlayParameterNameHints_none; + public static String TypeScriptInlayHintPreferencePage_includeInlayParameterNameHints_literals; + public static String TypeScriptInlayHintPreferencePage_includeInlayParameterNameHints_all; + public static String TypeScriptInlayHintPreferencePage_includeInlayParameterNameHintsWhenArgumentMatchesName; + public static String TypeScriptInlayHintPreferencePage_includeInlayPropertyDeclarationTypeHints; + public static String TypeScriptInlayHintPreferencePage_includeInlayVariableTypeHints; + public static String TypeScriptInlayHintPreferencePage_includeInlayVariableTypeHintsWhenTypeMatchesName; + + static { + NLS.initializeMessages("org.eclipse.wildwebdeveloper.jsts.ui.messages", Messages.class); //$NON-NLS-1$ + } +} diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/messages.properties b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/messages.properties new file mode 100644 index 0000000000..d2701ea075 --- /dev/null +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/messages.properties @@ -0,0 +1,25 @@ +#/******************************************************************************* +# * Copyright (c) 2022 Red Hat Inc. 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: +# * Angelo ZERR (Red Hat Inc.) - initial implementation +# *******************************************************************************/ + +# TypeScript Inlay Hints preference page +TypeScriptInlayHintPreferencePage_showInlayHintsFor_label=Show inlay hints for: +TypeScriptInlayHintPreferencePage_includeInlayEnumMemberValueHints=member values in enum declarations. +TypeScriptInlayHintPreferencePage_includeInlayFunctionLikeReturnTypeHints=implicit return types on function signatures. +TypeScriptInlayHintPreferencePage_includeInlayFunctionParameterTypeHints=function parameter type. +TypeScriptInlayHintPreferencePage_includeInlayPropertyDeclarationTypeHints=property declaration type. +TypeScriptInlayHintPreferencePage_includeInlayParameterNameHints=parameter names: +TypeScriptInlayHintPreferencePage_includeInlayParameterNameHints_none=Disable parameter name hints. +TypeScriptInlayHintPreferencePage_includeInlayParameterNameHints_literals=Only for literal arguments. +TypeScriptInlayHintPreferencePage_includeInlayParameterNameHints_all=For literal and non-literal arguments. +TypeScriptInlayHintPreferencePage_includeInlayParameterNameHintsWhenArgumentMatchesName=also on arguments whose text is identical to the parameter name. +TypeScriptInlayHintPreferencePage_includeInlayVariableTypeHints=variable type. +TypeScriptInlayHintPreferencePage_includeInlayVariableTypeHintsWhenTypeMatchesName=also variables whose name is identical to the type name. \ No newline at end of file diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/JSTSPreferencePage.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/JSTSPreferencePage.java new file mode 100644 index 0000000000..47bc0b2d39 --- /dev/null +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/JSTSPreferencePage.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2022 Red Hat Inc. 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: + * Angelo ZERR (Red Hat Inc.) - initial implementation + *******************************************************************************/ +package org.eclipse.wildwebdeveloper.jsts.ui.preferences; + +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.wildwebdeveloper.Activator; + +/** + * JS/TS main preference page. + * + */ +public class JSTSPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { + + public JSTSPreferencePage() { + super(GRID); + } + + @Override + public void init(IWorkbench workbench) { + setPreferenceStore(Activator.getDefault().getPreferenceStore()); + } + + @Override + protected void createFieldEditors() { + } +} \ No newline at end of file diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/javascript/JavaScriptInlayHintPreferencePage.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/javascript/JavaScriptInlayHintPreferencePage.java new file mode 100644 index 0000000000..2c216c6388 --- /dev/null +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/javascript/JavaScriptInlayHintPreferencePage.java @@ -0,0 +1,88 @@ +/******************************************************************************* + * Copyright (c) 2022 Red Hat Inc. 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: + * Angelo ZERR (Red Hat Inc.) - initial implementation + *******************************************************************************/ +package org.eclipse.wildwebdeveloper.jsts.ui.preferences.javascript; + +import static org.eclipse.wildwebdeveloper.jsts.ui.preferences.javascript.JavaScriptPreferenceServerConstants.JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_ENUM_MEMBER_VALUE_HINTS; +import static org.eclipse.wildwebdeveloper.jsts.ui.preferences.javascript.JavaScriptPreferenceServerConstants.JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_FUNCTION_LIKE_RETURN_TYPE_HINTS; +import static org.eclipse.wildwebdeveloper.jsts.ui.preferences.javascript.JavaScriptPreferenceServerConstants.JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_FUNCTION_PARAMETER_TYPE_HINTS; +import static org.eclipse.wildwebdeveloper.jsts.ui.preferences.javascript.JavaScriptPreferenceServerConstants.JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS; +import static org.eclipse.wildwebdeveloper.jsts.ui.preferences.javascript.JavaScriptPreferenceServerConstants.JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS_WHEN_ARGUMENT_MATCHES_NAME; +import static org.eclipse.wildwebdeveloper.jsts.ui.preferences.javascript.JavaScriptPreferenceServerConstants.JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PROPERTY_DECLARATION_TYPE_HINTS; +import static org.eclipse.wildwebdeveloper.jsts.ui.preferences.javascript.JavaScriptPreferenceServerConstants.JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_VARIABLE_TYPE_HINTS; +import static org.eclipse.wildwebdeveloper.jsts.ui.preferences.javascript.JavaScriptPreferenceServerConstants.JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_VARIABLE_TYPE_HINTS_WHEN_TYPE_MATCHES_NAME; + +import org.eclipse.jface.preference.BooleanFieldEditor; +import org.eclipse.jface.preference.ComboFieldEditor; +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.wildwebdeveloper.Activator; +import org.eclipse.wildwebdeveloper.jsts.ui.Messages; +import org.eclipse.wildwebdeveloper.ui.preferences.IndentedBooleanFieldEditor; + +/** + * JavaScript Inlay Hint preference page. + * + */ +public class JavaScriptInlayHintPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { + + public JavaScriptInlayHintPreferencePage() { + super(GRID); + } + + @Override + public void createFieldEditors() { + Composite parent = getFieldEditorParent(); + Label label = new Label(parent, SWT.NONE); + label.setText(Messages.TypeScriptInlayHintPreferencePage_showInlayHintsFor_label); + + addField(new BooleanFieldEditor(JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_ENUM_MEMBER_VALUE_HINTS, + Messages.TypeScriptInlayHintPreferencePage_includeInlayEnumMemberValueHints, parent)); + addField( + new BooleanFieldEditor(JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_FUNCTION_LIKE_RETURN_TYPE_HINTS, + Messages.TypeScriptInlayHintPreferencePage_includeInlayFunctionLikeReturnTypeHints, parent)); + addField(new BooleanFieldEditor(JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_FUNCTION_PARAMETER_TYPE_HINTS, + Messages.TypeScriptInlayHintPreferencePage_includeInlayFunctionParameterTypeHints, parent)); + addField( + new BooleanFieldEditor(JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PROPERTY_DECLARATION_TYPE_HINTS, + Messages.TypeScriptInlayHintPreferencePage_includeInlayPropertyDeclarationTypeHints, parent)); + + addField(new BooleanFieldEditor(JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_VARIABLE_TYPE_HINTS, + Messages.TypeScriptInlayHintPreferencePage_includeInlayVariableTypeHints, parent)); + addField(new IndentedBooleanFieldEditor( + JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_VARIABLE_TYPE_HINTS_WHEN_TYPE_MATCHES_NAME, + Messages.TypeScriptInlayHintPreferencePage_includeInlayVariableTypeHintsWhenTypeMatchesName, parent)); + + addField(new ComboFieldEditor(JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS, + Messages.TypeScriptInlayHintPreferencePage_includeInlayParameterNameHints, + new String[][] { + { Messages.TypeScriptInlayHintPreferencePage_includeInlayParameterNameHints_none, "none" }, + { Messages.TypeScriptInlayHintPreferencePage_includeInlayParameterNameHints_literals, + "literals" }, + { Messages.TypeScriptInlayHintPreferencePage_includeInlayParameterNameHints_all, "all" } }, + parent)); + addField(new IndentedBooleanFieldEditor( + JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS_WHEN_ARGUMENT_MATCHES_NAME, + Messages.TypeScriptInlayHintPreferencePage_includeInlayParameterNameHintsWhenArgumentMatchesName, + parent)); + } + + + @Override + public void init(IWorkbench workbench) { + setPreferenceStore(Activator.getDefault().getPreferenceStore()); + } +} diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/javascript/JavaScriptPreferenceInitializer.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/javascript/JavaScriptPreferenceInitializer.java new file mode 100644 index 0000000000..d8b052d02d --- /dev/null +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/javascript/JavaScriptPreferenceInitializer.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2022 Red Hat Inc. 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: + * Angelo ZERR (Red Hat Inc.) - initial implementation + *******************************************************************************/ +package org.eclipse.wildwebdeveloper.jsts.ui.preferences.javascript; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; + +/** + * JavaScript preference initializer. + * + */ +public class JavaScriptPreferenceInitializer extends AbstractPreferenceInitializer { + + @Override + public void initializeDefaultPreferences() { + JavaScriptPreferenceServerConstants.initializeDefaultPreferences(); + } + +} \ No newline at end of file diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/javascript/JavaScriptPreferencePage.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/javascript/JavaScriptPreferencePage.java new file mode 100644 index 0000000000..c25548ab3f --- /dev/null +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/javascript/JavaScriptPreferencePage.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2022 Red Hat Inc. 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: + * Angelo ZERR (Red Hat Inc.) - initial implementation + *******************************************************************************/ +package org.eclipse.wildwebdeveloper.jsts.ui.preferences.javascript; + +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.wildwebdeveloper.Activator; + +/** + * JavaScript main preference page. + * + */ +public class JavaScriptPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { + + public JavaScriptPreferencePage() { + super(GRID); + } + + @Override + public void init(IWorkbench workbench) { + setPreferenceStore(Activator.getDefault().getPreferenceStore()); + } + + @Override + protected void createFieldEditors() { + } +} \ No newline at end of file diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/javascript/JavaScriptPreferenceServerConstants.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/javascript/JavaScriptPreferenceServerConstants.java new file mode 100644 index 0000000000..1ab70e2301 --- /dev/null +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/javascript/JavaScriptPreferenceServerConstants.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (c) 2022 Red Hat Inc. 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: + * Angelo ZERR (Red Hat Inc.) - initial implementation + *******************************************************************************/ +package org.eclipse.wildwebdeveloper.jsts.ui.preferences.javascript; + +import static org.eclipse.wildwebdeveloper.ui.preferences.Settings.isMatchSection; + +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.wildwebdeveloper.Activator; +import org.eclipse.wildwebdeveloper.ui.preferences.Settings; + +/** + * TypeScript preference server constants. + * + */ +public class JavaScriptPreferenceServerConstants { + + public static final String JAVASCRIPT_SECTION = "javascript"; + + // Inlay Hint settings + public static final String JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_ENUM_MEMBER_VALUE_HINTS = "javascript.inlayHints.includeInlayEnumMemberValueHints"; + public static final String JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_FUNCTION_LIKE_RETURN_TYPE_HINTS = "javascript.inlayHints.includeInlayFunctionLikeReturnTypeHints"; + public static final String JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_FUNCTION_PARAMETER_TYPE_HINTS = "javascript.inlayHints.includeInlayFunctionParameterTypeHints"; + public static final String JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS = "javascript.inlayHints.includeInlayParameterNameHints"; + public static final String JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS_WHEN_ARGUMENT_MATCHES_NAME = "javascript.inlayHints.includeInlayParameterNameHintsWhenArgumentMatchesName"; + public static final String JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PROPERTY_DECLARATION_TYPE_HINTS = "javascript.inlayHints.includeInlayPropertyDeclarationTypeHints"; + public static final String JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_VARIABLE_TYPE_HINTS = "javascript.inlayHints.includeInlayVariableTypeHints"; + public static final String JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_VARIABLE_TYPE_HINTS_WHEN_TYPE_MATCHES_NAME = "javascript.inlayHints.includeInlayVariableTypeHintsWhenTypeMatchesName"; + + public static Settings getGlobalSettings() { + Settings settings = new Settings(Activator.getDefault().getPreferenceStore()); + + // Inlay Hint settings + settings.fillAsBoolean(JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_ENUM_MEMBER_VALUE_HINTS); + settings.fillAsBoolean(JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_FUNCTION_LIKE_RETURN_TYPE_HINTS); + settings.fillAsBoolean(JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_FUNCTION_PARAMETER_TYPE_HINTS); + settings.fillAsString(JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS); + settings.fillAsBoolean( + JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS_WHEN_ARGUMENT_MATCHES_NAME); + settings.fillAsBoolean(JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PROPERTY_DECLARATION_TYPE_HINTS); + settings.fillAsBoolean(JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_VARIABLE_TYPE_HINTS); + settings.fillAsBoolean( + JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_VARIABLE_TYPE_HINTS_WHEN_TYPE_MATCHES_NAME); + return settings; + } + + public static void initializeDefaultPreferences() { + IPreferenceStore store = Activator.getDefault().getPreferenceStore(); + + // Server settings + + // - Inlay Hint + store.setDefault(JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS, false); + store.setDefault(JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_FUNCTION_LIKE_RETURN_TYPE_HINTS, false); + store.setDefault(JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_FUNCTION_PARAMETER_TYPE_HINTS, false); + store.setDefault(JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS, "none"); // 'none' | + // 'literals' + // | 'all' + store.setDefault( + JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS_WHEN_ARGUMENT_MATCHES_NAME, + false); + store.setDefault(JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PROPERTY_DECLARATION_TYPE_HINTS, false); + store.setDefault(JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_VARIABLE_TYPE_HINTS, false); + store.setDefault(JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_VARIABLE_TYPE_HINTS_WHEN_TYPE_MATCHES_NAME, + false); + } + + /** + * Returns true if the given section matches JavaScript settings and false + * otherwise. + * + * @param section the section to check. + * + * @return true if the given section matches JavaScript settings and false + * otherwise. + */ + public static boolean isMatchTypeScriptSection(String section) { + return isMatchSection(section, JAVASCRIPT_SECTION); + } +} diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/typescript/TypeScriptInlayHintPreferencePage.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/typescript/TypeScriptInlayHintPreferencePage.java new file mode 100644 index 0000000000..a31551213d --- /dev/null +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/typescript/TypeScriptInlayHintPreferencePage.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (c) 2022 Red Hat Inc. 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: + * Angelo ZERR (Red Hat Inc.) - initial implementation + *******************************************************************************/ +package org.eclipse.wildwebdeveloper.jsts.ui.preferences.typescript; + +import static org.eclipse.wildwebdeveloper.jsts.ui.preferences.typescript.TypeScriptPreferenceServerConstants.TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_ENUM_MEMBER_VALUE_HINTS; +import static org.eclipse.wildwebdeveloper.jsts.ui.preferences.typescript.TypeScriptPreferenceServerConstants.TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_FUNCTION_LIKE_RETURN_TYPE_HINTS; +import static org.eclipse.wildwebdeveloper.jsts.ui.preferences.typescript.TypeScriptPreferenceServerConstants.TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_FUNCTION_PARAMETER_TYPE_HINTS; +import static org.eclipse.wildwebdeveloper.jsts.ui.preferences.typescript.TypeScriptPreferenceServerConstants.TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS; +import static org.eclipse.wildwebdeveloper.jsts.ui.preferences.typescript.TypeScriptPreferenceServerConstants.TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS_WHEN_ARGUMENT_MATCHES_NAME; +import static org.eclipse.wildwebdeveloper.jsts.ui.preferences.typescript.TypeScriptPreferenceServerConstants.TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PROPERTY_DECLARATION_TYPE_HINTS; +import static org.eclipse.wildwebdeveloper.jsts.ui.preferences.typescript.TypeScriptPreferenceServerConstants.TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_VARIABLE_TYPE_HINTS; +import static org.eclipse.wildwebdeveloper.jsts.ui.preferences.typescript.TypeScriptPreferenceServerConstants.TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_VARIABLE_TYPE_HINTS_WHEN_TYPE_MATCHES_NAME; + +import org.eclipse.jface.preference.BooleanFieldEditor; +import org.eclipse.jface.preference.ComboFieldEditor; +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.wildwebdeveloper.Activator; +import org.eclipse.wildwebdeveloper.jsts.ui.Messages; +import org.eclipse.wildwebdeveloper.ui.preferences.IndentedBooleanFieldEditor; + +/** + * TypeScript Inlay Hint preference page. + * + */ +public class TypeScriptInlayHintPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { + + private int INDENT = 20; + + public TypeScriptInlayHintPreferencePage() { + super(GRID); + } + + @Override + public void createFieldEditors() { + Composite parent = getFieldEditorParent(); + Label label = new Label(parent, SWT.NONE); + label.setText(Messages.TypeScriptInlayHintPreferencePage_showInlayHintsFor_label); + + addField(new BooleanFieldEditor(TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_ENUM_MEMBER_VALUE_HINTS, + Messages.TypeScriptInlayHintPreferencePage_includeInlayEnumMemberValueHints, parent)); + addField( + new BooleanFieldEditor(TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_FUNCTION_LIKE_RETURN_TYPE_HINTS, + Messages.TypeScriptInlayHintPreferencePage_includeInlayFunctionLikeReturnTypeHints, parent)); + addField(new BooleanFieldEditor(TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_FUNCTION_PARAMETER_TYPE_HINTS, + Messages.TypeScriptInlayHintPreferencePage_includeInlayFunctionParameterTypeHints, parent)); + addField( + new BooleanFieldEditor(TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PROPERTY_DECLARATION_TYPE_HINTS, + Messages.TypeScriptInlayHintPreferencePage_includeInlayPropertyDeclarationTypeHints, parent)); + + addField(new BooleanFieldEditor(TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_VARIABLE_TYPE_HINTS, + Messages.TypeScriptInlayHintPreferencePage_includeInlayVariableTypeHints, parent)); + addField(new IndentedBooleanFieldEditor( + TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_VARIABLE_TYPE_HINTS_WHEN_TYPE_MATCHES_NAME, + Messages.TypeScriptInlayHintPreferencePage_includeInlayVariableTypeHintsWhenTypeMatchesName, parent)); + + addField(new ComboFieldEditor(TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS, + Messages.TypeScriptInlayHintPreferencePage_includeInlayParameterNameHints, + new String[][] { + { Messages.TypeScriptInlayHintPreferencePage_includeInlayParameterNameHints_none, "none" }, + { Messages.TypeScriptInlayHintPreferencePage_includeInlayParameterNameHints_literals, + "literals" }, + { Messages.TypeScriptInlayHintPreferencePage_includeInlayParameterNameHints_all, "all" } }, + parent)); + addField(new IndentedBooleanFieldEditor( + TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS_WHEN_ARGUMENT_MATCHES_NAME, + Messages.TypeScriptInlayHintPreferencePage_includeInlayParameterNameHintsWhenArgumentMatchesName, + parent)); + } + + @Override + public void init(IWorkbench workbench) { + setPreferenceStore(Activator.getDefault().getPreferenceStore()); + } +} diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/typescript/TypeScriptPreferenceInitializer.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/typescript/TypeScriptPreferenceInitializer.java new file mode 100644 index 0000000000..11418fa02f --- /dev/null +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/typescript/TypeScriptPreferenceInitializer.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2022 Red Hat Inc. 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: + * Angelo ZERR (Red Hat Inc.) - initial implementation + *******************************************************************************/ +package org.eclipse.wildwebdeveloper.jsts.ui.preferences.typescript; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; + +/** + * TypeScript preference initializer. + * + */ +public class TypeScriptPreferenceInitializer extends AbstractPreferenceInitializer { + + @Override + public void initializeDefaultPreferences() { + TypeScriptPreferenceServerConstants.initializeDefaultPreferences(); + } + +} \ No newline at end of file diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/typescript/TypeScriptPreferencePage.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/typescript/TypeScriptPreferencePage.java new file mode 100644 index 0000000000..6774f66bb7 --- /dev/null +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/typescript/TypeScriptPreferencePage.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2022 Red Hat Inc. 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: + * Angelo ZERR (Red Hat Inc.) - initial implementation + *******************************************************************************/ +package org.eclipse.wildwebdeveloper.jsts.ui.preferences.typescript; + +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.wildwebdeveloper.Activator; + +/** + * TypeScript main preference page. + * + */ +public class TypeScriptPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { + + public TypeScriptPreferencePage() { + super(GRID); + } + + @Override + public void init(IWorkbench workbench) { + setPreferenceStore(Activator.getDefault().getPreferenceStore()); + } + + @Override + protected void createFieldEditors() { + } +} \ No newline at end of file diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/typescript/TypeScriptPreferenceServerConstants.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/typescript/TypeScriptPreferenceServerConstants.java new file mode 100644 index 0000000000..dc8529a72f --- /dev/null +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/typescript/TypeScriptPreferenceServerConstants.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (c) 2022 Red Hat Inc. 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: + * Angelo ZERR (Red Hat Inc.) - initial implementation + *******************************************************************************/ +package org.eclipse.wildwebdeveloper.jsts.ui.preferences.typescript; + +import static org.eclipse.wildwebdeveloper.ui.preferences.Settings.isMatchSection; + +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.wildwebdeveloper.Activator; +import org.eclipse.wildwebdeveloper.ui.preferences.Settings; + +/** + * TypeScript preference server constants. + * + */ +public class TypeScriptPreferenceServerConstants { + + public static final String TYPESCRIPT_SECTION = "typescript"; + + // Inlay Hint settings + public static final String TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_ENUM_MEMBER_VALUE_HINTS = "typescript.inlayHints.includeInlayEnumMemberValueHints"; + public static final String TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_FUNCTION_LIKE_RETURN_TYPE_HINTS = "typescript.inlayHints.includeInlayFunctionLikeReturnTypeHints"; + public static final String TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_FUNCTION_PARAMETER_TYPE_HINTS = "typescript.inlayHints.includeInlayFunctionParameterTypeHints"; + public static final String TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS = "typescript.inlayHints.includeInlayParameterNameHints"; + public static final String TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS_WHEN_ARGUMENT_MATCHES_NAME = "typescript.inlayHints.includeInlayParameterNameHintsWhenArgumentMatchesName"; + public static final String TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PROPERTY_DECLARATION_TYPE_HINTS = "typescript.inlayHints.includeInlayPropertyDeclarationTypeHints"; + public static final String TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_VARIABLE_TYPE_HINTS = "typescript.inlayHints.includeInlayVariableTypeHints"; + public static final String TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_VARIABLE_TYPE_HINTS_WHEN_TYPE_MATCHES_NAME = "typescript.inlayHints.includeInlayVariableTypeHintsWhenTypeMatchesName"; + + public static Settings getGlobalSettings() { + Settings settings = new Settings(Activator.getDefault().getPreferenceStore()); + + // Inlay Hint settings + settings.fillAsBoolean(TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_ENUM_MEMBER_VALUE_HINTS); + settings.fillAsBoolean(TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_FUNCTION_LIKE_RETURN_TYPE_HINTS); + settings.fillAsBoolean(TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_FUNCTION_PARAMETER_TYPE_HINTS); + settings.fillAsString(TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS); + settings.fillAsBoolean( + TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS_WHEN_ARGUMENT_MATCHES_NAME); + settings.fillAsBoolean(TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PROPERTY_DECLARATION_TYPE_HINTS); + settings.fillAsBoolean(TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_VARIABLE_TYPE_HINTS); + settings.fillAsBoolean( + TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_VARIABLE_TYPE_HINTS_WHEN_TYPE_MATCHES_NAME); + return settings; + } + + public static void initializeDefaultPreferences() { + IPreferenceStore store = Activator.getDefault().getPreferenceStore(); + + // Server settings + + // - Inlay Hint + store.setDefault(TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS, false); + store.setDefault(TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_FUNCTION_LIKE_RETURN_TYPE_HINTS, false); + store.setDefault(TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_FUNCTION_PARAMETER_TYPE_HINTS, false); + store.setDefault(TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS, "none"); // 'none' | + // 'literals' + // | 'all' + store.setDefault( + TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS_WHEN_ARGUMENT_MATCHES_NAME, + false); + store.setDefault(TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PROPERTY_DECLARATION_TYPE_HINTS, false); + store.setDefault(TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_VARIABLE_TYPE_HINTS, false); + store.setDefault(TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_VARIABLE_TYPE_HINTS_WHEN_TYPE_MATCHES_NAME, + false); + } + + /** + * Returns true if the given section matches TypeScript settings and false + * otherwise. + * + * @param section the section to check. + * + * @return true if the given section matches TypeScript settings and false + * otherwise. + */ + public static boolean isMatchTypeScriptSection(String section) { + return isMatchSection(section, TYPESCRIPT_SECTION); + } +} diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/ui/preferences/IndentedBooleanFieldEditor.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/ui/preferences/IndentedBooleanFieldEditor.java new file mode 100644 index 0000000000..939e73cfd2 --- /dev/null +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/ui/preferences/IndentedBooleanFieldEditor.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2022 Red Hat Inc. 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: + * Angelo ZERR (Red Hat Inc.) - initial implementation + *******************************************************************************/ +package org.eclipse.wildwebdeveloper.ui.preferences; + +import org.eclipse.jface.preference.BooleanFieldEditor; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; + +/** + * {@link BooleanFieldEditor} extension to display the checkbox with + * indentation. + * + */ +public class IndentedBooleanFieldEditor extends BooleanFieldEditor { + + private static final int INDENT_SIZE = 20; + + /** + * Creates a boolean field editor in the default style. + * + * @param name the name of the preference this field editor works on + * @param label the label text of the field editor + * @param parent the parent of the field editor's control + */ + public IndentedBooleanFieldEditor(String name, String label, Composite parent) { + super(name, label, DEFAULT, parent); + } + + @Override + protected void doFillIntoGrid(Composite parent, int numColumns) { + super.doFillIntoGrid(parent, numColumns); + Button checkBox = super.getChangeControl(parent); + ((GridData) checkBox.getLayoutData()).horizontalIndent = INDENT_SIZE; + } +}