TypeScript builder adoption

This commit is contained in:
Dirk Baeumer
2016-06-17 19:03:04 +02:00
parent faf853a232
commit a4aeaa1d67
9 changed files with 107 additions and 13 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,13 +214,24 @@ export default class BufferSyncSupport {
}
public requestDiagnostic(file: string): void {
if (!!true) {
return;
}
if (!this._validate) {
return;
}
this.pendingDiagnostics[file] = Date.now();
this.diagnosticDelayer.trigger(() => {
this.sendPendingDiagnostics();
});
if (!this.projectValidationRequested) {
this.client.execute('geterrForProject' , {
file: file,
delay: -1,
watch: true
}, false);
this.projectValidationRequested = true;
}
// this.pendingDiagnostics[file] = Date.now();
// this.diagnosticDelayer.trigger(() => {
// this.sendPendingDiagnostics();
// });
}
private sendPendingDiagnostics(): void {

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.
*/

View File

@@ -63,7 +63,7 @@ export function activate(context: ExtensionContext): void {
modeIds: [MODE_ID_JS, MODE_ID_JSX],
extensions: ['.js', '.jsx']
}
]);
], context.storagePath);
let client = clientHost.serviceClient;
@@ -285,7 +285,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 +300,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 => {

View File

@@ -68,6 +68,7 @@ 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; };
@@ -90,8 +91,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) => {
@@ -201,7 +203,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 +241,10 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
}
private serviceStarted(resendModels: boolean): void {
this.execute('configure', {
autoBuild: this.storagePath ? true : false,
metaDataDirectory: this.storagePath
});
if (resendModels) {
this.host.populateService();
}