Skip to content

Commit 2d024ff

Browse files
committed
Add warn when tserver-plugins is used wit hTypeScript >=2.2.1
1 parent b56d5e3 commit 2d024ff

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

eclipse/ts.eclipse.ide.core/src/ts/eclipse/ide/core/utils/TypeScriptResourceUtil.java

+4
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,10 @@ public static File getNodejsInstallPath(IProject project) throws TypeScriptExcep
444444
if (isTypeScriptProject(project)) {
445445
return getTypeScriptProject(project).getProjectSettings().getNodejsInstallPath();
446446
}
447+
return getWorkspaceNodejsInstallPath();
448+
}
449+
450+
public static File getWorkspaceNodejsInstallPath() {
447451
return IDETypeScriptProjectSettings.getWorkspaceNodejsInstallPath();
448452
}
449453

eclipse/ts.eclipse.ide.ui/src/ts/eclipse/ide/internal/ui/TypeScriptUIMessages.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ public class TypeScriptUIMessages extends NLS {
9393
public static String TypeScriptRuntimeConfigurationBlock_installedTypeScript_required_error;
9494
public static String TypeScriptRuntimeConfigurationBlock_typeScriptFile_exists_error;
9595
public static String TypeScriptRuntimeConfigurationBlock_typeScriptFile_invalid_error;
96-
96+
public static String TypeScriptRuntimeConfigurationBlock_installedTypeScript_emulatePlugins_warning;
97+
9798
// tsserver
9899
public static String TypeScriptRuntimeConfigurationBlock_traceOnConsole_label;
99100
public static String TypeScriptRuntimeConfigurationBlock_emulatePlugins_label;

eclipse/ts.eclipse.ide.ui/src/ts/eclipse/ide/internal/ui/TypeScriptUIMessages.properties

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ TypeScriptRuntimeConfigurationBlock_embeddedTypeScript_required_error=The Embedd
7878
TypeScriptRuntimeConfigurationBlock_installedTypeScript_required_error=The installed TypeScript runtime path is required.
7979
TypeScriptRuntimeConfigurationBlock_typeScriptFile_exists_error=The ''{0}'' doesn't exists.
8080
TypeScriptRuntimeConfigurationBlock_typeScriptFile_invalid_error=The ''{0}'' is not a TypeScript Runtime.
81+
TypeScriptRuntimeConfigurationBlock_installedTypeScript_emulatePlugins_warning=No need to emulate plugins since TypeScript 2.2.1 support it.
8182

8283
# Formatter
8384
FormatterConfigurationBlock_editorOptions_group_label=Editor options

eclipse/ts.eclipse.ide.ui/src/ts/eclipse/ide/internal/ui/preferences/TypeScriptRuntimeConfigurationBlock.java

+18-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414

1515
import org.eclipse.core.resources.IProject;
1616
import org.eclipse.core.runtime.IStatus;
17+
import org.eclipse.core.runtime.Status;
1718
import org.eclipse.osgi.util.NLS;
1819
import org.eclipse.swt.SWT;
1920
import org.eclipse.swt.layout.GridData;
2021
import org.eclipse.swt.layout.GridLayout;
22+
import org.eclipse.swt.widgets.Button;
2123
import org.eclipse.swt.widgets.Composite;
2224
import org.eclipse.swt.widgets.Label;
2325
import org.eclipse.swt.widgets.Text;
@@ -34,6 +36,7 @@
3436
import ts.repository.TypeScriptRepositoryManager;
3537
import ts.utils.FileUtils;
3638
import ts.utils.StringUtils;
39+
import ts.utils.VersionHelper;
3740

3841
/**
3942
* TypeScript Runtime configuration block.
@@ -56,6 +59,7 @@ public class TypeScriptRuntimeConfigurationBlock extends AbstractTypeScriptRepos
5659

5760
private Text tsRuntimePath;
5861
private Text tsRuntimeVersion;
62+
private Button emulatePlugins;
5963

6064
public TypeScriptRuntimeConfigurationBlock(IStatusChangeListener context, IProject project,
6165
IWorkbenchPreferenceContainer container) {
@@ -67,7 +71,8 @@ protected void createBody(Composite parent) {
6771
super.createBody(parent);
6872
super.addCheckBox(parent, TypeScriptUIMessages.TypeScriptRuntimeConfigurationBlock_traceOnConsole_label,
6973
PREF_TSSERVER_TRACE_ON_CONSOLE, new String[] { "true", "false" }, 0);
70-
super.addCheckBox(parent, TypeScriptUIMessages.TypeScriptRuntimeConfigurationBlock_emulatePlugins_label,
74+
emulatePlugins = super.addCheckBox(parent,
75+
TypeScriptUIMessages.TypeScriptRuntimeConfigurationBlock_emulatePlugins_label,
7176
PREF_TSSERVER_EMULATE_PLUGINS, new String[] { "true", "false" }, 0);
7277
createTypeScriptRuntimeInfo(parent.getParent());
7378
}
@@ -172,7 +177,7 @@ public String getTsVersion() {
172177
*
173178
* @return the validation status of the TypeScript path.
174179
*/
175-
private IStatus validateAndUpdateTsRuntimePath() {
180+
private TypeScriptRuntimeStatus validateAndUpdateTsRuntimePath() {
176181
// Compute runtime status
177182
TypeScriptRuntimeStatus status = validateTsRuntimePath();
178183
// Update TypeScript version & path
@@ -240,6 +245,17 @@ private TypeScriptRuntimeStatus validateTsRuntimePath() {
240245
@Override
241246
protected void validateSettings(Key changedKey, String oldValue, String newValue) {
242247
IStatus status = validateAndUpdateTsRuntimePath();
248+
if (status.isOK()) {
249+
status = validateUseOfTsserverPlugins(((TypeScriptRuntimeStatus) status).getTsVersion());
250+
}
243251
fContext.statusChanged(status);
244252
}
253+
254+
private IStatus validateUseOfTsserverPlugins(String tsVersion) {
255+
if (emulatePlugins.getSelection() && VersionHelper.canSupport(tsVersion, "2.2.1")) {
256+
return new StatusInfo(IStatus.WARNING,
257+
TypeScriptUIMessages.TypeScriptRuntimeConfigurationBlock_installedTypeScript_emulatePlugins_warning);
258+
}
259+
return Status.OK_STATUS;
260+
}
245261
}

0 commit comments

Comments
 (0)