Skip to content

Commit

Permalink
Update LKG
Browse files Browse the repository at this point in the history
  • Loading branch information
mhegazy committed Mar 13, 2017
1 parent 7ea8d9f commit d89553f
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 32 deletions.
2 changes: 1 addition & 1 deletion lib/cancellationToken.js
Expand Up @@ -49,7 +49,7 @@ function createCancellationToken(args) {
return {
isCancellationRequested: function () { return perRequestPipeName_1 !== undefined && pipeExists(perRequestPipeName_1); },
setRequest: function (requestId) {
currentRequestId_1 = currentRequestId_1;
currentRequestId_1 = requestId;
perRequestPipeName_1 = namePrefix_1 + requestId;
},
resetRequest: function (requestId) {
Expand Down
8 changes: 8 additions & 0 deletions lib/protocol.d.ts
Expand Up @@ -1666,6 +1666,14 @@ declare namespace ts.server.protocol {
telemetryEventName: string;
payload: any;
}
type TypesInstallerInitializationFailedEventName = "typesInstallerInitializationFailed";
interface TypesInstallerInitializationFailedEvent extends Event {
event: TypesInstallerInitializationFailedEventName;
body: TypesInstallerInitializationFailedEventBody;
}
interface TypesInstallerInitializationFailedEventBody {
message: string;
}
type TypingsInstalledTelemetryEventName = "typingsInstalled";
interface TypingsInstalledTelemetryEventBody extends TelemetryEventBody {
telemetryEventName: TypingsInstalledTelemetryEventName;
Expand Down
70 changes: 44 additions & 26 deletions lib/tsserver.js
Expand Up @@ -68707,6 +68707,7 @@ var ts;
server.ActionInvalidate = "action::invalidate";
server.EventBeginInstallTypes = "event::beginInstallTypes";
server.EventEndInstallTypes = "event::endInstallTypes";
server.EventInitializationFailed = "event::initializationFailed";
var Arguments;
(function (Arguments) {
Arguments.GlobalCacheLocation = "--globalTypingsCacheLocation";
Expand Down Expand Up @@ -74259,6 +74260,13 @@ var ts;
this.seq = 0;
this.inGroup = false;
this.firstInGroup = true;
if (this.logFilename) {
try {
this.fd = fs.openSync(this.logFilename, "w");
}
catch (e) {
}
}
}
Logger.padStringRight = function (str, padding) {
return (str + padding).slice(0, padding.length);
Expand Down Expand Up @@ -74294,11 +74302,6 @@ var ts;
};
Logger.prototype.msg = function (s, type) {
if (type === void 0) { type = server.Msg.Err; }
if (this.fd < 0) {
if (this.logFilename) {
this.fd = fs.openSync(this.logFilename, "w");
}
}
if (this.fd >= 0 || this.traceToConsole) {
s = s + "\n";
var prefix = Logger.padStringRight(type + " " + this.seq.toString(), " ");
Expand Down Expand Up @@ -74408,6 +74411,17 @@ var ts;
if (this.logger.hasLevel(server.LogLevel.verbose)) {
this.logger.info("Received response: " + JSON.stringify(response));
}
if (response.kind === server.EventInitializationFailed) {
if (!this.eventSender) {
return;
}
var body = {
message: response.message
};
var eventName = "typesInstallerInitializationFailed";
this.eventSender.event(body, eventName);
return;
}
if (response.kind === server.EventBeginInstallTypes) {
if (!this.eventSender) {
return;
Expand Down Expand Up @@ -74483,6 +74497,9 @@ var ts;
return IOSession;
}(server.Session));
function parseLoggingEnvironmentString(logEnvStr) {
if (!logEnvStr) {
return {};
}
var logEnv = { logToFile: true };
var args = logEnvStr.split(" ");
var len = args.length - 1;
Expand All @@ -74495,8 +74512,8 @@ var ts;
logEnv.file = ts.stripQuotes(value);
break;
case "-level":
var level = server.LogLevel[value];
logEnv.detailLevel = typeof level === "number" ? level : server.LogLevel.normal;
var level = getLogLevel(value);
logEnv.detailLevel = level !== undefined ? level : server.LogLevel.normal;
break;
case "-traceToConsole":
logEnv.traceToConsole = value.toLowerCase() === "true";
Expand All @@ -74509,27 +74526,28 @@ var ts;
}
return logEnv;
}
function createLoggerFromEnv() {
var fileName = undefined;
var detailLevel = server.LogLevel.normal;
var traceToConsole = false;
var logEnvStr = process.env["TSS_LOG"];
if (logEnvStr) {
var logEnv = parseLoggingEnvironmentString(logEnvStr);
if (logEnv.logToFile) {
if (logEnv.file) {
fileName = logEnv.file;
function getLogLevel(level) {
if (level) {
var l = level.toLowerCase();
for (var name in server.LogLevel) {
if (isNaN(+name) && l === name.toLowerCase()) {
return server.LogLevel[name];
}
else {
fileName = __dirname + "/.log" + process.pid.toString();
}
}
if (logEnv.detailLevel) {
detailLevel = logEnv.detailLevel;
}
traceToConsole = logEnv.traceToConsole;
}
return new Logger(fileName, traceToConsole, detailLevel);
return undefined;
}
function createLogger() {
var cmdLineLogFileName = server.findArgument("--logFile");
var cmdLineVerbosity = getLogLevel(server.findArgument("--logVerbosity"));
var envLogOptions = parseLoggingEnvironmentString(process.env["TSS_LOG"]);
var logFileName = cmdLineLogFileName
? ts.stripQuotes(cmdLineLogFileName)
: envLogOptions.logToFile
? envLogOptions.file || (__dirname + "/.log" + process.pid.toString())
: undefined;
var logVerbosity = cmdLineVerbosity || envLogOptions.detailLevel;
return new Logger(logFileName, envLogOptions.traceToConsole, logVerbosity);
}
function createPollingWatchedFileSet(interval, chunkSize) {
if (interval === void 0) { interval = 2500; }
Expand Down Expand Up @@ -74598,7 +74616,6 @@ var ts;
};
}
var pollingWatchedFileSet = createPollingWatchedFileSet();
var logger = createLoggerFromEnv();
var pending = [];
var canWrite = true;
function writeMessage(buf) {
Expand Down Expand Up @@ -74637,6 +74654,7 @@ var ts;
function isUNCPath(s) {
return s.length > 2 && s.charCodeAt(0) === 47 && s.charCodeAt(1) === 47;
}
var logger = createLogger();
var sys = ts.sys;
var useWatchGuard = process.platform === "win32" && ts.getNodeMajorVersion() >= 4;
if (useWatchGuard) {
Expand Down
16 changes: 15 additions & 1 deletion lib/tsserverlibrary.d.ts
Expand Up @@ -3253,8 +3253,13 @@ declare namespace ts.server {
type ActionInvalidate = "action::invalidate";
type EventBeginInstallTypes = "event::beginInstallTypes";
type EventEndInstallTypes = "event::endInstallTypes";
type EventInitializationFailed = "event::initializationFailed";
interface TypingInstallerResponse {
readonly kind: ActionSet | ActionInvalidate | EventBeginInstallTypes | EventEndInstallTypes;
readonly kind: ActionSet | ActionInvalidate | EventBeginInstallTypes | EventEndInstallTypes | EventInitializationFailed;
}
interface InitializationFailedResponse extends TypingInstallerResponse {
readonly kind: EventInitializationFailed;
readonly message: string;
}
interface ProjectResponse extends TypingInstallerResponse {
readonly projectName: string;
Expand Down Expand Up @@ -3288,6 +3293,7 @@ declare namespace ts.server {
const ActionInvalidate: ActionInvalidate;
const EventBeginInstallTypes: EventBeginInstallTypes;
const EventEndInstallTypes: EventEndInstallTypes;
const EventInitializationFailed: EventInitializationFailed;
namespace Arguments {
const GlobalCacheLocation = "--globalTypingsCacheLocation";
const LogFile = "--logFile";
Expand Down Expand Up @@ -4025,6 +4031,14 @@ declare namespace ts.server.protocol {
telemetryEventName: string;
payload: any;
}
type TypesInstallerInitializationFailedEventName = "typesInstallerInitializationFailed";
interface TypesInstallerInitializationFailedEvent extends Event {
event: TypesInstallerInitializationFailedEventName;
body: TypesInstallerInitializationFailedEventBody;
}
interface TypesInstallerInitializationFailedEventBody {
message: string;
}
type TypingsInstalledTelemetryEventName = "typingsInstalled";
interface TypingsInstalledTelemetryEventBody extends TelemetryEventBody {
telemetryEventName: TypingsInstalledTelemetryEventName;
Expand Down
5 changes: 3 additions & 2 deletions lib/tsserverlibrary.js
Expand Up @@ -37492,8 +37492,8 @@ var ts;
error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements);
}
}
var exports_1 = getExportsOfModule(moduleSymbol);
exports_1 && exports_1.forEach(function (_a, id) {
var exports = getExportsOfModule(moduleSymbol);
exports && exports.forEach(function (_a, id) {
var declarations = _a.declarations, flags = _a.flags;
if (id === "__export") {
return;
Expand Down Expand Up @@ -68013,6 +68013,7 @@ var ts;
server.ActionInvalidate = "action::invalidate";
server.EventBeginInstallTypes = "event::beginInstallTypes";
server.EventEndInstallTypes = "event::endInstallTypes";
server.EventInitializationFailed = "event::initializationFailed";
var Arguments;
(function (Arguments) {
Arguments.GlobalCacheLocation = "--globalTypingsCacheLocation";
Expand Down
19 changes: 17 additions & 2 deletions lib/typingsInstaller.js
Expand Up @@ -6221,6 +6221,7 @@ var ts;
server.ActionInvalidate = "action::invalidate";
server.EventBeginInstallTypes = "event::beginInstallTypes";
server.EventEndInstallTypes = "event::endInstallTypes";
server.EventInitializationFailed = "event::initializationFailed";
var Arguments;
(function (Arguments) {
Arguments.GlobalCacheLocation = "--globalTypingsCacheLocation";
Expand Down Expand Up @@ -7381,12 +7382,18 @@ var ts;
var FileLog = (function () {
function FileLog(logFile) {
this.logFile = logFile;
this.logEnabled = true;
}
FileLog.prototype.isEnabled = function () {
return this.logFile !== undefined;
return this.logEnabled && this.logFile !== undefined;
};
FileLog.prototype.writeLine = function (text) {
fs.appendFileSync(this.logFile, text + ts.sys.newLine);
try {
fs.appendFileSync(this.logFile, text + ts.sys.newLine);
}
catch (e) {
this.logEnabled = false;
}
};
return FileLog;
}());
Expand Down Expand Up @@ -7440,13 +7447,21 @@ var ts;
if (_this.log.isEnabled()) {
_this.log.writeLine("Error updating " + TypesRegistryPackageName + " package: " + e.message);
}
_this.delayedInitializationError = {
kind: "event::initializationFailed",
message: e.message
};
}
_this.typesRegistry = loadTypesRegistryFile(getTypesRegistryFileLocation(globalTypingsCacheLocation), _this.installTypingHost, _this.log);
return _this;
}
NodeTypingsInstaller.prototype.listen = function () {
var _this = this;
process.on("message", function (req) {
if (_this.delayedInitializationError) {
_this.sendResponse(_this.delayedInitializationError);
_this.delayedInitializationError = undefined;
}
switch (req.kind) {
case "discover":
_this.install(req);
Expand Down

0 comments on commit d89553f

Please sign in to comment.