mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-28 04:23:32 +01:00
tsfmt - extensions/typescript
This commit is contained in:
@@ -14,7 +14,7 @@ export default class TypeScriptReferenceSupport implements ReferenceProvider {
|
||||
|
||||
private client: ITypescriptServiceClient;
|
||||
|
||||
public tokens:string[] = [];
|
||||
public tokens: string[] = [];
|
||||
|
||||
public constructor(client: ITypescriptServiceClient) {
|
||||
this.client = client;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
import { workspace, window, Uri, WorkspaceSymbolProvider, SymbolInformation, SymbolKind, Range, Location, CancellationToken } from 'vscode';
|
||||
|
||||
import * as Proto from '../protocol';
|
||||
import * as Proto from '../protocol';
|
||||
import { ITypescriptServiceClient } from '../typescriptService';
|
||||
|
||||
let _kindMapping: { [kind: string]: SymbolKind } = Object.create(null);
|
||||
@@ -28,7 +28,7 @@ export default class TypeScriptWorkspaceSymbolProvider implements WorkspaceSymbo
|
||||
this.modeId = modeId;
|
||||
}
|
||||
|
||||
public provideWorkspaceSymbols(search: string, token :CancellationToken): Promise<SymbolInformation[]> {
|
||||
public provideWorkspaceSymbols(search: string, token: CancellationToken): Promise<SymbolInformation[]> {
|
||||
// typescript wants to have a resource even when asking
|
||||
// general questions so we check the active editor. If this
|
||||
// doesn't match we take the first TS document.
|
||||
@@ -54,14 +54,14 @@ export default class TypeScriptWorkspaceSymbolProvider implements WorkspaceSymbo
|
||||
return Promise.resolve<SymbolInformation[]>([]);
|
||||
}
|
||||
|
||||
let args:Proto.NavtoRequestArgs = {
|
||||
let args: Proto.NavtoRequestArgs = {
|
||||
file: this.client.asAbsolutePath(uri),
|
||||
searchValue: search
|
||||
};
|
||||
if (!args.file) {
|
||||
return Promise.resolve<SymbolInformation[]>([]);
|
||||
}
|
||||
return this.client.execute('navto', args, token).then((response):SymbolInformation[] => {
|
||||
return this.client.execute('navto', args, token).then((response): SymbolInformation[] => {
|
||||
let data = response.body;
|
||||
if (data) {
|
||||
let result: SymbolInformation[] = [];
|
||||
|
||||
@@ -6,42 +6,42 @@
|
||||
'use strict';
|
||||
|
||||
export class Kind {
|
||||
public static unknown:string = '';
|
||||
public static keyword:string = 'keyword';
|
||||
public static script:string = 'script';
|
||||
public static module:string = 'module';
|
||||
public static class:string = 'class';
|
||||
public static interface:string = 'interface';
|
||||
public static type:string = 'type';
|
||||
public static enum:string = 'enum';
|
||||
public static variable:string = 'var';
|
||||
public static localVariable:string = 'local var';
|
||||
public static function:string = 'function';
|
||||
public static localFunction:string = 'local function';
|
||||
public static memberFunction:string = 'method';
|
||||
public static memberGetAccessor:string = 'getter';
|
||||
public static memberSetAccessor:string = 'setter';
|
||||
public static memberVariable:string = 'property';
|
||||
public static constructorImplementation:string = 'constructor';
|
||||
public static callSignature:string = 'call';
|
||||
public static indexSignature:string = 'index';
|
||||
public static constructSignature:string = 'construct';
|
||||
public static parameter:string = 'parameter';
|
||||
public static typeParameter:string = 'type parameter';
|
||||
public static primitiveType:string = 'primitive type';
|
||||
public static label:string = 'label';
|
||||
public static alias:string = 'alias';
|
||||
public static const:string = 'const';
|
||||
public static let:string = 'let';
|
||||
public static warning:string = 'warning';
|
||||
public static unknown: string = '';
|
||||
public static keyword: string = 'keyword';
|
||||
public static script: string = 'script';
|
||||
public static module: string = 'module';
|
||||
public static class: string = 'class';
|
||||
public static interface: string = 'interface';
|
||||
public static type: string = 'type';
|
||||
public static enum: string = 'enum';
|
||||
public static variable: string = 'var';
|
||||
public static localVariable: string = 'local var';
|
||||
public static function: string = 'function';
|
||||
public static localFunction: string = 'local function';
|
||||
public static memberFunction: string = 'method';
|
||||
public static memberGetAccessor: string = 'getter';
|
||||
public static memberSetAccessor: string = 'setter';
|
||||
public static memberVariable: string = 'property';
|
||||
public static constructorImplementation: string = 'constructor';
|
||||
public static callSignature: string = 'call';
|
||||
public static indexSignature: string = 'index';
|
||||
public static constructSignature: string = 'construct';
|
||||
public static parameter: string = 'parameter';
|
||||
public static typeParameter: string = 'type parameter';
|
||||
public static primitiveType: string = 'primitive type';
|
||||
public static label: string = 'label';
|
||||
public static alias: string = 'alias';
|
||||
public static const: string = 'const';
|
||||
public static let: string = 'let';
|
||||
public static warning: string = 'warning';
|
||||
}
|
||||
|
||||
export class KindModifier {
|
||||
public static none:string = '';
|
||||
public static staticMember:string = 'public static';
|
||||
public static privateMember:string = 'private';
|
||||
public static protectedMember:string = 'protected';
|
||||
public static exported:string = 'export';
|
||||
public static ambient:string = 'declare';
|
||||
public static static:string = 'static';
|
||||
public static none: string = '';
|
||||
public static staticMember: string = 'public static';
|
||||
public static privateMember: string = 'private';
|
||||
public static protectedMember: string = 'protected';
|
||||
public static exported: string = 'export';
|
||||
public static ambient: string = 'declare';
|
||||
public static static: string = 'static';
|
||||
}
|
||||
1620
extensions/typescript/src/protocol.d.ts
vendored
1620
extensions/typescript/src/protocol.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@@ -14,7 +14,7 @@ import { env, languages, commands, workspace, window, Uri, ExtensionContext, Mem
|
||||
// This must be the first statement otherwise modules might got loaded with
|
||||
// the wrong locale.
|
||||
import * as nls from 'vscode-nls';
|
||||
nls.config({locale: env.language});
|
||||
nls.config({ locale: env.language });
|
||||
|
||||
import * as path from 'path';
|
||||
|
||||
@@ -350,7 +350,7 @@ class TypeScriptServiceClientHost implements ITypescriptServiceClientHost {
|
||||
}
|
||||
}
|
||||
if (Is.defined(body.queueLength)) {
|
||||
BuildStatus.update( { queueLength: body.queueLength });
|
||||
BuildStatus.update({ queueLength: body.queueLength });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,25 +55,25 @@ export interface ITypescriptServiceClient {
|
||||
experimentalAutoBuild: boolean;
|
||||
apiVersion: APIVersion;
|
||||
|
||||
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>;
|
||||
execute(command: 'change', args: Proto.ChangeRequestArgs, expectedResult:boolean, token?: CancellationToken):Promise<any>;
|
||||
execute(command: 'geterr', args: Proto.GeterrRequestArgs, expectedResult:boolean, token?: CancellationToken):Promise<any>;
|
||||
execute(command: 'quickinfo', args: Proto.FileLocationRequestArgs, token?: CancellationToken):Promise<Proto.QuickInfoResponse>;
|
||||
execute(command: 'completions', args: Proto.CompletionsRequestArgs, token?: CancellationToken):Promise<Proto.CompletionsResponse>;
|
||||
execute(commant: 'completionEntryDetails', args: Proto.CompletionDetailsRequestArgs, token?: CancellationToken):Promise<Proto.CompletionDetailsResponse>;
|
||||
execute(commant: 'signatureHelp', args: Proto.SignatureHelpRequestArgs, token?: CancellationToken):Promise<Proto.SignatureHelpResponse>;
|
||||
execute(command: 'definition', args: Proto.FileLocationRequestArgs, token?: CancellationToken):Promise<Proto.DefinitionResponse>;
|
||||
execute(command: 'references', args: Proto.FileLocationRequestArgs, token?: CancellationToken):Promise<Proto.ReferencesResponse>;
|
||||
execute(command: 'navto', args: Proto.NavtoRequestArgs, token?: CancellationToken):Promise<Proto.NavtoResponse>;
|
||||
execute(command: 'navbar', args: Proto.FileRequestArgs, token?: CancellationToken):Promise<Proto.NavBarResponse>;
|
||||
execute(command: 'format', args: Proto.FormatRequestArgs, token?: CancellationToken):Promise<Proto.FormatResponse>;
|
||||
execute(command: 'formatonkey', args: Proto.FormatOnKeyRequestArgs, token?: CancellationToken):Promise<Proto.FormatResponse>;
|
||||
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>;
|
||||
execute(command: 'change', args: Proto.ChangeRequestArgs, expectedResult: boolean, token?: CancellationToken): Promise<any>;
|
||||
execute(command: 'geterr', args: Proto.GeterrRequestArgs, expectedResult: boolean, token?: CancellationToken): Promise<any>;
|
||||
execute(command: 'quickinfo', args: Proto.FileLocationRequestArgs, token?: CancellationToken): Promise<Proto.QuickInfoResponse>;
|
||||
execute(command: 'completions', args: Proto.CompletionsRequestArgs, token?: CancellationToken): Promise<Proto.CompletionsResponse>;
|
||||
execute(commant: 'completionEntryDetails', args: Proto.CompletionDetailsRequestArgs, token?: CancellationToken): Promise<Proto.CompletionDetailsResponse>;
|
||||
execute(commant: 'signatureHelp', args: Proto.SignatureHelpRequestArgs, token?: CancellationToken): Promise<Proto.SignatureHelpResponse>;
|
||||
execute(command: 'definition', args: Proto.FileLocationRequestArgs, token?: CancellationToken): Promise<Proto.DefinitionResponse>;
|
||||
execute(command: 'references', args: Proto.FileLocationRequestArgs, token?: CancellationToken): Promise<Proto.ReferencesResponse>;
|
||||
execute(command: 'navto', args: Proto.NavtoRequestArgs, token?: CancellationToken): Promise<Proto.NavtoResponse>;
|
||||
execute(command: 'navbar', args: Proto.FileRequestArgs, token?: CancellationToken): Promise<Proto.NavBarResponse>;
|
||||
execute(command: 'format', args: Proto.FormatRequestArgs, token?: CancellationToken): Promise<Proto.FormatResponse>;
|
||||
execute(command: 'formatonkey', args: Proto.FormatOnKeyRequestArgs, token?: CancellationToken): Promise<Proto.FormatResponse>;
|
||||
execute(command: 'rename', args: Proto.RenameRequestArgs, token?: CancellationToken): Promise<Proto.RenameResponse>;
|
||||
execute(command: 'occurrences', args: Proto.FileLocationRequestArgs, token?: CancellationToken): Promise<Proto.OccurrencesResponse>;
|
||||
execute(command: 'projectInfo', args: Proto.ProjectInfoRequestArgs, token?: CancellationToken): Promise<Proto.ProjectInfoResponse>;
|
||||
execute(command: 'reloadProjects', args: any, expectedResult:boolean, token?: CancellationToken): Promise<any>;
|
||||
execute(command: 'reloadProjects', args: any, expectedResult: boolean, token?: CancellationToken): Promise<any>;
|
||||
execute(command: 'reload', args: Proto.ReloadRequestArgs, expectedResult: boolean, token?: CancellationToken): Promise<any>;
|
||||
execute(command: string, args: any, expectedResult: boolean | CancellationToken, token?: CancellationToken): Promise<any>;
|
||||
}
|
||||
@@ -12,9 +12,9 @@ import * as fs from 'fs';
|
||||
import * as electron from './utils/electron';
|
||||
import { Reader } from './utils/wireProtocol';
|
||||
|
||||
import { workspace, window, Uri, CancellationToken, OutputChannel, Memento, MessageItem } from 'vscode';
|
||||
import { workspace, window, Uri, CancellationToken, OutputChannel, Memento, MessageItem } from 'vscode';
|
||||
import * as Proto from './protocol';
|
||||
import { ITypescriptServiceClient, ITypescriptServiceClientHost, APIVersion } from './typescriptService';
|
||||
import { ITypescriptServiceClient, ITypescriptServiceClientHost, APIVersion } from './typescriptService';
|
||||
|
||||
import * as VersionStatus from './utils/versionStatus';
|
||||
import * as is from './utils/is';
|
||||
@@ -73,7 +73,7 @@ enum MessageAction {
|
||||
close
|
||||
}
|
||||
|
||||
interface MyMessageItem extends MessageItem {
|
||||
interface MyMessageItem extends MessageItem {
|
||||
id: MessageAction;
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
|
||||
return this._packageInfo;
|
||||
}
|
||||
|
||||
public logTelemetry(eventName: string, properties?: {[prop: string]: string}) {
|
||||
public logTelemetry(eventName: string, properties?: { [prop: string]: string }) {
|
||||
if (this.telemetryReporter) {
|
||||
this.telemetryReporter.sendTelemetryEvent(eventName, properties);
|
||||
}
|
||||
@@ -337,7 +337,7 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
|
||||
if (!selected || selected.id === MessageAction.close) {
|
||||
return modulePath;
|
||||
}
|
||||
switch(selected.id) {
|
||||
switch (selected.id) {
|
||||
case MessageAction.useLocal:
|
||||
let pathValue = './node_modules/typescript/lib';
|
||||
tsConfig.update('tsdk', pathValue, false);
|
||||
@@ -381,7 +381,7 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
|
||||
}
|
||||
|
||||
|
||||
const label = version || localize('versionNumber.custom' ,'custom');
|
||||
const label = version || localize('versionNumber.custom', 'custom');
|
||||
const tooltip = modulePath;
|
||||
VersionStatus.enable(!!this.tsdk || showVersionStatusItem);
|
||||
VersionStatus.setInfo(label, tooltip);
|
||||
@@ -459,7 +459,7 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
|
||||
this.lastError = err;
|
||||
this.error('Starting TSServer failed with error.', err);
|
||||
window.showErrorMessage(localize('serverCouldNotBeStarted', 'TypeScript language server couldn\'t be started. Error message is: {0}', err.message || err));
|
||||
this.logTelemetry('error', {message: err.message});
|
||||
this.logTelemetry('error', { message: err.message });
|
||||
return;
|
||||
}
|
||||
this.lastStart = Date.now();
|
||||
@@ -494,7 +494,7 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
|
||||
if (this._experimentalAutoBuild && this.storagePath) {
|
||||
try {
|
||||
fs.mkdirSync(this.storagePath);
|
||||
} catch(error) {
|
||||
} catch (error) {
|
||||
}
|
||||
this.execute('configure', {
|
||||
autoBuild: true,
|
||||
@@ -521,7 +521,7 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
|
||||
let desc = null;
|
||||
try {
|
||||
desc = JSON.parse(contents);
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
return undefined;
|
||||
}
|
||||
if (!desc.version) {
|
||||
@@ -542,7 +542,7 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
|
||||
let startService = true;
|
||||
if (this.numberRestarts > 5) {
|
||||
if (diff < 60 * 1000 /* 1 Minutes */) {
|
||||
window.showWarningMessage(localize('serverDied','The TypeScript language service died unexpectedly 5 times in the last 5 Minutes. Please consider to open a bug report.'));
|
||||
window.showWarningMessage(localize('serverDied', 'The TypeScript language service died unexpectedly 5 times in the last 5 Minutes. Please consider to open a bug report.'));
|
||||
} else if (diff < 2 * 1000 /* 2 seconds */) {
|
||||
startService = false;
|
||||
window.showErrorMessage(localize('serverDiedAfterStart', 'The TypeScript language service died 5 times right after it got started. The service will not be restarted. Please open a bug report.'));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
declare module 'vscode-extension-telemetry' {
|
||||
export default class TelemetryReporter {
|
||||
constructor(extensionId: string,extensionVersion: string, key: string);
|
||||
constructor(extensionId: string, extensionVersion: string, key: string);
|
||||
sendTelemetryEvent(eventName: string, properties?: { [key: string]: string }, measures?: { [key: string]: number }): void;
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ export interface IForkOptions {
|
||||
execArgv?: string[];
|
||||
}
|
||||
|
||||
function makeRandomHexString(length:number): string {
|
||||
function makeRandomHexString(length: number): string {
|
||||
let chars = ['0', '1', '2', '3', '4', '5', '6', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
|
||||
let result = '';
|
||||
for (let i = 0; i < length; i++) {
|
||||
@@ -37,10 +37,10 @@ function generatePipeName(): string {
|
||||
return path.join(os.tmpdir(), randomName + '.sock');
|
||||
}
|
||||
|
||||
function generatePatchedEnv(env:any, stdInPipeName:string, stdOutPipeName:string, stdErrPipeName:string): any {
|
||||
function generatePatchedEnv(env: any, stdInPipeName: string, stdOutPipeName: string, stdErrPipeName: string): any {
|
||||
// Set the two unique pipe names and the electron flag as process env
|
||||
|
||||
var newEnv:any = {};
|
||||
var newEnv: any = {};
|
||||
for (var key in env) {
|
||||
newEnv[key] = env[key];
|
||||
}
|
||||
@@ -53,7 +53,7 @@ function generatePatchedEnv(env:any, stdInPipeName:string, stdOutPipeName:string
|
||||
return newEnv;
|
||||
}
|
||||
|
||||
export function fork(modulePath: string, args: string[], options: IForkOptions, callback:(error:any, cp:cp.ChildProcess)=>void): void {
|
||||
export function fork(modulePath: string, args: string[], options: IForkOptions, callback: (error: any, cp: cp.ChildProcess) => void): void {
|
||||
|
||||
var callbackCalled = false;
|
||||
var resolve = (result: cp.ChildProcess) => {
|
||||
@@ -63,7 +63,7 @@ export function fork(modulePath: string, args: string[], options: IForkOptions,
|
||||
callbackCalled = true;
|
||||
callback(null, result);
|
||||
};
|
||||
var reject = (err:any) => {
|
||||
var reject = (err: any) => {
|
||||
if (callbackCalled) {
|
||||
return;
|
||||
}
|
||||
@@ -92,7 +92,7 @@ export function fork(modulePath: string, args: string[], options: IForkOptions,
|
||||
let stdOutServer = net.createServer((stdOutStream) => {
|
||||
// The child process will write exactly one chunk with content `ready` when it has installed a listener to the stdin pipe
|
||||
|
||||
stdOutStream.once('data', (chunk:Buffer) => {
|
||||
stdOutStream.once('data', (chunk: Buffer) => {
|
||||
// The child process is sending me the `ready` chunk, time to connect to the stdin pipe
|
||||
childProcess.stdin = <any>net.connect(stdInPipeName);
|
||||
|
||||
@@ -123,12 +123,12 @@ export function fork(modulePath: string, args: string[], options: IForkOptions,
|
||||
execArgv: options.execArgv
|
||||
});
|
||||
|
||||
childProcess.once('error', (err:Error) => {
|
||||
childProcess.once('error', (err: Error) => {
|
||||
closeServer();
|
||||
reject(err);
|
||||
});
|
||||
|
||||
childProcess.once('exit', (err:Error) => {
|
||||
childProcess.once('exit', (err: Error) => {
|
||||
closeServer();
|
||||
reject(err);
|
||||
});
|
||||
|
||||
@@ -8,9 +8,9 @@ var net = require('net'),
|
||||
|
||||
var ENABLE_LOGGING = false;
|
||||
|
||||
var log = (function() {
|
||||
var log = (function () {
|
||||
if (!ENABLE_LOGGING) {
|
||||
return function() {};
|
||||
return function () { };
|
||||
}
|
||||
var isFirst = true;
|
||||
var LOG_LOCATION = 'C:\\stdFork.log';
|
||||
@@ -34,7 +34,7 @@ log('STDERR_PIPE_NAME: ' + stdErrPipeName);
|
||||
log('ELECTRON_RUN_AS_NODE: ' + process.env['ELECTRON_RUN_AS_NODE']);
|
||||
|
||||
// stdout redirection to named pipe
|
||||
(function() {
|
||||
(function () {
|
||||
log('Beginning stdout redirection...');
|
||||
|
||||
// Create a writing stream to the stdout pipe
|
||||
@@ -44,7 +44,7 @@ log('ELECTRON_RUN_AS_NODE: ' + process.env['ELECTRON_RUN_AS_NODE']);
|
||||
stdOutStream.unref();
|
||||
|
||||
// handle process.stdout
|
||||
(<any>process).__defineGetter__('stdout', function() { return stdOutStream; });
|
||||
(<any>process).__defineGetter__('stdout', function () { return stdOutStream; });
|
||||
|
||||
// Create a writing stream to the stderr pipe
|
||||
var stdErrStream = net.connect(stdErrPipeName);
|
||||
@@ -53,15 +53,15 @@ log('ELECTRON_RUN_AS_NODE: ' + process.env['ELECTRON_RUN_AS_NODE']);
|
||||
stdErrStream.unref();
|
||||
|
||||
// handle process.stderr
|
||||
(<any>process).__defineGetter__('stderr', function() { return stdErrStream; });
|
||||
(<any>process).__defineGetter__('stderr', function () { return stdErrStream; });
|
||||
|
||||
var fsWriteSyncString = function(fd, str, position, encoding) {
|
||||
var fsWriteSyncString = function (fd, str, position, encoding) {
|
||||
// fs.writeSync(fd, string[, position[, encoding]]);
|
||||
var buf = new Buffer(str, encoding || 'utf8');
|
||||
return fsWriteSyncBuffer(fd, buf, 0, buf.length);
|
||||
};
|
||||
|
||||
var fsWriteSyncBuffer = function(fd, buffer, off, len) {
|
||||
var fsWriteSyncBuffer = function (fd, buffer, off, len) {
|
||||
off = Math.abs(off | 0);
|
||||
len = Math.abs(len | 0);
|
||||
|
||||
@@ -97,7 +97,7 @@ log('ELECTRON_RUN_AS_NODE: ' + process.env['ELECTRON_RUN_AS_NODE']);
|
||||
|
||||
// handle fs.writeSync(1, ...)
|
||||
var originalWriteSync = fs.writeSync;
|
||||
fs.writeSync = function(fd, data, position, encoding) {
|
||||
fs.writeSync = function (fd, data, position, encoding) {
|
||||
if (fd !== 1 || fd !== 2) {
|
||||
return originalWriteSync.apply(fs, arguments);
|
||||
}
|
||||
@@ -122,17 +122,17 @@ log('ELECTRON_RUN_AS_NODE: ' + process.env['ELECTRON_RUN_AS_NODE']);
|
||||
})();
|
||||
|
||||
// stdin redirection to named pipe
|
||||
(function() {
|
||||
(function () {
|
||||
|
||||
// Begin listening to stdin pipe
|
||||
var server = net.createServer(function(stream) {
|
||||
var server = net.createServer(function (stream) {
|
||||
// Stop accepting new connections, keep the existing one alive
|
||||
server.close();
|
||||
|
||||
log('Parent process has connected to my stdin. All should be good now.');
|
||||
|
||||
// handle process.stdin
|
||||
(<any>process).__defineGetter__('stdin', function() {
|
||||
(<any>process).__defineGetter__('stdin', function () {
|
||||
return stream;
|
||||
});
|
||||
|
||||
@@ -154,7 +154,7 @@ log('ELECTRON_RUN_AS_NODE: ' + process.env['ELECTRON_RUN_AS_NODE']);
|
||||
log('Finished loading program.');
|
||||
|
||||
var stdinIsReferenced = true;
|
||||
var timer = setInterval(function() {
|
||||
var timer = setInterval(function () {
|
||||
var listenerCount = (
|
||||
stream.listeners('data').length +
|
||||
stream.listeners('end').length +
|
||||
@@ -190,7 +190,7 @@ log('ELECTRON_RUN_AS_NODE: ' + process.env['ELECTRON_RUN_AS_NODE']);
|
||||
});
|
||||
|
||||
|
||||
server.listen(stdInPipeName, function() {
|
||||
server.listen(stdInPipeName, function () {
|
||||
// signal via stdout that the parent process can now begin writing to stdin pipe
|
||||
process.stdout.write('ready');
|
||||
});
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
'use strict';
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import {ITypescriptServiceClient} from '../typescriptService';
|
||||
import {loadMessageBundle} from 'vscode-nls';
|
||||
import {dirname, join} from 'path';
|
||||
import {exists} from 'fs';
|
||||
import { ITypescriptServiceClient } from '../typescriptService';
|
||||
import { loadMessageBundle } from 'vscode-nls';
|
||||
import { dirname, join } from 'path';
|
||||
import { exists } from 'fs';
|
||||
|
||||
const localize = loadMessageBundle();
|
||||
const selector = ['javascript', 'javascriptreact'];
|
||||
@@ -25,7 +25,7 @@ interface Hint {
|
||||
|
||||
const fileLimit = 500;
|
||||
|
||||
export function create(client: ITypescriptServiceClient, isOpen:(path:string)=>Promise<boolean>, memento: vscode.Memento) {
|
||||
export function create(client: ITypescriptServiceClient, isOpen: (path: string) => Promise<boolean>, memento: vscode.Memento) {
|
||||
|
||||
const toDispose: vscode.Disposable[] = [];
|
||||
const projectHinted: { [k: string]: boolean } = Object.create(null);
|
||||
@@ -157,7 +157,7 @@ export function create(client: ITypescriptServiceClient, isOpen:(path:string)=>P
|
||||
return vscode.Disposable.from(...toDispose);
|
||||
}
|
||||
|
||||
function computeLargeRoots(configFileName:string, fileNames: string[]): string[] {
|
||||
function computeLargeRoots(configFileName: string, fileNames: string[]): string[] {
|
||||
|
||||
let roots: { [first: string]: number } = Object.create(null);
|
||||
let dir = dirname(configFileName);
|
||||
|
||||
@@ -7,25 +7,25 @@
|
||||
|
||||
import stream = require('stream');
|
||||
|
||||
let DefaultSize:number = 8192;
|
||||
let ContentLength:string = 'Content-Length: ';
|
||||
let ContentLengthSize:number = Buffer.byteLength(ContentLength, 'utf8');
|
||||
let Blank:number = new Buffer(' ', 'utf8')[0];
|
||||
let BackslashR:number = new Buffer('\r', 'utf8')[0];
|
||||
let BackslashN:number = new Buffer('\n', 'utf8')[0];
|
||||
let DefaultSize: number = 8192;
|
||||
let ContentLength: string = 'Content-Length: ';
|
||||
let ContentLengthSize: number = Buffer.byteLength(ContentLength, 'utf8');
|
||||
let Blank: number = new Buffer(' ', 'utf8')[0];
|
||||
let BackslashR: number = new Buffer('\r', 'utf8')[0];
|
||||
let BackslashN: number = new Buffer('\n', 'utf8')[0];
|
||||
|
||||
class ProtocolBuffer {
|
||||
|
||||
private index:number;
|
||||
private buffer:Buffer;
|
||||
private index: number;
|
||||
private buffer: Buffer;
|
||||
|
||||
constructor() {
|
||||
this.index = 0;
|
||||
this.buffer = new Buffer(DefaultSize);
|
||||
}
|
||||
|
||||
public append(data:string | Buffer):void {
|
||||
let toAppend:Buffer = null;
|
||||
public append(data: string | Buffer): void {
|
||||
let toAppend: Buffer = null;
|
||||
if (Buffer.isBuffer(data)) {
|
||||
toAppend = <Buffer>data;
|
||||
} else {
|
||||
@@ -42,10 +42,10 @@ class ProtocolBuffer {
|
||||
this.buffer = Buffer.concat([this.buffer.slice(0, this.index), toAppend], newSize);
|
||||
}
|
||||
}
|
||||
this.index+= toAppend.length;
|
||||
this.index += toAppend.length;
|
||||
}
|
||||
|
||||
public tryReadContentLength():number {
|
||||
public tryReadContentLength(): number {
|
||||
let result = -1;
|
||||
let current = 0;
|
||||
// we are utf8 encoding...
|
||||
@@ -57,7 +57,7 @@ class ProtocolBuffer {
|
||||
}
|
||||
current += ContentLengthSize;
|
||||
let start = current;
|
||||
while(current < this.index && this.buffer[current] !== BackslashR) {
|
||||
while (current < this.index && this.buffer[current] !== BackslashR) {
|
||||
current++;
|
||||
}
|
||||
if (current + 3 >= this.index || this.buffer[current + 1] !== BackslashN || this.buffer[current + 2] !== BackslashR || this.buffer[current + 3] !== BackslashN) {
|
||||
@@ -70,13 +70,13 @@ class ProtocolBuffer {
|
||||
return result;
|
||||
}
|
||||
|
||||
public tryReadContent(length:number):string {
|
||||
public tryReadContent(length: number): string {
|
||||
if (this.index < length) {
|
||||
return null;
|
||||
}
|
||||
let result = this.buffer.toString('utf8', 0, length);
|
||||
let sourceStart = length;
|
||||
while(sourceStart < this.index && (this.buffer[sourceStart] === BackslashR || this.buffer[sourceStart] === BackslashN)) {
|
||||
while (sourceStart < this.index && (this.buffer[sourceStart] === BackslashR || this.buffer[sourceStart] === BackslashN)) {
|
||||
sourceStart++;
|
||||
}
|
||||
this.buffer.copy(this.buffer, 0, sourceStart);
|
||||
@@ -84,8 +84,8 @@ class ProtocolBuffer {
|
||||
return result;
|
||||
}
|
||||
|
||||
public tryReadLine():string {
|
||||
let end:number = 0;
|
||||
public tryReadLine(): string {
|
||||
let end: number = 0;
|
||||
while (end < this.index && this.buffer[end] !== BackslashR && this.buffer[end] !== BackslashN) {
|
||||
end++;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ class ProtocolBuffer {
|
||||
return result;
|
||||
}
|
||||
|
||||
public get numberOfBytes():number {
|
||||
public get numberOfBytes(): number {
|
||||
return this.index;
|
||||
}
|
||||
}
|
||||
@@ -116,35 +116,35 @@ export enum ReaderType {
|
||||
}
|
||||
|
||||
export interface ICallback<T> {
|
||||
(data:T):void;
|
||||
(data: T): void;
|
||||
}
|
||||
|
||||
export class Reader<T> {
|
||||
|
||||
private readable:stream.Readable;
|
||||
private callback:ICallback<T>;
|
||||
private buffer:ProtocolBuffer;
|
||||
private nextMessageLength:number;
|
||||
private readable: stream.Readable;
|
||||
private callback: ICallback<T>;
|
||||
private buffer: ProtocolBuffer;
|
||||
private nextMessageLength: number;
|
||||
|
||||
public constructor(readable:stream.Readable, callback:ICallback<T>, type:ReaderType = ReaderType.Length) {
|
||||
public constructor(readable: stream.Readable, callback: ICallback<T>, type: ReaderType = ReaderType.Length) {
|
||||
this.readable = readable;
|
||||
this.buffer = new ProtocolBuffer();
|
||||
this.callback = callback;
|
||||
this.nextMessageLength = -1;
|
||||
if (type === ReaderType.Length) {
|
||||
this.readable.on('data', (data:Buffer) => {
|
||||
this.readable.on('data', (data: Buffer) => {
|
||||
this.onLengthData(data);
|
||||
});
|
||||
} else if (type === ReaderType.Line) {
|
||||
this.readable.on('data', (data:Buffer) => {
|
||||
this.readable.on('data', (data: Buffer) => {
|
||||
this.onLineData(data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private onLengthData(data:Buffer):void {
|
||||
private onLengthData(data: Buffer): void {
|
||||
this.buffer.append(data);
|
||||
while(true) {
|
||||
while (true) {
|
||||
if (this.nextMessageLength === -1) {
|
||||
this.nextMessageLength = this.buffer.tryReadContentLength();
|
||||
if (this.nextMessageLength === -1) {
|
||||
@@ -161,9 +161,9 @@ export class Reader<T> {
|
||||
}
|
||||
}
|
||||
|
||||
private onLineData(data:Buffer):void {
|
||||
private onLineData(data: Buffer): void {
|
||||
this.buffer.append(data);
|
||||
while(true) {
|
||||
while (true) {
|
||||
let msg = this.buffer.tryReadLine();
|
||||
if (msg === null) {
|
||||
return;
|
||||
@@ -175,15 +175,15 @@ export class Reader<T> {
|
||||
|
||||
export class Writer<T> {
|
||||
|
||||
private writable:stream.Writable;
|
||||
private writable: stream.Writable;
|
||||
|
||||
public constructor(writable:stream.Writable) {
|
||||
public constructor(writable: stream.Writable) {
|
||||
this.writable = writable;
|
||||
}
|
||||
|
||||
public write(msg:T):void {
|
||||
public write(msg: T): void {
|
||||
let json = JSON.stringify(msg);
|
||||
let buffer:string[] = [
|
||||
let buffer: string[] = [
|
||||
ContentLength,
|
||||
Buffer.byteLength(json, 'utf8').toString(),
|
||||
'\r\n\r\n',
|
||||
|
||||
Reference in New Issue
Block a user