Merge branch 'dbaeumer/TS9125'

This commit is contained in:
Dirk Baeumer
2016-06-23 13:38:45 +02:00
13 changed files with 158 additions and 17 deletions

View File

@@ -85,6 +85,8 @@ export default class BufferSyncSupport {
private syncedBuffers: Map<SyncedBuffer>;
private closedFiles: Map<boolean>;
private projectValidationRequested: boolean;
private pendingDiagnostics: { [key: string]: number; };
private diagnosticDelayer: Delayer<any>;
@@ -96,6 +98,8 @@ export default class BufferSyncSupport {
this.extensions = extensions;
this._validate = validate;
this.projectValidationRequested = false;
this.pendingDiagnostics = Object.create(null);
this.diagnosticDelayer = new Delayer<any>(100);
@@ -210,9 +214,10 @@ export default class BufferSyncSupport {
}
public requestDiagnostic(file: string): void {
if (!this._validate) {
if (!this._validate || this.client.experimentalAutoBuild) {
return;
}
this.pendingDiagnostics[file] = Date.now();
this.diagnosticDelayer.trigger(() => {
this.sendPendingDiagnostics();

View File

@@ -484,6 +484,19 @@ export interface ConfigureRequestArguments {
*/
hostInfo?: string;
/**
* Sets a folder that can be used by the tsserver to store
* meta data information.
*/
metaDataDirectory?: string;
/**
* Turns the tsserver into auto diagnostice mode. When in
* auto diagnostic mode the server will automatically generate
* diagnostics and send them to the client without requests
*/
autoDiagnostics?: boolean;
/**
* If present, tab settings apply only to this file.
*/
@@ -996,6 +1009,11 @@ export interface DiagnosticEventBody {
* An array of diagnostic information items.
*/
diagnostics: Diagnostic[];
/**
* Information about the current length of the build queue.
*/
queueLength?: number;
}
/**

View File

@@ -19,6 +19,9 @@ nls.config({locale: env.language});
import * as path from 'path';
import * as Proto from './protocol';
import * as Is from './utils/is';
import TypeScriptServiceClient from './typescriptServiceClient';
import { ITypescriptServiceClientHost } from './typescriptService';
@@ -36,6 +39,7 @@ import WorkspaceSymbolProvider from './features/workspaceSymbolProvider';
import * as VersionStatus from './utils/versionStatus';
import * as ProjectStatus from './utils/projectStatus';
import * as BuildStatus from './utils/buildStatus';
interface LanguageDescription {
id: string;
@@ -63,7 +67,7 @@ export function activate(context: ExtensionContext): void {
modeIds: [MODE_ID_JS, MODE_ID_JSX],
extensions: ['.js', '.jsx']
}
]);
], context.storagePath);
let client = clientHost.serviceClient;
@@ -83,6 +87,7 @@ export function activate(context: ExtensionContext): void {
}, () => {
// Nothing to do here. The client did show a message;
});
BuildStatus.update({ queueLength: 0 });
}
const validateSetting = 'validate.enable';
@@ -285,7 +290,7 @@ class TypeScriptServiceClientHost implements ITypescriptServiceClientHost {
private languages: LanguageProvider[];
private languagePerId: Map<LanguageProvider>;
constructor(descriptions: LanguageDescription[]) {
constructor(descriptions: LanguageDescription[], storagePath: string) {
let handleProjectCreateOrDelete = () => {
this.client.execute('reloadProjects', null, false);
this.triggerAllDiagnostics();
@@ -300,7 +305,7 @@ class TypeScriptServiceClientHost implements ITypescriptServiceClientHost {
watcher.onDidDelete(handleProjectCreateOrDelete);
watcher.onDidChange(handleProjectChange);
this.client = new TypeScriptServiceClient(this);
this.client = new TypeScriptServiceClient(this, storagePath);
this.languages = [];
this.languagePerId = Object.create(null);
descriptions.forEach(description => {
@@ -362,6 +367,9 @@ class TypeScriptServiceClientHost implements ITypescriptServiceClientHost {
language.semanticDiagnosticsReceived(body.file, this.createMarkerDatas(body.diagnostics, language.diagnosticSource));
}
}
if (Is.defined(body.queueLength)) {
BuildStatus.update( { queueLength: body.queueLength });
}
}
private createMarkerDatas(diagnostics: Proto.Diagnostic[], source: string): Diagnostic[] {

View File

@@ -20,6 +20,8 @@ export interface ITypescriptServiceClient {
logTelemetry(eventName: string, properties?: { [prop: string]: string });
experimentalAutoBuild: boolean;
execute(command:'configure', args: Proto.ConfigureRequestArguments, token?: CancellationToken):Promise<Proto.ConfigureResponse>;
execute(command:'open', args: Proto.OpenRequestArgs, expectedResult:boolean, token?: CancellationToken):Promise<any>;
execute(command:'close', args: Proto.FileRequestArgs, expectedResult:boolean, token?: CancellationToken):Promise<any>;

View File

@@ -68,10 +68,12 @@ namespace Trace {
export default class TypeScriptServiceClient implements ITypescriptServiceClient {
private host: ITypescriptServiceClientHost;
private storagePath: string;
private pathSeparator: string;
private _onReady: { promise: Promise<void>; resolve: () => void; reject: () => void; };
private tsdk: string;
private _experimentalAutoBuild: boolean;
private trace: Trace;
private output: OutputChannel;
private servicePromise: Promise<cp.ChildProcess>;
@@ -90,8 +92,9 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
private _packageInfo: IPackageInfo;
private telemetryReporter: TelemetryReporter;
constructor(host: ITypescriptServiceClientHost) {
constructor(host: ITypescriptServiceClientHost, storagePath: string) {
this.host = host;
this.storagePath = storagePath;
this.pathSeparator = path.sep;
let p = new Promise<void>((resolve, reject) => {
@@ -109,7 +112,9 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
this.requestQueue = [];
this.pendingResponses = 0;
this.callbacks = Object.create(null);
this.tsdk = workspace.getConfiguration().get<string>('typescript.tsdk', null);
const configuration = workspace.getConfiguration();
this.tsdk = configuration.get<string>('typescript.tsdk', null);
this._experimentalAutoBuild = configuration.get<boolean>('typescript.tsserver.experimentalAutoBuild', false);
this.trace = this.readTrace();
workspace.onDidChangeConfiguration(() => {
this.trace = this.readTrace();
@@ -136,6 +141,10 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
return result;
}
public get experimentalAutoBuild(): boolean {
return this._experimentalAutoBuild;
}
public onReady(): Promise<void> {
return this._onReady.promise;
}
@@ -201,7 +210,7 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
this.servicePromise = new Promise<cp.ChildProcess>((resolve, reject) => {
try {
let options: electron.IForkOptions = {
execArgv: [] //[`--debug-brk=5859`]
execArgv: [`--debug-brk=5859`]
};
let value = process.env.TSS_DEBUG;
if (value) {
@@ -239,6 +248,16 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
}
private serviceStarted(resendModels: boolean): void {
if (this._experimentalAutoBuild && this.storagePath) {
try {
fs.mkdirSync(this.storagePath);
} catch(error) {
}
this.execute('configure', {
autoBuild: true,
metaDataDirectory: this.storagePath
});
}
if (resendModels) {
this.host.populateService();
}

View File

@@ -0,0 +1,23 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import vscode = require('vscode');
const statusItem: vscode.StatusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, Number.MIN_VALUE);
export interface BuildInfo {
queueLength: number;
}
export function update(info: BuildInfo): void {
if (info.queueLength === 0) {
statusItem.hide();
return;
}
statusItem.text = info.queueLength.toString();
statusItem.show();
}