diff --git a/org.eclipse.wildwebdeveloper/plugin.properties b/org.eclipse.wildwebdeveloper/plugin.properties index 4e1039183a..b657d81fa3 100644 --- a/org.eclipse.wildwebdeveloper/plugin.properties +++ b/org.eclipse.wildwebdeveloper/plugin.properties @@ -1,70 +1,71 @@ -#/******************************************************************************* -# * 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 -# *******************************************************************************/ -pluginName=Wild Web Developer: web development in Eclipse IDE -providerName=Eclipse Wild Web Developer project - -# CSS, LESS, SCSS -CSSPreferencePage.name=CSS (Wild Web Developer) -CSSCompletionPreferencePage.name=Completion -CSSFormatPreferencePage.name=Format -CSSHoverPreferencePage.name=Hover -CSSValidationPreferencePage.name=Validation - -LESSPreferencePage.name=LESS -LESSCompletionPreferencePage.name=Completion -LESSFormatPreferencePage.name=Format -LESSHoverPreferencePage.name=Hover -LESSValidationPreferencePage.name=Validation - -SCSSPreferencePage.name=SCSS -SCSSCompletionPreferencePage.name=Completion -SCSSFormatPreferencePage.name=Format -SCSSHoverPreferencePage.name=Hover -SCSSValidationPreferencePage.name=Validation - -# HTML -HTMLPreferencePage.name=HTML (Wild Web Developer) -HTMLCompletionPreferencePage.name=Completion -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 - -# Markdown -MarkdownPreferencePage.name=Markdown (Wild Web Developer) -MarkdownProblem=Markdown Problem - -# YAML -YAMLPreferencePage.name=YAML (Wild Web Developer) -YAMLCompletionPreferencePage.name=Completion -YAMLFormatPreferencePage.name=Format -YAMLHoverPreferencePage.name=Hover -YAMLValidationPreferencePage.name=Validation - -# preference keywords -preferenceKeywords.yaml=yaml -preferenceKeywords.js=js -preferenceKeywords.ts=ts -preferenceKeywords.javascript=javascript -preferenceKeywords.typescript=typescript -preferenceKeywords.css=css -preferenceKeywords.less=less -preferenceKeywords.scss=scss -preferenceKeywords.sass=sass +#/******************************************************************************* +# * 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 +# *******************************************************************************/ +pluginName=Wild Web Developer: web development in Eclipse IDE +providerName=Eclipse Wild Web Developer project + +# CSS, LESS, SCSS +CSSPreferencePage.name=CSS (Wild Web Developer) +CSSCompletionPreferencePage.name=Completion +CSSFormatPreferencePage.name=Format +CSSHoverPreferencePage.name=Hover +CSSValidationPreferencePage.name=Validation + +LESSPreferencePage.name=LESS +LESSCompletionPreferencePage.name=Completion +LESSFormatPreferencePage.name=Format +LESSHoverPreferencePage.name=Hover +LESSValidationPreferencePage.name=Validation + +SCSSPreferencePage.name=SCSS +SCSSCompletionPreferencePage.name=Completion +SCSSFormatPreferencePage.name=Format +SCSSHoverPreferencePage.name=Hover +SCSSValidationPreferencePage.name=Validation + +# HTML +HTMLPreferencePage.name=HTML (Wild Web Developer) +HTMLCompletionPreferencePage.name=Completion +HTMLFormatPreferencePage.name=Format +HTMLHoverPreferencePage.name=Hover +HTMLValidationPreferencePage.name=Validation + +# JST/TS +JSTSPreferencePage.name=JS/TS (Wild Web Developer) +TypeScriptPreferencePage.name=TypeScript +JavaScriptPreferencePage.name=JavaScript +JSTSCodeLensPreferencePage.name=Code Lens +JSTSInlayHintPreferencePage.name=Inlay Hint +JSTSFormatterPreferencePage.name=Formatter + +# Markdown +MarkdownPreferencePage.name=Markdown (Wild Web Developer) +MarkdownProblem=Markdown Problem + +# YAML +YAMLPreferencePage.name=YAML (Wild Web Developer) +YAMLCompletionPreferencePage.name=Completion +YAMLFormatPreferencePage.name=Format +YAMLHoverPreferencePage.name=Hover +YAMLValidationPreferencePage.name=Validation + +# preference keywords +preferenceKeywords.yaml=yaml +preferenceKeywords.js=js +preferenceKeywords.ts=ts +preferenceKeywords.javascript=javascript +preferenceKeywords.typescript=typescript +preferenceKeywords.css=css +preferenceKeywords.less=less +preferenceKeywords.scss=scss +preferenceKeywords.sass=sass preferenceKeywords.html=html preferenceKeywords.markdown=markdown diff --git a/org.eclipse.wildwebdeveloper/plugin.xml b/org.eclipse.wildwebdeveloper/plugin.xml index f7c3eb3436..7b4c093b07 100644 --- a/org.eclipse.wildwebdeveloper/plugin.xml +++ b/org.eclipse.wildwebdeveloper/plugin.xml @@ -514,11 +514,27 @@ + + + + + name="%JSTSInlayHintPreferencePage.name"> + + + + @@ -531,11 +547,27 @@ + + + + + name="%JSTSInlayHintPreferencePage.name"> + + + + diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/JSTSLanguageServer.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/JSTSLanguageServer.java index 739dfffe3e..02122b0155 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/JSTSLanguageServer.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/JSTSLanguageServer.java @@ -14,8 +14,7 @@ *******************************************************************************/ package org.eclipse.wildwebdeveloper.jsts; -import static org.eclipse.wildwebdeveloper.jsts.ui.preferences.JSTSPreferenceServerConstants.TYPESCRIPT_PREFERENCES_TSSERVER_TYPESCRIPT_VERSION_PROJECT; -import static org.eclipse.wildwebdeveloper.jsts.ui.preferences.JSTSPreferenceServerConstants.getTypeScriptVersion; +import static org.eclipse.wildwebdeveloper.jsts.ui.preferences.JSTSPreferenceServerConstants.*; import java.io.File; import java.io.IOException; @@ -35,8 +34,7 @@ import org.eclipse.lsp4j.services.LanguageServer; import org.eclipse.wildwebdeveloper.Activator; import org.eclipse.wildwebdeveloper.embedder.node.NodeJSManager; -import org.eclipse.wildwebdeveloper.jsts.ui.preferences.javascript.JavaScriptPreferenceServerConstants; -import org.eclipse.wildwebdeveloper.jsts.ui.preferences.typescript.TypeScriptPreferenceServerConstants; +import org.eclipse.wildwebdeveloper.jsts.ui.preferences.JSTSLanguagePreferences; import org.eclipse.wildwebdeveloper.ui.preferences.ProcessStreamConnectionProviderWithPreference; public class JSTSLanguageServer extends ProcessStreamConnectionProviderWithPreference { @@ -107,9 +105,9 @@ public Object getInitializationOptions(URI rootUri) { protected Object createSettings() { Map settings = new HashMap<>(); // javascript - settings.putAll(JavaScriptPreferenceServerConstants.getGlobalSettings()); + settings.putAll(JSTSLanguagePreferences.JS.getGlobalSettings()); // typescript - settings.putAll(TypeScriptPreferenceServerConstants.getGlobalSettings()); + settings.putAll(JSTSLanguagePreferences.TS.getGlobalSettings()); return settings; } 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 index 4f37fbd833..5fd21ecdc5 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/Messages.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/Messages.java @@ -7,9 +7,10 @@ * SPDX-License-Identifier: EPL-2.0 * * Contributors: - * Angelo ZERR (Red Hat Inc.) - initial implementation - * Pierre-Yves Bigourdan - Allow using TypeScript version specified by project - * Pierre-Yves Bigourdan - Allow configuring directory of ESLint package + * Angelo ZERR (Red Hat Inc.) - initial implementation + * Pierre-Yves Bigourdan - Allow using TypeScript version specified by project + * Pierre-Yves Bigourdan - Allow configuring directory of ESLint package + * Sebastian Thomschke (Vegard IT GmbH) - add CodeLensPreferencePage, FormatterPreferencePage keys *******************************************************************************/ package org.eclipse.wildwebdeveloper.jsts.ui; @@ -17,7 +18,6 @@ /** * JS/TS messages keys. - * */ public class Messages extends NLS { @@ -27,19 +27,50 @@ public class Messages extends NLS { public static String JSTSPreferencePage_eslintNodePath; - // --------- 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; + // JavaScript / TypeScript Inlay Hints preference page + public static String InlayHintPreferencePage_showInlayHintsFor_label; + public static String InlayHintPreferencePage_includeInlayEnumMemberValueHints; + public static String InlayHintPreferencePage_includeInlayFunctionLikeReturnTypeHints; + public static String InlayHintPreferencePage_includeInlayFunctionParameterTypeHints; + public static String InlayHintPreferencePage_includeInlayParameterNameHints; + public static String InlayHintPreferencePage_includeInlayParameterNameHints_none; + public static String InlayHintPreferencePage_includeInlayParameterNameHints_literals; + public static String InlayHintPreferencePage_includeInlayParameterNameHints_all; + public static String InlayHintPreferencePage_includeInlayParameterNameHintsWhenArgumentMatchesName; + public static String InlayHintPreferencePage_includeInlayPropertyDeclarationTypeHints; + public static String InlayHintPreferencePage_includeInlayVariableTypeHints; + public static String InlayHintPreferencePage_includeInlayVariableTypeHintsWhenTypeMatchesName; + + // JavaScript / TypeScript Code Lens preference page + public static String CodeLensPreferencePage_showCodeLensFor_label; + public static String CodeLensPreferencePage_implementationsCodeLens_enabled; + public static String CodeLensPreferencePage_referencesCodeLens_enabled; + public static String CodeLensPreferencePage_referencesCodeLens_showOnAllFunctions; + + public static String FormatterPreferencePage_baseIndentSize; + public static String FormatterPreferencePage_convertTabsToSpaces; + public static String FormatterPreferencePage_indentSize; + public static String FormatterPreferencePage_indentStyle; + public static String FormatterPreferencePage_insertSpaceAfterCommaDelimiter; + public static String FormatterPreferencePage_insertSpaceAfterConstructor; + public static String FormatterPreferencePage_insertSpaceAfterFunctionKeywordForAnonymousFunctions; + public static String FormatterPreferencePage_insertSpaceAfterKeywordsInControlFlowStatements; + public static String FormatterPreferencePage_insertSpaceAfterOpeningAndBeforeClosingEmptyBraces; + public static String FormatterPreferencePage_insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces; + public static String FormatterPreferencePage_insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces; + public static String FormatterPreferencePage_insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets; + public static String FormatterPreferencePage_insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis; + public static String FormatterPreferencePage_insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces; + public static String FormatterPreferencePage_insertSpaceAfterSemicolonInForStatements; + public static String FormatterPreferencePage_insertSpaceAfterTypeAssertion; + public static String FormatterPreferencePage_insertSpaceBeforeAndAfterBinaryOperators; + public static String FormatterPreferencePage_insertSpaceBeforeFunctionParenthesis; + public static String FormatterPreferencePage_insertSpaceBeforeTypeAnnotation; + public static String FormatterPreferencePage_newLineCharacter; + public static String FormatterPreferencePage_placeOpenBraceOnNewLineForControlBlocks; + public static String FormatterPreferencePage_placeOpenBraceOnNewLineForFunctions; + public static String FormatterPreferencePage_semicolons; + public static String FormatterPreferencePage_trimTrailingWhitespace; 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 index 80468413d3..405ae7fc2c 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/messages.properties +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/messages.properties @@ -10,6 +10,7 @@ # * Angelo ZERR (Red Hat Inc.) - initial implementation # * Pierre-Yves Bigourdan - Allow using TypeScript version specified by project # * Pierre-Yves Bigourdan - Allow configuring directory of ESLint package +# * Sebastian Thomschke (Vegard IT GmbH) - add CodeLensPreferencePage, FormatterPreferencePage translations # *******************************************************************************/ JSTSPreferencePage_typeScriptVersion=Typescript version used for JavaScript and TypeScript language features: @@ -18,16 +19,48 @@ JSTSPreferencePage_typeScriptVersion_project=Project version JSTSPreferencePage_eslintNodePath=Absolute or project-relative path containing the eslint folder (node_modules used if blank): -# 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 +# JavaScript / TypeScript Inlay Hints preference page +InlayHintPreferencePage_showInlayHintsFor_label=Show inlay hints for: +InlayHintPreferencePage_includeInlayEnumMemberValueHints=member values in enum declarations +InlayHintPreferencePage_includeInlayFunctionLikeReturnTypeHints=implicit return types on function signatures +InlayHintPreferencePage_includeInlayFunctionParameterTypeHints=function parameter type +InlayHintPreferencePage_includeInlayPropertyDeclarationTypeHints=property declaration type +InlayHintPreferencePage_includeInlayParameterNameHints=parameter names: +InlayHintPreferencePage_includeInlayParameterNameHints_none=Disable parameter name hints +InlayHintPreferencePage_includeInlayParameterNameHints_literals=Only for literal arguments +InlayHintPreferencePage_includeInlayParameterNameHints_all=For literal and non-literal arguments +InlayHintPreferencePage_includeInlayParameterNameHintsWhenArgumentMatchesName=also on arguments whose text is identical to the parameter name +InlayHintPreferencePage_includeInlayVariableTypeHints=variable type +InlayHintPreferencePage_includeInlayVariableTypeHintsWhenTypeMatchesName=also variables whose name is identical to the type name + +# JavaScript / TypeScript Code Lens preference page +CodeLensPreferencePage_showCodeLensFor_label=Show code lens for: +CodeLensPreferencePage_implementationsCodeLens_enabled=Implementations (shows the number of implementations for symbols like classes or methods) +CodeLensPreferencePage_referencesCodeLens_enabled=References (shows the number of references/usages for symbols in the project) +CodeLensPreferencePage_referencesCodeLens_showOnAllFunctions=Show reference Code Lens on all functions (not just exported ones) + +# JavaScript / TypeScript Formatter preference page +FormatterPreferencePage_baseIndentSize=Base indentation size applied to the entire file +FormatterPreferencePage_convertTabsToSpaces=Convert tabs to spaces +FormatterPreferencePage_indentSize=Number of spaces used for each indentation level +FormatterPreferencePage_indentStyle=Indentation style +FormatterPreferencePage_insertSpaceAfterCommaDelimiter=Insert a space after each comma in lists (arrays, parameters, etc.) +FormatterPreferencePage_insertSpaceAfterConstructor=Insert a space after the 'constructor' keyword before the parameter list +FormatterPreferencePage_insertSpaceAfterFunctionKeywordForAnonymousFunctions=Insert a space after the 'function' keyword in anonymous or inline functions +FormatterPreferencePage_insertSpaceAfterKeywordsInControlFlowStatements=Insert a space after control-flow keywords such as 'if', 'for', 'while', and 'switch' +FormatterPreferencePage_insertSpaceAfterOpeningAndBeforeClosingEmptyBraces=Insert spaces inside empty curly braces (e.g., '{ }') +FormatterPreferencePage_insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces=Insert spaces inside JSX expression braces (e.g., '{ value }') +FormatterPreferencePage_insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces=Insert spaces inside non-empty curly braces (e.g., '{ a: 1 }') +FormatterPreferencePage_insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets=Insert spaces inside brackets (e.g., '[ 1, 2 ]') +FormatterPreferencePage_insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis=Insert spaces inside parentheses (e.g., '( a + b )') +FormatterPreferencePage_insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces=Insert spaces inside template string expressions (e.g., `${ value }`) +FormatterPreferencePage_insertSpaceAfterSemicolonInForStatements=Insert a space after each semicolon in 'for' statement headers +FormatterPreferencePage_insertSpaceAfterTypeAssertion=Insert a space after a type assertion expression (e.g., ' value') +FormatterPreferencePage_insertSpaceBeforeAndAfterBinaryOperators=Insert spaces around binary and logical operators (e.g., 'a + b', 'x && y') +FormatterPreferencePage_insertSpaceBeforeFunctionParenthesis=Insert a space before the opening parenthesis in function declarations +FormatterPreferencePage_insertSpaceBeforeTypeAnnotation=Insert a space before a colon in type annotations (e.g., 'let x : number') +FormatterPreferencePage_newLineCharacter=Character(s) used for new lines +FormatterPreferencePage_placeOpenBraceOnNewLineForControlBlocks=Place the opening brace of control blocks (e.g., 'if', 'for') on a new line +FormatterPreferencePage_placeOpenBraceOnNewLineForFunctions=Place the opening brace of function declarations on a new line +FormatterPreferencePage_semicolons=Semicolon handling +FormatterPreferencePage_trimTrailingWhitespace=Remove trailing whitespace characters when formatting diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/JSTSCodeLensPreferencePage.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/JSTSCodeLensPreferencePage.java new file mode 100644 index 0000000000..ca51729715 --- /dev/null +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/JSTSCodeLensPreferencePage.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2025 Vegard IT GmbH 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: + * Sebastian Thomschke (Vegard IT GmbH) - initial implementation + *******************************************************************************/ +package org.eclipse.wildwebdeveloper.jsts.ui.preferences; + +import org.eclipse.jface.preference.BooleanFieldEditor; +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; + +/** + * JavaScript / TypeScript Code Lens preference page. + */ +public abstract class JSTSCodeLensPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { + + private final JSTSLanguagePreferences prefs; + + protected JSTSCodeLensPreferencePage(JSTSLanguagePreferences prefs) { + super(GRID); + this.prefs = prefs; + } + + @Override + public void createFieldEditors() { + Composite parent = getFieldEditorParent(); + Label label = new Label(parent, SWT.NONE); + label.setText(Messages.CodeLensPreferencePage_showCodeLensFor_label); + + addField(new BooleanFieldEditor(prefs.implementationsCodeLens_enabled, + Messages.CodeLensPreferencePage_implementationsCodeLens_enabled, parent)); + addField(new BooleanFieldEditor(prefs.referencesCodeLens_enabled, + Messages.CodeLensPreferencePage_referencesCodeLens_enabled, parent)); + addField(new BooleanFieldEditor(prefs.referencesCodeLens_showOnAllFunctions, + Messages.CodeLensPreferencePage_referencesCodeLens_showOnAllFunctions, parent)); + } + + @Override + public void init(IWorkbench workbench) { + setPreferenceStore(Activator.getDefault().getPreferenceStore()); + } +} diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/JSTSFormatterPreferencePage.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/JSTSFormatterPreferencePage.java new file mode 100644 index 0000000000..98fe774d89 --- /dev/null +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/JSTSFormatterPreferencePage.java @@ -0,0 +1,110 @@ +/******************************************************************************* + * Copyright (c) 2025 Vegard IT GmbH 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: + * Sebastian Thomschke (Vegard IT GmbH) - initial implementation + *******************************************************************************/ +package org.eclipse.wildwebdeveloper.jsts.ui.preferences; + +import org.eclipse.jface.preference.BooleanFieldEditor; +import org.eclipse.jface.preference.ComboFieldEditor; +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.jface.preference.IntegerFieldEditor; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.wildwebdeveloper.Activator; +import org.eclipse.wildwebdeveloper.jsts.ui.Messages; + +/** + * JavaScript / TypeScript Formatter preference page. + */ +public abstract class JSTSFormatterPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { + + private final JSTSLanguagePreferences prefs; + + protected JSTSFormatterPreferencePage(JSTSLanguagePreferences prefs) { + super(GRID); + this.prefs = prefs; + } + + @Override + public void createFieldEditors() { + Composite parent = getFieldEditorParent(); + + // indentation settings + addField(new IntegerFieldEditor(prefs.format_baseIndentSize, Messages.FormatterPreferencePage_baseIndentSize, + getFieldEditorParent())); + addField(new IntegerFieldEditor(prefs.format_indentSize, Messages.FormatterPreferencePage_indentSize, parent)); + addField(new ComboFieldEditor(prefs.format_indentStyle, + Messages.FormatterPreferencePage_indentStyle, + new String[][] { + { "None: no indent", "0" }, + { "Blok: indent statements inside blocks", "1" }, + { "Smart: context-aware indendation", "2" } }, + parent)); + addField(new BooleanFieldEditor(prefs.format_convertTabsToSpaces, Messages.FormatterPreferencePage_convertTabsToSpaces, parent)); + + // whitespace settings + addField(new BooleanFieldEditor(prefs.format_insertSpaceAfterCommaDelimiter, + Messages.FormatterPreferencePage_insertSpaceAfterCommaDelimiter, parent)); + addField(new BooleanFieldEditor(prefs.format_insertSpaceAfterConstructor, + Messages.FormatterPreferencePage_insertSpaceAfterConstructor, parent)); + addField(new BooleanFieldEditor(prefs.format_insertSpaceAfterFunctionKeywordForAnonymousFunctions, + Messages.FormatterPreferencePage_insertSpaceAfterFunctionKeywordForAnonymousFunctions, parent)); + addField(new BooleanFieldEditor(prefs.format_insertSpaceAfterKeywordsInControlFlowStatements, + Messages.FormatterPreferencePage_insertSpaceAfterKeywordsInControlFlowStatements, parent)); + addField(new BooleanFieldEditor(prefs.format_insertSpaceAfterOpeningAndBeforeClosingEmptyBraces, + Messages.FormatterPreferencePage_insertSpaceAfterOpeningAndBeforeClosingEmptyBraces, parent)); + addField(new BooleanFieldEditor(prefs.format_insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces, + Messages.FormatterPreferencePage_insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces, parent)); + addField(new BooleanFieldEditor(prefs.format_insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces, + Messages.FormatterPreferencePage_insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces, parent)); + addField(new BooleanFieldEditor(prefs.format_insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets, + Messages.FormatterPreferencePage_insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets, parent)); + addField(new BooleanFieldEditor(prefs.format_insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis, + Messages.FormatterPreferencePage_insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis, parent)); + addField(new BooleanFieldEditor(prefs.format_insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces, + Messages.FormatterPreferencePage_insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces, parent)); + addField(new BooleanFieldEditor(prefs.format_insertSpaceAfterSemicolonInForStatements, + Messages.FormatterPreferencePage_insertSpaceAfterSemicolonInForStatements, parent)); + addField(new BooleanFieldEditor(prefs.format_insertSpaceAfterTypeAssertion, + Messages.FormatterPreferencePage_insertSpaceAfterTypeAssertion, parent)); + addField(new BooleanFieldEditor(prefs.format_insertSpaceBeforeAndAfterBinaryOperators, + Messages.FormatterPreferencePage_insertSpaceBeforeAndAfterBinaryOperators, parent)); + addField(new BooleanFieldEditor(prefs.format_insertSpaceBeforeFunctionParenthesis, + Messages.FormatterPreferencePage_insertSpaceBeforeFunctionParenthesis, parent)); + addField(new BooleanFieldEditor(prefs.format_insertSpaceBeforeTypeAnnotation, + Messages.FormatterPreferencePage_insertSpaceBeforeTypeAnnotation, parent)); + addField(new ComboFieldEditor(prefs.format_newLineCharacter, + Messages.FormatterPreferencePage_newLineCharacter, + new String[][] { + { "\\n (Linux/MacOS)", "\n" }, + { "\\r\\n (Windows)", "\r\n" } }, + parent)); + addField(new BooleanFieldEditor(prefs.format_placeOpenBraceOnNewLineForControlBlocks, + Messages.FormatterPreferencePage_placeOpenBraceOnNewLineForControlBlocks, parent)); + addField(new BooleanFieldEditor(prefs.format_placeOpenBraceOnNewLineForFunctions, + Messages.FormatterPreferencePage_placeOpenBraceOnNewLineForFunctions, parent)); + addField(new ComboFieldEditor(prefs.format_semicolons, + Messages.FormatterPreferencePage_semicolons, + new String[][] { + { "Ignore: leave unchanged", "ignore" }, + { "Insert: always insert", "insert" }, + { "Remove: remove where possible", "remove" } }, + parent)); + addField(new BooleanFieldEditor(prefs.format_trimTrailingWhitespace, + Messages.FormatterPreferencePage_trimTrailingWhitespace, parent)); + } + + @Override + public void init(IWorkbench workbench) { + setPreferenceStore(Activator.getDefault().getPreferenceStore()); + } +} diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/JSTSLanguagePreferences.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/JSTSLanguagePreferences.java new file mode 100644 index 0000000000..ec1a51c2cc --- /dev/null +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/JSTSLanguagePreferences.java @@ -0,0 +1,240 @@ +/******************************************************************************* + * 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 + * Sebastian Thomschke (Vegard IT GmbH) - add Formatter and Code Lens prefs handling + *******************************************************************************/ +package org.eclipse.wildwebdeveloper.jsts.ui.preferences; + +import static org.eclipse.wildwebdeveloper.ui.preferences.Settings.isMatchSection; + +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.ui.editors.text.EditorsUI; +import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; +import org.eclipse.wildwebdeveloper.Activator; +import org.eclipse.wildwebdeveloper.ui.preferences.Settings; + +/** + * JS/TS preferences. + * See https://github.com/typescript-language-server/typescript-language-server/blob/master/docs/configuration.md + */ +public class JSTSLanguagePreferences { + + public static final JSTSLanguagePreferences JS = new JSTSLanguagePreferences("javascript"); + public static final JSTSLanguagePreferences TS = new JSTSLanguagePreferences("typescript"); + + // Formatting preferences keys + public final String format_baseIndentSize; + public final String format_convertTabsToSpaces; + public final String format_indentSize; + public final String format_indentStyle; + public final String format_tabSize; + + public final String format_insertSpaceAfterCommaDelimiter; + public final String format_insertSpaceAfterConstructor; + public final String format_insertSpaceAfterFunctionKeywordForAnonymousFunctions; + public final String format_insertSpaceAfterKeywordsInControlFlowStatements; + public final String format_insertSpaceAfterOpeningAndBeforeClosingEmptyBraces; + public final String format_insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces; + public final String format_insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces; + public final String format_insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets; + public final String format_insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis; + public final String format_insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces; + public final String format_insertSpaceAfterSemicolonInForStatements; + public final String format_insertSpaceAfterTypeAssertion; + public final String format_insertSpaceBeforeAndAfterBinaryOperators; + public final String format_insertSpaceBeforeFunctionParenthesis; + public final String format_insertSpaceBeforeTypeAnnotation; + public final String format_newLineCharacter; + public final String format_placeOpenBraceOnNewLineForControlBlocks; + public final String format_placeOpenBraceOnNewLineForFunctions; + public final String format_semicolons; + public final String format_trimTrailingWhitespace; + + // Inlay Hint preferences keys + public final String inlayHints_includeInlayEnumMemberValueHints; + public final String inlayHints_includeInlayFunctionLikeReturnTypeHints; + public final String inlayHints_includeInlayFunctionParameterTypeHints; + public final String inlayHints_includeInlayParameterNameHints; + public final String inlayHints_includeInlayParameterNameHintsWhenArgumentMatchesName; + public final String inlayHints_includeInlayPropertyDeclarationTypeHints; + public final String inlayHints_includeInlayVariableTypeHints; + public final String inlayHints_includeInlayVariableTypeHintsWhenTypeMatchesName; + + // Code Lens preferences keys + public final String implementationsCodeLens_enabled; + public final String referencesCodeLens_enabled; + public final String referencesCodeLens_showOnAllFunctions; + + private final String section; + + private JSTSLanguagePreferences(String section) { + this.section = section; + + // Formatting preferences keys + format_baseIndentSize = section + ".format.baseIndentSize"; + format_convertTabsToSpaces = section + ".format.convertTabsToSpaces"; + format_indentSize = section + ".format.indentSize"; + format_indentStyle = section + ".format.indentStyle"; + format_tabSize = section + ".format.tabSize"; + + format_insertSpaceAfterCommaDelimiter = section + ".format.insertSpaceAfterCommaDelimiter"; + format_insertSpaceAfterConstructor = section + ".format.insertSpaceAfterConstructor"; + format_insertSpaceAfterFunctionKeywordForAnonymousFunctions = section + + ".format.insertSpaceAfterFunctionKeywordForAnonymousFunctions"; + format_insertSpaceAfterKeywordsInControlFlowStatements = section + ".format.insertSpaceAfterKeywordsInControlFlowStatements"; + format_insertSpaceAfterOpeningAndBeforeClosingEmptyBraces = section + ".format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces"; + format_insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces = section + + ".format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"; + format_insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces = section + + ".format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"; + format_insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets = section + + ".format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"; + format_insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis = section + + ".format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"; + format_insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces = section + + ".format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"; + format_insertSpaceAfterSemicolonInForStatements = section + ".format.insertSpaceAfterSemicolonInForStatements"; + format_insertSpaceAfterTypeAssertion = section + ".format.insertSpaceAfterTypeAssertion"; + format_insertSpaceBeforeAndAfterBinaryOperators = section + ".format.insertSpaceBeforeAndAfterBinaryOperators"; + format_insertSpaceBeforeFunctionParenthesis = section + ".format.insertSpaceBeforeFunctionParenthesis"; + format_insertSpaceBeforeTypeAnnotation = section + ".format.insertSpaceBeforeTypeAnnotation"; + format_newLineCharacter = section + ".format.newLineCharacter"; + format_placeOpenBraceOnNewLineForControlBlocks = section + ".format.placeOpenBraceOnNewLineForControlBlocks"; + format_placeOpenBraceOnNewLineForFunctions = section + ".format.placeOpenBraceOnNewLineForFunctions"; + format_semicolons = section + ".format.semicolons"; + format_trimTrailingWhitespace = section + ".format.trimTrailingWhitespace"; + + // Inlay Hint preferences keys + inlayHints_includeInlayEnumMemberValueHints = section + ".inlayHints.includeInlayEnumMemberValueHints"; + inlayHints_includeInlayFunctionLikeReturnTypeHints = section + ".inlayHints.includeInlayFunctionLikeReturnTypeHints"; + inlayHints_includeInlayFunctionParameterTypeHints = section + ".inlayHints.includeInlayFunctionParameterTypeHints"; + inlayHints_includeInlayParameterNameHints = section + ".inlayHints.includeInlayParameterNameHints"; + inlayHints_includeInlayParameterNameHintsWhenArgumentMatchesName = section + + ".inlayHints.includeInlayParameterNameHintsWhenArgumentMatchesName"; + inlayHints_includeInlayPropertyDeclarationTypeHints = section + ".inlayHints.includeInlayPropertyDeclarationTypeHints"; + inlayHints_includeInlayVariableTypeHints = section + ".inlayHints.includeInlayVariableTypeHints"; + inlayHints_includeInlayVariableTypeHintsWhenTypeMatchesName = section + + ".inlayHints.includeInlayVariableTypeHintsWhenTypeMatchesName"; + + // Code Lens preferences keys + implementationsCodeLens_enabled = section + ".implementationsCodeLens.enabled"; + referencesCodeLens_enabled = section + ".referencesCodeLens.enabled"; + referencesCodeLens_showOnAllFunctions = section + ".referencesCodeLens.showOnAllFunctions"; + } + + public Settings getGlobalSettings() { + Settings settings = new Settings(Activator.getDefault().getPreferenceStore()); + + // Formatting preferences + settings.fillAsInt(format_baseIndentSize); + settings.fillAsBoolean(format_convertTabsToSpaces); + settings.fillAsInt(format_indentSize); + settings.fillAsInt(format_indentStyle); + settings.fillSetting(format_tabSize, + // Using: Preferences > General > Editors > Text Editors > Displayed tab width + EditorsUI.getPreferenceStore().getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH)); + + settings.fillAsBoolean(format_insertSpaceAfterCommaDelimiter); + settings.fillAsBoolean(format_insertSpaceAfterConstructor); + settings.fillAsBoolean(format_insertSpaceAfterFunctionKeywordForAnonymousFunctions); + settings.fillAsBoolean(format_insertSpaceAfterKeywordsInControlFlowStatements); + settings.fillAsBoolean(format_insertSpaceAfterOpeningAndBeforeClosingEmptyBraces); + settings.fillAsBoolean(format_insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces); + settings.fillAsBoolean(format_insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces); + settings.fillAsBoolean(format_insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets); + settings.fillAsBoolean(format_insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis); + settings.fillAsBoolean(format_insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces); + settings.fillAsBoolean(format_insertSpaceAfterSemicolonInForStatements); + settings.fillAsBoolean(format_insertSpaceAfterTypeAssertion); + settings.fillAsBoolean(format_insertSpaceBeforeAndAfterBinaryOperators); + settings.fillAsBoolean(format_insertSpaceBeforeFunctionParenthesis); + settings.fillAsBoolean(format_insertSpaceBeforeTypeAnnotation); + settings.fillAsString(format_newLineCharacter); + settings.fillAsBoolean(format_placeOpenBraceOnNewLineForControlBlocks); + settings.fillAsBoolean(format_placeOpenBraceOnNewLineForFunctions); + settings.fillAsString(format_semicolons); + settings.fillAsString(format_trimTrailingWhitespace); + + // Inlay Hint preferences + settings.fillAsBoolean(inlayHints_includeInlayEnumMemberValueHints); + settings.fillAsBoolean(inlayHints_includeInlayFunctionLikeReturnTypeHints); + settings.fillAsBoolean(inlayHints_includeInlayFunctionParameterTypeHints); + settings.fillAsString(inlayHints_includeInlayParameterNameHints); + settings.fillAsBoolean(inlayHints_includeInlayParameterNameHintsWhenArgumentMatchesName); + settings.fillAsBoolean(inlayHints_includeInlayPropertyDeclarationTypeHints); + settings.fillAsBoolean(inlayHints_includeInlayVariableTypeHints); + settings.fillAsBoolean(inlayHints_includeInlayVariableTypeHintsWhenTypeMatchesName); + + // Code Lens preferences + settings.fillAsBoolean(implementationsCodeLens_enabled); + settings.fillAsBoolean(referencesCodeLens_enabled); + settings.fillAsBoolean(referencesCodeLens_showOnAllFunctions); + return settings; + } + + public void initializeDefaultPreferences() { + IPreferenceStore store = Activator.getDefault().getPreferenceStore(); + + // Formatting preferences + // https://github.com/microsoft/TypeScript/blob/efca03ffed10dccede4fbc8dd8a624374e5424d9/src/services/types.ts#L1212 + store.setDefault(format_baseIndentSize, 0); + store.setDefault(format_convertTabsToSpaces, true); + store.setDefault(format_indentSize, 4); + store.setDefault(format_indentStyle, "2"); // 0=None|1=Block|2=Smart + store.setDefault(format_insertSpaceAfterCommaDelimiter, true); + store.setDefault(format_insertSpaceAfterConstructor, false); + store.setDefault(format_insertSpaceAfterFunctionKeywordForAnonymousFunctions, false); + store.setDefault(format_insertSpaceAfterKeywordsInControlFlowStatements, true); + store.setDefault(format_insertSpaceAfterOpeningAndBeforeClosingEmptyBraces, false); + store.setDefault(format_insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces, false); + store.setDefault(format_insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces, true); + store.setDefault(format_insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets, false); + store.setDefault(format_insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis, false); + store.setDefault(format_insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces, false); + store.setDefault(format_insertSpaceAfterSemicolonInForStatements, false); + store.setDefault(format_insertSpaceAfterTypeAssertion, false); + store.setDefault(format_insertSpaceBeforeAndAfterBinaryOperators, true); + store.setDefault(format_insertSpaceBeforeFunctionParenthesis, false); + store.setDefault(format_insertSpaceBeforeTypeAnnotation, false); + store.setDefault(format_newLineCharacter, System.lineSeparator()); + store.setDefault(format_placeOpenBraceOnNewLineForControlBlocks, false); + store.setDefault(format_placeOpenBraceOnNewLineForFunctions, false); + store.setDefault(format_semicolons, "ignore"); // ignore|insert|remove + // store.setDefault(format_tabSize, 4); + store.setDefault(format_trimTrailingWhitespace, true); + + // Inlay Hint preferences + store.setDefault(inlayHints_includeInlayParameterNameHints, false); + store.setDefault(inlayHints_includeInlayFunctionLikeReturnTypeHints, false); + store.setDefault(inlayHints_includeInlayFunctionParameterTypeHints, false); + store.setDefault(inlayHints_includeInlayParameterNameHints, "none"); // none|literals|all + store.setDefault(inlayHints_includeInlayParameterNameHintsWhenArgumentMatchesName, false); + store.setDefault(inlayHints_includeInlayPropertyDeclarationTypeHints, false); + store.setDefault(inlayHints_includeInlayVariableTypeHints, false); + store.setDefault(inlayHints_includeInlayVariableTypeHintsWhenTypeMatchesName, false); + + // Code Lens preferences + store.setDefault(implementationsCodeLens_enabled, false); + store.setDefault(referencesCodeLens_enabled, false); + store.setDefault(referencesCodeLens_showOnAllFunctions, 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 boolean isMatchTypeScriptSection(String section) { + return isMatchSection(section, this.section); + } +} diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/javascript/JavaScriptCodeLensPreferencePage.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/javascript/JavaScriptCodeLensPreferencePage.java new file mode 100644 index 0000000000..d3a9add25c --- /dev/null +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/javascript/JavaScriptCodeLensPreferencePage.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2025 Vegard IT GmbH 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: + * Sebastian Thomschke (Vegard IT GmbH) - initial implementation + *******************************************************************************/ +package org.eclipse.wildwebdeveloper.jsts.ui.preferences.javascript; + +import org.eclipse.wildwebdeveloper.jsts.ui.preferences.JSTSCodeLensPreferencePage; +import org.eclipse.wildwebdeveloper.jsts.ui.preferences.JSTSLanguagePreferences; + +/** + * JavaScript Inlay Hint preference page. + */ +public final class JavaScriptCodeLensPreferencePage extends JSTSCodeLensPreferencePage { + + public JavaScriptCodeLensPreferencePage() { + super(JSTSLanguagePreferences.JS); + } +} diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/javascript/JavaScriptFormatterPreferencePage.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/javascript/JavaScriptFormatterPreferencePage.java new file mode 100644 index 0000000000..a7b0417cca --- /dev/null +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/javascript/JavaScriptFormatterPreferencePage.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2025 Vegard IT GmbH 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: + * Sebastian Thomschke (Vegard IT GmbH) - initial implementation + *******************************************************************************/ +package org.eclipse.wildwebdeveloper.jsts.ui.preferences.javascript; + +import org.eclipse.wildwebdeveloper.jsts.ui.preferences.JSTSFormatterPreferencePage; +import org.eclipse.wildwebdeveloper.jsts.ui.preferences.JSTSLanguagePreferences; + +/** + * JavaScript Inlay Hint preference page. + */ +public final class JavaScriptFormatterPreferencePage extends JSTSFormatterPreferencePage { + + public JavaScriptFormatterPreferencePage() { + super(JSTSLanguagePreferences.JS); + } +} 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 index 2c216c6388..26ef149a5b 100644 --- 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 @@ -8,18 +8,11 @@ * SPDX-License-Identifier: EPL-2.0 * * Contributors: - * Angelo ZERR (Red Hat Inc.) - initial implementation + * 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 static org.eclipse.wildwebdeveloper.jsts.ui.preferences.JSTSLanguagePreferences.JS; import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.ComboFieldEditor; @@ -35,7 +28,6 @@ /** * JavaScript Inlay Hint preference page. - * */ public class JavaScriptInlayHintPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { @@ -47,40 +39,34 @@ public JavaScriptInlayHintPreferencePage() { public void createFieldEditors() { Composite parent = getFieldEditorParent(); Label label = new Label(parent, SWT.NONE); - label.setText(Messages.TypeScriptInlayHintPreferencePage_showInlayHintsFor_label); + label.setText(Messages.InlayHintPreferencePage_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(JS.inlayHints_includeInlayEnumMemberValueHints, + Messages.InlayHintPreferencePage_includeInlayEnumMemberValueHints, parent)); + addField(new BooleanFieldEditor(JS.inlayHints_includeInlayFunctionLikeReturnTypeHints, + Messages.InlayHintPreferencePage_includeInlayFunctionLikeReturnTypeHints, parent)); + addField(new BooleanFieldEditor(JS.inlayHints_includeInlayFunctionParameterTypeHints, + Messages.InlayHintPreferencePage_includeInlayFunctionParameterTypeHints, parent)); + addField(new BooleanFieldEditor(JS.inlayHints_includeInlayPropertyDeclarationTypeHints, + Messages.InlayHintPreferencePage_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 BooleanFieldEditor(JS.inlayHints_includeInlayVariableTypeHints, + Messages.InlayHintPreferencePage_includeInlayVariableTypeHints, parent)); + addField(new IndentedBooleanFieldEditor(JS.inlayHints_includeInlayVariableTypeHintsWhenTypeMatchesName, + Messages.InlayHintPreferencePage_includeInlayVariableTypeHintsWhenTypeMatchesName, parent)); - addField(new ComboFieldEditor(JAVASCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS, - Messages.TypeScriptInlayHintPreferencePage_includeInlayParameterNameHints, + addField(new ComboFieldEditor(JS.inlayHints_includeInlayParameterNameHints, + Messages.InlayHintPreferencePage_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, + { Messages.InlayHintPreferencePage_includeInlayParameterNameHints_none, "none" }, + { Messages.InlayHintPreferencePage_includeInlayParameterNameHints_literals, + "literals" }, + { Messages.InlayHintPreferencePage_includeInlayParameterNameHints_all, "all" } }, parent)); + addField(new IndentedBooleanFieldEditor(JS.inlayHints_includeInlayParameterNameHintsWhenArgumentMatchesName, + Messages.InlayHintPreferencePage_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 index d8b052d02d..b8e75bbd5d 100644 --- 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 @@ -7,21 +7,21 @@ * SPDX-License-Identifier: EPL-2.0 * * Contributors: - * Angelo ZERR (Red Hat Inc.) - initial implementation + * Angelo ZERR (Red Hat Inc.) - initial implementation *******************************************************************************/ package org.eclipse.wildwebdeveloper.jsts.ui.preferences.javascript; import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.wildwebdeveloper.jsts.ui.preferences.JSTSLanguagePreferences; /** * JavaScript preference initializer. - * */ public class JavaScriptPreferenceInitializer extends AbstractPreferenceInitializer { @Override public void initializeDefaultPreferences() { - JavaScriptPreferenceServerConstants.initializeDefaultPreferences(); + JSTSLanguagePreferences.JS.initializeDefaultPreferences(); } } \ 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 deleted file mode 100644 index 1ab70e2301..0000000000 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/javascript/JavaScriptPreferenceServerConstants.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * 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/TypeScriptCodeLensPreferencePage.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/typescript/TypeScriptCodeLensPreferencePage.java new file mode 100644 index 0000000000..53c201a00f --- /dev/null +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/typescript/TypeScriptCodeLensPreferencePage.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2025 Vegard IT GmbH 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: + * Sebastian Thomschke (Vegard IT GmbH) - initial implementation + *******************************************************************************/ +package org.eclipse.wildwebdeveloper.jsts.ui.preferences.typescript; + +import org.eclipse.wildwebdeveloper.jsts.ui.preferences.JSTSCodeLensPreferencePage; +import org.eclipse.wildwebdeveloper.jsts.ui.preferences.JSTSLanguagePreferences; + +/** + * TypeScript Code Lens preference page. + */ +public final class TypeScriptCodeLensPreferencePage extends JSTSCodeLensPreferencePage { + + public TypeScriptCodeLensPreferencePage() { + super(JSTSLanguagePreferences.TS); + } +} diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/typescript/TypeScriptFormatterPreferencePage.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/typescript/TypeScriptFormatterPreferencePage.java new file mode 100644 index 0000000000..cf9328773c --- /dev/null +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/typescript/TypeScriptFormatterPreferencePage.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2025 Vegard IT GmbH 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: + * Sebastian Thomschke (Vegard IT GmbH) - initial implementation + *******************************************************************************/ +package org.eclipse.wildwebdeveloper.jsts.ui.preferences.typescript; + +import org.eclipse.wildwebdeveloper.jsts.ui.preferences.JSTSFormatterPreferencePage; +import org.eclipse.wildwebdeveloper.jsts.ui.preferences.JSTSLanguagePreferences; + +/** + * JavaScript Inlay Hint preference page. + */ +public final class TypeScriptFormatterPreferencePage extends JSTSFormatterPreferencePage { + + public TypeScriptFormatterPreferencePage() { + super(JSTSLanguagePreferences.TS); + } +} 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 index a31551213d..649178e008 100644 --- 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 @@ -8,18 +8,11 @@ * SPDX-License-Identifier: EPL-2.0 * * Contributors: - * Angelo ZERR (Red Hat Inc.) - initial implementation + * 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 static org.eclipse.wildwebdeveloper.jsts.ui.preferences.JSTSLanguagePreferences.TS; import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.ComboFieldEditor; @@ -35,12 +28,9 @@ /** * TypeScript Inlay Hint preference page. - * */ public class TypeScriptInlayHintPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { - private int INDENT = 20; - public TypeScriptInlayHintPreferencePage() { super(GRID); } @@ -49,37 +39,32 @@ public TypeScriptInlayHintPreferencePage() { public void createFieldEditors() { Composite parent = getFieldEditorParent(); Label label = new Label(parent, SWT.NONE); - label.setText(Messages.TypeScriptInlayHintPreferencePage_showInlayHintsFor_label); + label.setText(Messages.InlayHintPreferencePage_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(TS.inlayHints_includeInlayEnumMemberValueHints, + Messages.InlayHintPreferencePage_includeInlayEnumMemberValueHints, parent)); + addField(new BooleanFieldEditor(TS.inlayHints_includeInlayFunctionLikeReturnTypeHints, + Messages.InlayHintPreferencePage_includeInlayFunctionLikeReturnTypeHints, parent)); + addField(new BooleanFieldEditor(TS.inlayHints_includeInlayFunctionParameterTypeHints, + Messages.InlayHintPreferencePage_includeInlayFunctionParameterTypeHints, parent)); + addField(new BooleanFieldEditor(TS.inlayHints_includeInlayPropertyDeclarationTypeHints, + Messages.InlayHintPreferencePage_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 BooleanFieldEditor(TS.inlayHints_includeInlayVariableTypeHints, + Messages.InlayHintPreferencePage_includeInlayVariableTypeHints, parent)); + addField(new IndentedBooleanFieldEditor(TS.inlayHints_includeInlayVariableTypeHintsWhenTypeMatchesName, + Messages.InlayHintPreferencePage_includeInlayVariableTypeHintsWhenTypeMatchesName, parent)); - addField(new ComboFieldEditor(TYPESCRIPT_PREFERENCES_INLAY_HINTS_INCLUDE_INLAY_PARAMETER_NAME_HINTS, - Messages.TypeScriptInlayHintPreferencePage_includeInlayParameterNameHints, + addField(new ComboFieldEditor(TS.inlayHints_includeInlayParameterNameHints, + Messages.InlayHintPreferencePage_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, + { Messages.InlayHintPreferencePage_includeInlayParameterNameHints_none, "none" }, + { Messages.InlayHintPreferencePage_includeInlayParameterNameHints_literals, + "literals" }, + { Messages.InlayHintPreferencePage_includeInlayParameterNameHints_all, "all" } }, parent)); + addField(new IndentedBooleanFieldEditor(TS.inlayHints_includeInlayParameterNameHintsWhenArgumentMatchesName, + Messages.InlayHintPreferencePage_includeInlayParameterNameHintsWhenArgumentMatchesName, parent)); } @Override 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 index 11418fa02f..8b063a1385 100644 --- 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 @@ -7,21 +7,21 @@ * SPDX-License-Identifier: EPL-2.0 * * Contributors: - * Angelo ZERR (Red Hat Inc.) - initial implementation + * Angelo ZERR (Red Hat Inc.) - initial implementation *******************************************************************************/ package org.eclipse.wildwebdeveloper.jsts.ui.preferences.typescript; import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.wildwebdeveloper.jsts.ui.preferences.JSTSLanguagePreferences; /** * TypeScript preference initializer. - * */ public class TypeScriptPreferenceInitializer extends AbstractPreferenceInitializer { @Override public void initializeDefaultPreferences() { - TypeScriptPreferenceServerConstants.initializeDefaultPreferences(); + JSTSLanguagePreferences.TS.initializeDefaultPreferences(); } } \ 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 deleted file mode 100644 index dc8529a72f..0000000000 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/ui/preferences/typescript/TypeScriptPreferenceServerConstants.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * 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); - } -}