Skip to content

Commit

Permalink
Add warn when tserver-plugins is used wit hTypeScript >=2.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
angelozerr committed Apr 12, 2017
1 parent b56d5e3 commit 2d024ff
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,10 @@ public static File getNodejsInstallPath(IProject project) throws TypeScriptExcep
if (isTypeScriptProject(project)) {
return getTypeScriptProject(project).getProjectSettings().getNodejsInstallPath();
}
return getWorkspaceNodejsInstallPath();
}

public static File getWorkspaceNodejsInstallPath() {
return IDETypeScriptProjectSettings.getWorkspaceNodejsInstallPath();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ public class TypeScriptUIMessages extends NLS {
public static String TypeScriptRuntimeConfigurationBlock_installedTypeScript_required_error;
public static String TypeScriptRuntimeConfigurationBlock_typeScriptFile_exists_error;
public static String TypeScriptRuntimeConfigurationBlock_typeScriptFile_invalid_error;

public static String TypeScriptRuntimeConfigurationBlock_installedTypeScript_emulatePlugins_warning;

// tsserver
public static String TypeScriptRuntimeConfigurationBlock_traceOnConsole_label;
public static String TypeScriptRuntimeConfigurationBlock_emulatePlugins_label;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ TypeScriptRuntimeConfigurationBlock_embeddedTypeScript_required_error=The Embedd
TypeScriptRuntimeConfigurationBlock_installedTypeScript_required_error=The installed TypeScript runtime path is required.
TypeScriptRuntimeConfigurationBlock_typeScriptFile_exists_error=The ''{0}'' doesn't exists.
TypeScriptRuntimeConfigurationBlock_typeScriptFile_invalid_error=The ''{0}'' is not a TypeScript Runtime.
TypeScriptRuntimeConfigurationBlock_installedTypeScript_emulatePlugins_warning=No need to emulate plugins since TypeScript 2.2.1 support it.

# Formatter
FormatterConfigurationBlock_editorOptions_group_label=Editor options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
Expand All @@ -34,6 +36,7 @@
import ts.repository.TypeScriptRepositoryManager;
import ts.utils.FileUtils;
import ts.utils.StringUtils;
import ts.utils.VersionHelper;

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

private Text tsRuntimePath;
private Text tsRuntimeVersion;
private Button emulatePlugins;

public TypeScriptRuntimeConfigurationBlock(IStatusChangeListener context, IProject project,
IWorkbenchPreferenceContainer container) {
Expand All @@ -67,7 +71,8 @@ protected void createBody(Composite parent) {
super.createBody(parent);
super.addCheckBox(parent, TypeScriptUIMessages.TypeScriptRuntimeConfigurationBlock_traceOnConsole_label,
PREF_TSSERVER_TRACE_ON_CONSOLE, new String[] { "true", "false" }, 0);
super.addCheckBox(parent, TypeScriptUIMessages.TypeScriptRuntimeConfigurationBlock_emulatePlugins_label,
emulatePlugins = super.addCheckBox(parent,
TypeScriptUIMessages.TypeScriptRuntimeConfigurationBlock_emulatePlugins_label,
PREF_TSSERVER_EMULATE_PLUGINS, new String[] { "true", "false" }, 0);
createTypeScriptRuntimeInfo(parent.getParent());
}
Expand Down Expand Up @@ -172,7 +177,7 @@ public String getTsVersion() {
*
* @return the validation status of the TypeScript path.
*/
private IStatus validateAndUpdateTsRuntimePath() {
private TypeScriptRuntimeStatus validateAndUpdateTsRuntimePath() {
// Compute runtime status
TypeScriptRuntimeStatus status = validateTsRuntimePath();
// Update TypeScript version & path
Expand Down Expand Up @@ -240,6 +245,17 @@ private TypeScriptRuntimeStatus validateTsRuntimePath() {
@Override
protected void validateSettings(Key changedKey, String oldValue, String newValue) {
IStatus status = validateAndUpdateTsRuntimePath();
if (status.isOK()) {
status = validateUseOfTsserverPlugins(((TypeScriptRuntimeStatus) status).getTsVersion());
}
fContext.statusChanged(status);
}

private IStatus validateUseOfTsserverPlugins(String tsVersion) {
if (emulatePlugins.getSelection() && VersionHelper.canSupport(tsVersion, "2.2.1")) {
return new StatusInfo(IStatus.WARNING,
TypeScriptUIMessages.TypeScriptRuntimeConfigurationBlock_installedTypeScript_emulatePlugins_warning);
}
return Status.OK_STATUS;
}
}

0 comments on commit 2d024ff

Please sign in to comment.