Skip to content

Commit

Permalink
Update LKG
Browse files Browse the repository at this point in the history
  • Loading branch information
mhegazy committed Apr 19, 2018
1 parent 149803b commit 80fff90
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 46 deletions.
4 changes: 4 additions & 0 deletions lib/tsc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10534,6 +10534,10 @@ var ts;
|| kind === 251;
}
ts.isTypeElement = isTypeElement;
function isClassOrTypeElement(node) {
return isTypeElement(node) || isClassElement(node);
}
ts.isClassOrTypeElement = isClassOrTypeElement;
function isObjectLiteralElementLike(node) {
var kind = node.kind;
return kind === 268
Expand Down
35 changes: 22 additions & 13 deletions lib/tsserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -10985,6 +10985,10 @@ var ts;
|| kind === 251;
}
ts.isTypeElement = isTypeElement;
function isClassOrTypeElement(node) {
return isTypeElement(node) || isClassElement(node);
}
ts.isClassOrTypeElement = isClassOrTypeElement;
function isObjectLiteralElementLike(node) {
var kind = node.kind;
return kind === 268
Expand Down Expand Up @@ -78631,10 +78635,7 @@ var ts;
}
};
ChangeTracker.prototype.insertNodeAfter = function (sourceFile, after, newNode) {
if (ts.isStatementButNotDeclaration(after) ||
after.kind === 151 ||
after.kind === 150 ||
after.kind === 152) {
if (needSemicolonBetween(after, newNode)) {
if (sourceFile.text.charCodeAt(after.end - 1) !== 59) {
this.changes.push({
kind: ChangeKind.ReplaceWithSingleNode,
Expand All @@ -78652,7 +78653,7 @@ var ts;
if (ts.isClassDeclaration(node) || ts.isModuleDeclaration(node)) {
return { prefix: this.newLineCharacter, suffix: this.newLineCharacter };
}
else if (ts.isStatement(node) || ts.isClassElement(node) || ts.isTypeElement(node)) {
else if (ts.isStatement(node) || ts.isClassOrTypeElement(node)) {
return { suffix: this.newLineCharacter };
}
else if (ts.isVariableDeclaration(node)) {
Expand Down Expand Up @@ -79017,6 +79018,10 @@ var ts;
}
}
}
function needSemicolonBetween(a, b) {
return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 146
|| ts.isStatementButNotDeclaration(a) && ts.isStatementButNotDeclaration(b);
}
})(textChanges = ts.textChanges || (ts.textChanges = {}));
})(ts || (ts = {}));
var ts;
Expand Down Expand Up @@ -85937,6 +85942,11 @@ var ts;
: undefined;
}
server.findArgument = findArgument;
function nowString() {
var d = new Date();
return d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds() + "." + d.getMilliseconds();
}
server.nowString = nowString;
})(server = ts.server || (ts.server = {}));
})(ts || (ts = {}));
var ts;
Expand Down Expand Up @@ -88963,6 +88973,8 @@ var ts;
}
this.currentDirectory = this.host.getCurrentDirectory();
this.toCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames);
this.globalCacheLocationDirectoryPath = this.typingsInstaller.globalTypingsCacheLocation &&
ts.ensureTrailingDirectorySeparator(this.toPath(this.typingsInstaller.globalTypingsCacheLocation));
this.throttledOperations = new server.ThrottledOperations(this.host, this.logger);
if (this.typesMapLocation) {
this.loadTypesMap();
Expand Down Expand Up @@ -89060,8 +89072,8 @@ var ts;
else {
if (_this.pendingEnsureProjectForOpenFiles) {
_this.ensureProjectForOpenFiles();
_this.sendProjectsUpdatedInBackgroundEvent();
}
_this.sendProjectsUpdatedInBackgroundEvent();
}
});
};
Expand Down Expand Up @@ -89132,7 +89144,6 @@ var ts;
return undefined;
}
if (server.isInferredProjectName(projectName)) {
this.ensureProjectStructuresUptoDate();
return findProjectByName(projectName, this.inferredProjects);
}
return this.findExternalProjectByProjectName(projectName) || this.findConfiguredProjectByProjectName(server.toNormalizedPath(projectName));
Expand Down Expand Up @@ -89884,7 +89895,9 @@ var ts;
ProjectService.prototype.watchClosedScriptInfo = function (info) {
var _this = this;
ts.Debug.assert(!info.fileWatcher);
if (!info.isDynamicOrHasMixedContent()) {
if (!info.isDynamicOrHasMixedContent() &&
(!this.globalCacheLocationDirectoryPath ||
!ts.startsWith(info.path, this.globalCacheLocationDirectoryPath))) {
var fileName = info.fileName;
info.fileWatcher = this.watchFactory.watchFilePath(this.host, fileName, function (fileName, eventKind, path) { return _this.onSourceFileChanged(fileName, eventKind, path); }, ts.PollingInterval.Medium, info.path, "Closed Script info");
}
Expand Down Expand Up @@ -93041,7 +93054,7 @@ var ts;
if (type === void 0) { type = server.Msg.Err; }
if (!this.canWrite)
return;
s = "[" + nowString() + "] " + s + "\n";
s = "[" + server.nowString() + "] " + s + "\n";
if (!this.inGroup || this.firstInGroup) {
var prefix = Logger.padStringRight(type + " " + this.seq.toString(), " ");
s = prefix + s;
Expand Down Expand Up @@ -93069,10 +93082,6 @@ var ts;
};
return Logger;
}());
function nowString() {
var d = new Date();
return d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds() + "." + d.getMilliseconds();
}
var NodeTypingsInstaller = (function () {
function NodeTypingsInstaller(telemetryEnabled, logger, host, globalTypingsCacheLocation, typingSafeListLocation, typesMapLocation, npmLocation, event) {
this.telemetryEnabled = telemetryEnabled;
Expand Down
2 changes: 2 additions & 0 deletions lib/tsserverlibrary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3219,6 +3219,7 @@ declare namespace ts {
function isClassLike(node: Node): node is ClassLikeDeclaration;
function isAccessor(node: Node): node is AccessorDeclaration;
function isTypeElement(node: Node): node is TypeElement;
function isClassOrTypeElement(node: Node): node is ClassElement | TypeElement;
function isObjectLiteralElementLike(node: Node): node is ObjectLiteralElementLike;
/**
* Node test that determines whether a node is a valid type node.
Expand Down Expand Up @@ -7847,6 +7848,7 @@ declare namespace ts.server {
readonly useSingleInferredProject: boolean;
readonly useInferredProjectPerProjectRoot: boolean;
readonly typingsInstaller: ITypingsInstaller;
private readonly globalCacheLocationDirectoryPath;
readonly throttleWaitMilliseconds?: number;
private readonly eventHandler?;
readonly globalPlugins: ReadonlyArray<string>;
Expand Down
40 changes: 26 additions & 14 deletions lib/tsserverlibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -3648,10 +3648,6 @@ var ts;
return path;
}
ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator;
/**
* Adds a trailing directory separator to a path, if it does not already have one.
* @param path The path.
*/
function ensureTrailingDirectorySeparator(path) {
if (path.charAt(path.length - 1) !== ts.directorySeparator) {
return path + ts.directorySeparator;
Expand Down Expand Up @@ -11497,6 +11493,10 @@ var ts;
|| kind === 251 /* MissingDeclaration */;
}
ts.isTypeElement = isTypeElement;
function isClassOrTypeElement(node) {
return isTypeElement(node) || isClassElement(node);
}
ts.isClassOrTypeElement = isClassOrTypeElement;
function isObjectLiteralElementLike(node) {
var kind = node.kind;
return kind === 268 /* PropertyAssignment */
Expand Down Expand Up @@ -94878,10 +94878,7 @@ var ts;
}
};
ChangeTracker.prototype.insertNodeAfter = function (sourceFile, after, newNode) {
if (ts.isStatementButNotDeclaration(after) ||
after.kind === 151 /* PropertyDeclaration */ ||
after.kind === 150 /* PropertySignature */ ||
after.kind === 152 /* MethodSignature */) {
if (needSemicolonBetween(after, newNode)) {
// check if previous statement ends with semicolon
// if not - insert semicolon to preserve the code from changing the meaning due to ASI
if (sourceFile.text.charCodeAt(after.end - 1) !== 59 /* semicolon */) {
Expand All @@ -94901,7 +94898,7 @@ var ts;
if (ts.isClassDeclaration(node) || ts.isModuleDeclaration(node)) {
return { prefix: this.newLineCharacter, suffix: this.newLineCharacter };
}
else if (ts.isStatement(node) || ts.isClassElement(node) || ts.isTypeElement(node)) {
else if (ts.isStatement(node) || ts.isClassOrTypeElement(node)) {
return { suffix: this.newLineCharacter };
}
else if (ts.isVariableDeclaration(node)) {
Expand Down Expand Up @@ -95335,6 +95332,10 @@ var ts;
}
}
}
function needSemicolonBetween(a, b) {
return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 146 /* ComputedPropertyName */
|| ts.isStatementButNotDeclaration(a) && ts.isStatementButNotDeclaration(b); // TODO: only if b would start with a `(` or `[`
}
})(textChanges = ts.textChanges || (ts.textChanges = {}));
})(ts || (ts = {}));
/* @internal */
Expand Down Expand Up @@ -102515,6 +102516,13 @@ var ts;
: undefined;
}
server.findArgument = findArgument;
/*@internal*/
function nowString() {
// E.g. "12:34:56.789"
var d = new Date();
return d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds() + "." + d.getMilliseconds();
}
server.nowString = nowString;
})(server = ts.server || (ts.server = {}));
})(ts || (ts = {}));
/// <reference path="types.ts" />
Expand Down Expand Up @@ -108711,6 +108719,8 @@ var ts;
}
this.currentDirectory = this.host.getCurrentDirectory();
this.toCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames);
this.globalCacheLocationDirectoryPath = this.typingsInstaller.globalTypingsCacheLocation &&
ts.ensureTrailingDirectorySeparator(this.toPath(this.typingsInstaller.globalTypingsCacheLocation));
this.throttledOperations = new server.ThrottledOperations(this.host, this.logger);
if (this.typesMapLocation) {
this.loadTypesMap();
Expand Down Expand Up @@ -108815,10 +108825,10 @@ var ts;
else {
if (_this.pendingEnsureProjectForOpenFiles) {
_this.ensureProjectForOpenFiles();
// Send the event to notify that there were background project updates
// send current list of open files
_this.sendProjectsUpdatedInBackgroundEvent();
}
// Send the event to notify that there were background project updates
// send current list of open files
_this.sendProjectsUpdatedInBackgroundEvent();
}
});
};
Expand Down Expand Up @@ -108901,7 +108911,6 @@ var ts;
return undefined;
}
if (server.isInferredProjectName(projectName)) {
this.ensureProjectStructuresUptoDate();
return findProjectByName(projectName, this.inferredProjects);
}
return this.findExternalProjectByProjectName(projectName) || this.findConfiguredProjectByProjectName(server.toNormalizedPath(projectName));
Expand Down Expand Up @@ -109848,7 +109857,10 @@ var ts;
var _this = this;
ts.Debug.assert(!info.fileWatcher);
// do not watch files with mixed content - server doesn't know how to interpret it
if (!info.isDynamicOrHasMixedContent()) {
// do not watch files in the global cache location
if (!info.isDynamicOrHasMixedContent() &&
(!this.globalCacheLocationDirectoryPath ||
!ts.startsWith(info.path, this.globalCacheLocationDirectoryPath))) {
var fileName = info.fileName;
info.fileWatcher = this.watchFactory.watchFilePath(this.host, fileName, function (fileName, eventKind, path) { return _this.onSourceFileChanged(fileName, eventKind, path); }, ts.PollingInterval.Medium, info.path, "Closed Script info" /* ClosedScriptInfo */);
}
Expand Down
1 change: 1 addition & 0 deletions lib/typescript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@ declare namespace ts {
function isClassLike(node: Node): node is ClassLikeDeclaration;
function isAccessor(node: Node): node is AccessorDeclaration;
function isTypeElement(node: Node): node is TypeElement;
function isClassOrTypeElement(node: Node): node is ClassElement | TypeElement;
function isObjectLiteralElementLike(node: Node): node is ObjectLiteralElementLike;
/**
* Node test that determines whether a node is a valid type node.
Expand Down
19 changes: 10 additions & 9 deletions lib/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -3648,10 +3648,6 @@ var ts;
return path;
}
ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator;
/**
* Adds a trailing directory separator to a path, if it does not already have one.
* @param path The path.
*/
function ensureTrailingDirectorySeparator(path) {
if (path.charAt(path.length - 1) !== ts.directorySeparator) {
return path + ts.directorySeparator;
Expand Down Expand Up @@ -13373,6 +13369,10 @@ var ts;
|| kind === 251 /* MissingDeclaration */;
}
ts.isTypeElement = isTypeElement;
function isClassOrTypeElement(node) {
return isTypeElement(node) || isClassElement(node);
}
ts.isClassOrTypeElement = isClassOrTypeElement;
function isObjectLiteralElementLike(node) {
var kind = node.kind;
return kind === 268 /* PropertyAssignment */
Expand Down Expand Up @@ -96457,10 +96457,7 @@ var ts;
}
};
ChangeTracker.prototype.insertNodeAfter = function (sourceFile, after, newNode) {
if (ts.isStatementButNotDeclaration(after) ||
after.kind === 151 /* PropertyDeclaration */ ||
after.kind === 150 /* PropertySignature */ ||
after.kind === 152 /* MethodSignature */) {
if (needSemicolonBetween(after, newNode)) {
// check if previous statement ends with semicolon
// if not - insert semicolon to preserve the code from changing the meaning due to ASI
if (sourceFile.text.charCodeAt(after.end - 1) !== 59 /* semicolon */) {
Expand All @@ -96480,7 +96477,7 @@ var ts;
if (ts.isClassDeclaration(node) || ts.isModuleDeclaration(node)) {
return { prefix: this.newLineCharacter, suffix: this.newLineCharacter };
}
else if (ts.isStatement(node) || ts.isClassElement(node) || ts.isTypeElement(node)) {
else if (ts.isStatement(node) || ts.isClassOrTypeElement(node)) {
return { suffix: this.newLineCharacter };
}
else if (ts.isVariableDeclaration(node)) {
Expand Down Expand Up @@ -96914,6 +96911,10 @@ var ts;
}
}
}
function needSemicolonBetween(a, b) {
return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 146 /* ComputedPropertyName */
|| ts.isStatementButNotDeclaration(a) && ts.isStatementButNotDeclaration(b); // TODO: only if b would start with a `(` or `[`
}
})(textChanges = ts.textChanges || (ts.textChanges = {}));
})(ts || (ts = {}));
/* @internal */
Expand Down
1 change: 1 addition & 0 deletions lib/typescriptServices.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@ declare namespace ts {
function isClassLike(node: Node): node is ClassLikeDeclaration;
function isAccessor(node: Node): node is AccessorDeclaration;
function isTypeElement(node: Node): node is TypeElement;
function isClassOrTypeElement(node: Node): node is ClassElement | TypeElement;
function isObjectLiteralElementLike(node: Node): node is ObjectLiteralElementLike;
/**
* Node test that determines whether a node is a valid type node.
Expand Down
19 changes: 10 additions & 9 deletions lib/typescriptServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -3648,10 +3648,6 @@ var ts;
return path;
}
ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator;
/**
* Adds a trailing directory separator to a path, if it does not already have one.
* @param path The path.
*/
function ensureTrailingDirectorySeparator(path) {
if (path.charAt(path.length - 1) !== ts.directorySeparator) {
return path + ts.directorySeparator;
Expand Down Expand Up @@ -13373,6 +13369,10 @@ var ts;
|| kind === 251 /* MissingDeclaration */;
}
ts.isTypeElement = isTypeElement;
function isClassOrTypeElement(node) {
return isTypeElement(node) || isClassElement(node);
}
ts.isClassOrTypeElement = isClassOrTypeElement;
function isObjectLiteralElementLike(node) {
var kind = node.kind;
return kind === 268 /* PropertyAssignment */
Expand Down Expand Up @@ -96457,10 +96457,7 @@ var ts;
}
};
ChangeTracker.prototype.insertNodeAfter = function (sourceFile, after, newNode) {
if (ts.isStatementButNotDeclaration(after) ||
after.kind === 151 /* PropertyDeclaration */ ||
after.kind === 150 /* PropertySignature */ ||
after.kind === 152 /* MethodSignature */) {
if (needSemicolonBetween(after, newNode)) {
// check if previous statement ends with semicolon
// if not - insert semicolon to preserve the code from changing the meaning due to ASI
if (sourceFile.text.charCodeAt(after.end - 1) !== 59 /* semicolon */) {
Expand All @@ -96480,7 +96477,7 @@ var ts;
if (ts.isClassDeclaration(node) || ts.isModuleDeclaration(node)) {
return { prefix: this.newLineCharacter, suffix: this.newLineCharacter };
}
else if (ts.isStatement(node) || ts.isClassElement(node) || ts.isTypeElement(node)) {
else if (ts.isStatement(node) || ts.isClassOrTypeElement(node)) {
return { suffix: this.newLineCharacter };
}
else if (ts.isVariableDeclaration(node)) {
Expand Down Expand Up @@ -96914,6 +96911,10 @@ var ts;
}
}
}
function needSemicolonBetween(a, b) {
return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 146 /* ComputedPropertyName */
|| ts.isStatementButNotDeclaration(a) && ts.isStatementButNotDeclaration(b); // TODO: only if b would start with a `(` or `[`
}
})(textChanges = ts.textChanges || (ts.textChanges = {}));
})(ts || (ts = {}));
/* @internal */
Expand Down
Loading

0 comments on commit 80fff90

Please sign in to comment.