if (ts.indexOf(declarations, declaration) === indexOfDeclaration) {
- var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration);
+ var sourceFileOfDeclaration_1 = ts.getSourceFileOfNode(declaration);
// If it is parameter - try and get the jsDoc comment with @param tag from function declaration's jsDoc comments
- if (canUseParsedParamTagComments && declaration.kind === 138 /* Parameter */) {
- ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) {
- var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration);
+ if (canUseParsedParamTagComments && declaration.kind === 139 /* Parameter */) {
+ ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration_1), function (jsDocCommentTextRange) {
+ var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration_1);
if (cleanedParamJsDocComment) {
ts.addRange(jsDocCommentParts, cleanedParamJsDocComment);
}
});
}
// If this is left side of dotted module declaration, there is no doc comments associated with this node
- if (declaration.kind === 218 /* ModuleDeclaration */ && declaration.body.kind === 218 /* ModuleDeclaration */) {
+ if (declaration.kind === 221 /* ModuleDeclaration */ && declaration.body.kind === 221 /* ModuleDeclaration */) {
return;
}
// If this is dotted module name, get the doc comments from the parent
- while (declaration.kind === 218 /* ModuleDeclaration */ && declaration.parent.kind === 218 /* ModuleDeclaration */) {
+ while (declaration.kind === 221 /* ModuleDeclaration */ && declaration.parent.kind === 221 /* ModuleDeclaration */) {
declaration = declaration.parent;
}
// Get the cleaned js doc comment text from the declaration
- ts.forEach(getJsDocCommentTextRange(declaration.kind === 211 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) {
- var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration);
+ ts.forEach(getJsDocCommentTextRange(declaration.kind === 214 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration_1), function (jsDocCommentTextRange) {
+ var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration_1);
if (cleanedJsDocComment) {
ts.addRange(jsDocCommentParts, cleanedJsDocComment);
}
@@ -43043,7 +46767,8 @@ var ts;
}
function pushDocCommentLineText(docComments, text, blankLineCount) {
// Add the empty lines in between texts
- while (blankLineCount--) {
+ while (blankLineCount) {
+ blankLineCount--;
docComments.push(ts.textPart(""));
}
docComments.push(ts.textPart(text));
@@ -43269,7 +46994,7 @@ var ts;
: undefined;
};
return TypeObject;
- })();
+ }());
var SignatureObject = (function () {
function SignatureObject(checker) {
this.checker = checker;
@@ -43295,11 +47020,11 @@ var ts;
return this.documentationComment;
};
return SignatureObject;
- })();
+ }());
var SourceFileObject = (function (_super) {
__extends(SourceFileObject, _super);
- function SourceFileObject() {
- _super.apply(this, arguments);
+ function SourceFileObject(kind, pos, end) {
+ _super.call(this, kind, pos, end);
}
SourceFileObject.prototype.update = function (newText, textChangeRange) {
return ts.updateSourceFile(this, newText, textChangeRange);
@@ -43335,13 +47060,13 @@ var ts;
}
function getDeclarationName(declaration) {
if (declaration.name) {
- var result_2 = getTextOfIdentifierOrLiteral(declaration.name);
- if (result_2 !== undefined) {
- return result_2;
+ var result_3 = getTextOfIdentifierOrLiteral(declaration.name);
+ if (result_3 !== undefined) {
+ return result_3;
}
- if (declaration.name.kind === 136 /* ComputedPropertyName */) {
+ if (declaration.name.kind === 137 /* ComputedPropertyName */) {
var expr = declaration.name.expression;
- if (expr.kind === 166 /* PropertyAccessExpression */) {
+ if (expr.kind === 169 /* PropertyAccessExpression */) {
return expr.name.text;
}
return getTextOfIdentifierOrLiteral(expr);
@@ -43361,9 +47086,9 @@ var ts;
}
function visit(node) {
switch (node.kind) {
- case 213 /* FunctionDeclaration */:
- case 143 /* MethodDeclaration */:
- case 142 /* MethodSignature */:
+ case 216 /* FunctionDeclaration */:
+ case 144 /* MethodDeclaration */:
+ case 143 /* MethodSignature */:
var functionDeclaration = node;
var declarationName = getDeclarationName(functionDeclaration);
if (declarationName) {
@@ -43383,60 +47108,60 @@ var ts;
ts.forEachChild(node, visit);
}
break;
- case 214 /* ClassDeclaration */:
- case 215 /* InterfaceDeclaration */:
- case 216 /* TypeAliasDeclaration */:
- case 217 /* EnumDeclaration */:
- case 218 /* ModuleDeclaration */:
- case 221 /* ImportEqualsDeclaration */:
- case 230 /* ExportSpecifier */:
- case 226 /* ImportSpecifier */:
- case 221 /* ImportEqualsDeclaration */:
- case 223 /* ImportClause */:
- case 224 /* NamespaceImport */:
- case 145 /* GetAccessor */:
- case 146 /* SetAccessor */:
- case 155 /* TypeLiteral */:
+ case 217 /* ClassDeclaration */:
+ case 218 /* InterfaceDeclaration */:
+ case 219 /* TypeAliasDeclaration */:
+ case 220 /* EnumDeclaration */:
+ case 221 /* ModuleDeclaration */:
+ case 224 /* ImportEqualsDeclaration */:
+ case 233 /* ExportSpecifier */:
+ case 229 /* ImportSpecifier */:
+ case 224 /* ImportEqualsDeclaration */:
+ case 226 /* ImportClause */:
+ case 227 /* NamespaceImport */:
+ case 146 /* GetAccessor */:
+ case 147 /* SetAccessor */:
+ case 156 /* TypeLiteral */:
addDeclaration(node);
// fall through
- case 144 /* Constructor */:
- case 193 /* VariableStatement */:
- case 212 /* VariableDeclarationList */:
- case 161 /* ObjectBindingPattern */:
- case 162 /* ArrayBindingPattern */:
- case 219 /* ModuleBlock */:
+ case 145 /* Constructor */:
+ case 196 /* VariableStatement */:
+ case 215 /* VariableDeclarationList */:
+ case 164 /* ObjectBindingPattern */:
+ case 165 /* ArrayBindingPattern */:
+ case 222 /* ModuleBlock */:
ts.forEachChild(node, visit);
break;
- case 192 /* Block */:
+ case 195 /* Block */:
if (ts.isFunctionBlock(node)) {
ts.forEachChild(node, visit);
}
break;
- case 138 /* Parameter */:
+ case 139 /* Parameter */:
// Only consider properties defined as constructor parameters
- if (!(node.flags & 112 /* AccessibilityModifier */)) {
+ if (!(node.flags & 56 /* AccessibilityModifier */)) {
break;
}
// fall through
- case 211 /* VariableDeclaration */:
- case 163 /* BindingElement */:
+ case 214 /* VariableDeclaration */:
+ case 166 /* BindingElement */:
if (ts.isBindingPattern(node.name)) {
ts.forEachChild(node.name, visit);
break;
}
- case 247 /* EnumMember */:
- case 141 /* PropertyDeclaration */:
- case 140 /* PropertySignature */:
+ case 250 /* EnumMember */:
+ case 142 /* PropertyDeclaration */:
+ case 141 /* PropertySignature */:
addDeclaration(node);
break;
- case 228 /* ExportDeclaration */:
+ case 231 /* ExportDeclaration */:
// Handle named exports case e.g.:
// export {a, b as B} from "mod";
if (node.exportClause) {
ts.forEach(node.exportClause.elements, visit);
}
break;
- case 222 /* ImportDeclaration */:
+ case 225 /* ImportDeclaration */:
var importClause = node.importClause;
if (importClause) {
// Handle default import case e.g.:
@@ -43448,7 +47173,7 @@ var ts;
// import * as NS from "mod";
// import {a, b as B} from "mod";
if (importClause.namedBindings) {
- if (importClause.namedBindings.kind === 224 /* NamespaceImport */) {
+ if (importClause.namedBindings.kind === 227 /* NamespaceImport */) {
addDeclaration(importClause.namedBindings);
}
else {
@@ -43461,12 +47186,12 @@ var ts;
}
};
return SourceFileObject;
- })(NodeObject);
+ }(NodeObject));
var TextChange = (function () {
function TextChange() {
}
return TextChange;
- })();
+ }());
ts.TextChange = TextChange;
var HighlightSpanKind;
(function (HighlightSpanKind) {
@@ -43556,7 +47281,7 @@ var ts;
// enum E
ScriptElementKind.enumElement = "enum";
// Inside module and script only
- // let v = ..
+ // const v = ..
ScriptElementKind.variableElement = "var";
// Inside function
ScriptElementKind.localVariableElement = "local var";
@@ -43621,8 +47346,14 @@ var ts;
ClassificationTypeNames.typeAliasName = "type alias name";
ClassificationTypeNames.parameterName = "parameter name";
ClassificationTypeNames.docCommentTagName = "doc comment tag name";
+ ClassificationTypeNames.jsxOpenTagName = "jsx open tag name";
+ ClassificationTypeNames.jsxCloseTagName = "jsx close tag name";
+ ClassificationTypeNames.jsxSelfClosingTagName = "jsx self closing tag name";
+ ClassificationTypeNames.jsxAttribute = "jsx attribute";
+ ClassificationTypeNames.jsxText = "jsx text";
+ ClassificationTypeNames.jsxAttributeStringLiteralValue = "jsx attribute string literal value";
return ClassificationTypeNames;
- })();
+ }());
ts.ClassificationTypeNames = ClassificationTypeNames;
(function (ClassificationType) {
ClassificationType[ClassificationType["comment"] = 1] = "comment";
@@ -43643,6 +47374,12 @@ var ts;
ClassificationType[ClassificationType["typeAliasName"] = 16] = "typeAliasName";
ClassificationType[ClassificationType["parameterName"] = 17] = "parameterName";
ClassificationType[ClassificationType["docCommentTagName"] = 18] = "docCommentTagName";
+ ClassificationType[ClassificationType["jsxOpenTagName"] = 19] = "jsxOpenTagName";
+ ClassificationType[ClassificationType["jsxCloseTagName"] = 20] = "jsxCloseTagName";
+ ClassificationType[ClassificationType["jsxSelfClosingTagName"] = 21] = "jsxSelfClosingTagName";
+ ClassificationType[ClassificationType["jsxAttribute"] = 22] = "jsxAttribute";
+ ClassificationType[ClassificationType["jsxText"] = 23] = "jsxText";
+ ClassificationType[ClassificationType["jsxAttributeStringLiteralValue"] = 24] = "jsxAttributeStringLiteralValue";
})(ts.ClassificationType || (ts.ClassificationType = {}));
var ClassificationType = ts.ClassificationType;
function displayPartsToString(displayParts) {
@@ -43658,16 +47395,16 @@ var ts;
}
return ts.forEach(symbol.declarations, function (declaration) {
// Function expressions are local
- if (declaration.kind === 173 /* FunctionExpression */) {
+ if (declaration.kind === 176 /* FunctionExpression */) {
return true;
}
- if (declaration.kind !== 211 /* VariableDeclaration */ && declaration.kind !== 213 /* FunctionDeclaration */) {
+ if (declaration.kind !== 214 /* VariableDeclaration */ && declaration.kind !== 216 /* FunctionDeclaration */) {
return false;
}
// If the parent is not sourceFile or module block it is local variable
- for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) {
+ for (var parent_10 = declaration.parent; !ts.isFunctionBlock(parent_10); parent_10 = parent_10.parent) {
// Reached source file or module block
- if (parent_8.kind === 248 /* SourceFile */ || parent_8.kind === 219 /* ModuleBlock */) {
+ if (parent_10.kind === 251 /* SourceFile */ || parent_10.kind === 222 /* ModuleBlock */) {
return false;
}
}
@@ -43679,7 +47416,6 @@ var ts;
// Always default to "ScriptTarget.ES5" for the language service
return {
target: 1 /* ES5 */,
- module: 0 /* None */,
jsx: 1 /* Preserve */
};
}
@@ -43690,13 +47426,15 @@ var ts;
var HostCache = (function () {
function HostCache(host, getCanonicalFileName) {
this.host = host;
+ this.getCanonicalFileName = getCanonicalFileName;
// script id => script index
- this.fileNameToEntry = ts.createFileMap(getCanonicalFileName);
+ this.currentDirectory = host.getCurrentDirectory();
+ this.fileNameToEntry = ts.createFileMap();
// Initialize the list with the root file names
var rootFileNames = host.getScriptFileNames();
- for (var _i = 0; _i < rootFileNames.length; _i++) {
- var fileName = rootFileNames[_i];
- this.createEntry(fileName);
+ for (var _i = 0, rootFileNames_1 = rootFileNames; _i < rootFileNames_1.length; _i++) {
+ var fileName = rootFileNames_1[_i];
+ this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName));
}
// store the compilation settings
this._compilationSettings = host.getCompilationSettings() || getDefaultCompilerOptions();
@@ -43704,7 +47442,7 @@ var ts;
HostCache.prototype.compilationSettings = function () {
return this._compilationSettings;
};
- HostCache.prototype.createEntry = function (fileName) {
+ HostCache.prototype.createEntry = function (fileName, path) {
var entry;
var scriptSnapshot = this.host.getScriptSnapshot(fileName);
if (scriptSnapshot) {
@@ -43714,40 +47452,41 @@ var ts;
scriptSnapshot: scriptSnapshot
};
}
- this.fileNameToEntry.set(fileName, entry);
+ this.fileNameToEntry.set(path, entry);
return entry;
};
- HostCache.prototype.getEntry = function (fileName) {
- return this.fileNameToEntry.get(fileName);
+ HostCache.prototype.getEntry = function (path) {
+ return this.fileNameToEntry.get(path);
};
- HostCache.prototype.contains = function (fileName) {
- return this.fileNameToEntry.contains(fileName);
+ HostCache.prototype.contains = function (path) {
+ return this.fileNameToEntry.contains(path);
};
HostCache.prototype.getOrCreateEntry = function (fileName) {
- if (this.contains(fileName)) {
- return this.getEntry(fileName);
+ var path = ts.toPath(fileName, this.currentDirectory, this.getCanonicalFileName);
+ if (this.contains(path)) {
+ return this.getEntry(path);
}
- return this.createEntry(fileName);
+ return this.createEntry(fileName, path);
};
HostCache.prototype.getRootFileNames = function () {
var fileNames = [];
- this.fileNameToEntry.forEachValue(function (value) {
+ this.fileNameToEntry.forEachValue(function (path, value) {
if (value) {
fileNames.push(value.hostFileName);
}
});
return fileNames;
};
- HostCache.prototype.getVersion = function (fileName) {
- var file = this.getEntry(fileName);
+ HostCache.prototype.getVersion = function (path) {
+ var file = this.getEntry(path);
return file && file.version;
};
- HostCache.prototype.getScriptSnapshot = function (fileName) {
- var file = this.getEntry(fileName);
+ HostCache.prototype.getScriptSnapshot = function (path) {
+ var file = this.getEntry(path);
return file && file.scriptSnapshot;
};
return HostCache;
- })();
+ }());
var SyntaxTreeCache = (function () {
function SyntaxTreeCache(host) {
this.host = host;
@@ -43762,7 +47501,7 @@ var ts;
var sourceFile;
if (this.currentFileName !== fileName) {
// This is a new file, just parse it
- sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2 /* Latest */, version, /*setNodeParents:*/ true);
+ sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2 /* Latest */, version, /*setNodeParents*/ true);
}
else if (this.currentFileVersion !== version) {
// This is the same file, just a newer version. Incrementally parse the file.
@@ -43779,7 +47518,7 @@ var ts;
return this.currentSourceFile;
};
return SyntaxTreeCache;
- })();
+ }());
function setSourceFileFields(sourceFile, scriptSnapshot, version) {
sourceFile.version = version;
sourceFile.scriptSnapshot = scriptSnapshot;
@@ -43796,6 +47535,8 @@ var ts;
function transpileModule(input, transpileOptions) {
var options = transpileOptions.compilerOptions ? ts.clone(transpileOptions.compilerOptions) : getDefaultCompilerOptions();
options.isolatedModules = true;
+ // transpileModule does not write anything to disk so there is no need to verify that there are no conflicts between input and output paths.
+ options.suppressOutputPathCheck = true;
// Filename can be non-ts file.
options.allowNonTsExtensions = true;
// We are not returning a sourceFile for lib file when asked by the program,
@@ -43824,7 +47565,7 @@ var ts;
sourceMapText = text;
}
else {
- ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name);
+ ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: '" + name + "'");
outputText = text;
}
},
@@ -43834,7 +47575,8 @@ var ts;
getCurrentDirectory: function () { return ""; },
getNewLine: function () { return newLine; },
fileExists: function (fileName) { return fileName === inputFileName; },
- readFile: function (fileName) { return ""; }
+ readFile: function (fileName) { return ""; },
+ directoryExists: function (directoryExists) { return true; }
};
var program = ts.createProgram([inputFileName], options, compilerHost);
var diagnostics;
@@ -43863,8 +47605,6 @@ var ts;
var text = scriptSnapshot.getText(0, scriptSnapshot.getLength());
var sourceFile = ts.createSourceFile(fileName, text, scriptTarget, setNodeParents);
setSourceFileFields(sourceFile, scriptSnapshot, version);
- // after full parsing we can use table with interned strings as name table
- sourceFile.nameTable = sourceFile.identifiers;
return sourceFile;
}
ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile;
@@ -43876,7 +47616,7 @@ var ts;
if (version !== sourceFile.version) {
// Once incremental parsing is ready, then just call into this function.
if (!ts.disableIncrementalParsing) {
- var newText;
+ var newText = void 0;
// grab the fragment from the beginning of the original text to the beginning of the span
var prefix = textChangeRange.span.start !== 0
? sourceFile.text.substr(0, textChangeRange.span.start)
@@ -43916,70 +47656,65 @@ var ts;
}
}
// Otherwise, just create a new source file.
- return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents:*/ true);
+ return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents*/ true);
}
ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile;
- function createGetCanonicalFileName(useCaseSensitivefileNames) {
- return useCaseSensitivefileNames
- ? (function (fileName) { return fileName; })
- : (function (fileName) { return fileName.toLowerCase(); });
- }
- ts.createGetCanonicalFileName = createGetCanonicalFileName;
- function createDocumentRegistry(useCaseSensitiveFileNames) {
+ function createDocumentRegistry(useCaseSensitiveFileNames, currentDirectory) {
+ if (currentDirectory === void 0) { currentDirectory = ""; }
// Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have
// for those settings.
var buckets = {};
- var getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames);
+ var getCanonicalFileName = ts.createGetCanonicalFileName(!!useCaseSensitiveFileNames);
function getKeyFromCompilationSettings(settings) {
- return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx;
+ return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx + +"|" + settings.allowJs;
}
function getBucketForCompilationSettings(settings, createIfMissing) {
var key = getKeyFromCompilationSettings(settings);
var bucket = ts.lookUp(buckets, key);
if (!bucket && createIfMissing) {
- buckets[key] = bucket = ts.createFileMap(getCanonicalFileName);
+ buckets[key] = bucket = ts.createFileMap();
}
return bucket;
}
function reportStats() {
- var bucketInfoArray = Object.keys(buckets).filter(function (name) { return name && name.charAt(0) === '_'; }).map(function (name) {
+ var bucketInfoArray = Object.keys(buckets).filter(function (name) { return name && name.charAt(0) === "_"; }).map(function (name) {
var entries = ts.lookUp(buckets, name);
var sourceFiles = [];
- for (var i in entries) {
- var entry = entries.get(i);
+ entries.forEachValue(function (key, entry) {
sourceFiles.push({
- name: i,
+ name: key,
refCount: entry.languageServiceRefCount,
references: entry.owners.slice(0)
});
- }
+ });
sourceFiles.sort(function (x, y) { return y.refCount - x.refCount; });
return {
bucket: name,
sourceFiles: sourceFiles
};
});
- return JSON.stringify(bucketInfoArray, null, 2);
+ return JSON.stringify(bucketInfoArray, undefined, 2);
}
function acquireDocument(fileName, compilationSettings, scriptSnapshot, version) {
- return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring:*/ true);
+ return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring*/ true);
}
function updateDocument(fileName, compilationSettings, scriptSnapshot, version) {
- return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring:*/ false);
+ return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring*/ false);
}
function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) {
var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true);
- var entry = bucket.get(fileName);
+ var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
+ var entry = bucket.get(path);
if (!entry) {
ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?");
// Have never seen this file with these settings. Create a new source file for it.
- var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, /*setNodeParents:*/ false);
+ var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, /*setNodeParents*/ false);
entry = {
sourceFile: sourceFile,
languageServiceRefCount: 0,
owners: []
};
- bucket.set(fileName, entry);
+ bucket.set(path, entry);
}
else {
// We have an entry for this file. However, it may be for a different version of
@@ -44000,13 +47735,14 @@ var ts;
return entry.sourceFile;
}
function releaseDocument(fileName, compilationSettings) {
- var bucket = getBucketForCompilationSettings(compilationSettings, false);
+ var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ false);
ts.Debug.assert(bucket !== undefined);
- var entry = bucket.get(fileName);
+ var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
+ var entry = bucket.get(path);
entry.languageServiceRefCount--;
ts.Debug.assert(entry.languageServiceRefCount >= 0);
if (entry.languageServiceRefCount === 0) {
- bucket.remove(fileName);
+ bucket.remove(path);
}
}
return {
@@ -44017,8 +47753,9 @@ var ts;
};
}
ts.createDocumentRegistry = createDocumentRegistry;
- function preProcessFile(sourceText, readImportFiles) {
+ function preProcessFile(sourceText, readImportFiles, detectJavaScriptImports) {
if (readImportFiles === void 0) { readImportFiles = true; }
+ if (detectJavaScriptImports === void 0) { detectJavaScriptImports = false; }
var referencedFiles = [];
var importedFiles = [];
var ambientExternalModules;
@@ -44052,116 +47789,66 @@ var ts;
end: pos + importPath.length
});
}
- function processImport() {
- scanner.setText(sourceText);
- var token = scanner.scan();
- // Look for:
- // import "mod";
- // import d from "mod"
- // import {a as A } from "mod";
- // import * as NS from "mod"
- // import d, {a, b as B} from "mod"
- // import i = require("mod");
- //
- // export * from "mod"
- // export {a as b} from "mod"
- // export import i = require("mod")
- while (token !== 1 /* EndOfFileToken */) {
- if (token === 122 /* DeclareKeyword */) {
- // declare module "mod"
- token = scanner.scan();
- if (token === 125 /* ModuleKeyword */) {
- token = scanner.scan();
- if (token === 9 /* StringLiteral */) {
- recordAmbientExternalModule();
- continue;
- }
- }
- }
- else if (token === 89 /* ImportKeyword */) {
+ /**
+ * Returns true if at least one token was consumed from the stream
+ */
+ function tryConsumeDeclare() {
+ var token = scanner.getToken();
+ if (token === 122 /* DeclareKeyword */) {
+ // declare module "mod"
+ token = scanner.scan();
+ if (token === 125 /* ModuleKeyword */) {
token = scanner.scan();
if (token === 9 /* StringLiteral */) {
- // import "mod";
- recordModuleName();
- continue;
+ recordAmbientExternalModule();
}
- else {
- if (token === 69 /* Identifier */ || ts.isKeyword(token)) {
+ }
+ return true;
+ }
+ return false;
+ }
+ /**
+ * Returns true if at least one token was consumed from the stream
+ */
+ function tryConsumeImport() {
+ var token = scanner.getToken();
+ if (token === 89 /* ImportKeyword */) {
+ token = scanner.scan();
+ if (token === 9 /* StringLiteral */) {
+ // import "mod";
+ recordModuleName();
+ return true;
+ }
+ else {
+ if (token === 69 /* Identifier */ || ts.isKeyword(token)) {
+ token = scanner.scan();
+ if (token === 133 /* FromKeyword */) {
token = scanner.scan();
- if (token === 133 /* FromKeyword */) {
- token = scanner.scan();
- if (token === 9 /* StringLiteral */) {
- // import d from "mod";
- recordModuleName();
- continue;
- }
- }
- else if (token === 56 /* EqualsToken */) {
- token = scanner.scan();
- if (token === 127 /* RequireKeyword */) {
- token = scanner.scan();
- if (token === 17 /* OpenParenToken */) {
- token = scanner.scan();
- if (token === 9 /* StringLiteral */) {
- // import i = require("mod");
- recordModuleName();
- continue;
- }
- }
- }
- }
- else if (token === 24 /* CommaToken */) {
- // consume comma and keep going
- token = scanner.scan();
- }
- else {
- // unknown syntax
- continue;
+ if (token === 9 /* StringLiteral */) {
+ // import d from "mod";
+ recordModuleName();
+ return true;
}
}
- if (token === 15 /* OpenBraceToken */) {
- token = scanner.scan();
- // consume "{ a as B, c, d as D}" clauses
- while (token !== 16 /* CloseBraceToken */) {
- token = scanner.scan();
- }
- if (token === 16 /* CloseBraceToken */) {
- token = scanner.scan();
- if (token === 133 /* FromKeyword */) {
- token = scanner.scan();
- if (token === 9 /* StringLiteral */) {
- // import {a as A} from "mod";
- // import d, {a, b as B} from "mod"
- recordModuleName();
- }
- }
+ else if (token === 56 /* EqualsToken */) {
+ if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) {
+ return true;
}
}
- else if (token === 37 /* AsteriskToken */) {
+ else if (token === 24 /* CommaToken */) {
+ // consume comma and keep going
token = scanner.scan();
- if (token === 116 /* AsKeyword */) {
- token = scanner.scan();
- if (token === 69 /* Identifier */ || ts.isKeyword(token)) {
- token = scanner.scan();
- if (token === 133 /* FromKeyword */) {
- token = scanner.scan();
- if (token === 9 /* StringLiteral */) {
- // import * as NS from "mod"
- // import d, * as NS from "mod"
- recordModuleName();
- }
- }
- }
- }
+ }
+ else {
+ // unknown syntax
+ return true;
}
}
- }
- else if (token === 82 /* ExportKeyword */) {
- token = scanner.scan();
if (token === 15 /* OpenBraceToken */) {
token = scanner.scan();
// consume "{ a as B, c, d as D}" clauses
- while (token !== 16 /* CloseBraceToken */) {
+ // make sure that it stops on EOF
+ while (token !== 16 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) {
token = scanner.scan();
}
if (token === 16 /* CloseBraceToken */) {
@@ -44169,49 +47856,171 @@ var ts;
if (token === 133 /* FromKeyword */) {
token = scanner.scan();
if (token === 9 /* StringLiteral */) {
- // export {a as A} from "mod";
- // export {a, b as B} from "mod"
+ // import {a as A} from "mod";
+ // import d, {a, b as B} from "mod"
recordModuleName();
}
}
}
}
else if (token === 37 /* AsteriskToken */) {
+ token = scanner.scan();
+ if (token === 116 /* AsKeyword */) {
+ token = scanner.scan();
+ if (token === 69 /* Identifier */ || ts.isKeyword(token)) {
+ token = scanner.scan();
+ if (token === 133 /* FromKeyword */) {
+ token = scanner.scan();
+ if (token === 9 /* StringLiteral */) {
+ // import * as NS from "mod"
+ // import d, * as NS from "mod"
+ recordModuleName();
+ }
+ }
+ }
+ }
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+ function tryConsumeExport() {
+ var token = scanner.getToken();
+ if (token === 82 /* ExportKeyword */) {
+ token = scanner.scan();
+ if (token === 15 /* OpenBraceToken */) {
+ token = scanner.scan();
+ // consume "{ a as B, c, d as D}" clauses
+ // make sure it stops on EOF
+ while (token !== 16 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) {
+ token = scanner.scan();
+ }
+ if (token === 16 /* CloseBraceToken */) {
token = scanner.scan();
if (token === 133 /* FromKeyword */) {
token = scanner.scan();
if (token === 9 /* StringLiteral */) {
- // export * from "mod"
+ // export {a as A} from "mod";
+ // export {a, b as B} from "mod"
recordModuleName();
}
}
}
- else if (token === 89 /* ImportKeyword */) {
+ }
+ else if (token === 37 /* AsteriskToken */) {
+ token = scanner.scan();
+ if (token === 133 /* FromKeyword */) {
token = scanner.scan();
- if (token === 69 /* Identifier */ || ts.isKeyword(token)) {
- token = scanner.scan();
- if (token === 56 /* EqualsToken */) {
- token = scanner.scan();
- if (token === 127 /* RequireKeyword */) {
- token = scanner.scan();
- if (token === 17 /* OpenParenToken */) {
- token = scanner.scan();
- if (token === 9 /* StringLiteral */) {
- // export import i = require("mod");
- recordModuleName();
- }
- }
- }
+ if (token === 9 /* StringLiteral */) {
+ // export * from "mod"
+ recordModuleName();
+ }
+ }
+ }
+ else if (token === 89 /* ImportKeyword */) {
+ token = scanner.scan();
+ if (token === 69 /* Identifier */ || ts.isKeyword(token)) {
+ token = scanner.scan();
+ if (token === 56 /* EqualsToken */) {
+ if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) {
+ return true;
}
}
}
}
+ return true;
+ }
+ return false;
+ }
+ function tryConsumeRequireCall(skipCurrentToken) {
+ var token = skipCurrentToken ? scanner.scan() : scanner.getToken();
+ if (token === 127 /* RequireKeyword */) {
+ token = scanner.scan();
+ if (token === 17 /* OpenParenToken */) {
+ token = scanner.scan();
+ if (token === 9 /* StringLiteral */) {
+ // require("mod");
+ recordModuleName();
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+ function tryConsumeDefine() {
+ var token = scanner.getToken();
+ if (token === 69 /* Identifier */ && scanner.getTokenValue() === "define") {
+ token = scanner.scan();
+ if (token !== 17 /* OpenParenToken */) {
+ return true;
+ }
+ token = scanner.scan();
+ if (token === 9 /* StringLiteral */) {
+ // looks like define ("modname", ... - skip string literal and comma
+ token = scanner.scan();
+ if (token === 24 /* CommaToken */) {
+ token = scanner.scan();
+ }
+ else {
+ // unexpected token
+ return true;
+ }
+ }
+ // should be start of dependency list
+ if (token !== 19 /* OpenBracketToken */) {
+ return true;
+ }
+ // skip open bracket
token = scanner.scan();
+ var i = 0;
+ // scan until ']' or EOF
+ while (token !== 20 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) {
+ // record string literals as module names
+ if (token === 9 /* StringLiteral */) {
+ recordModuleName();
+ i++;
+ }
+ token = scanner.scan();
+ }
+ return true;
+ }
+ return false;
+ }
+ function processImports() {
+ scanner.setText(sourceText);
+ scanner.scan();
+ // Look for:
+ // import "mod";
+ // import d from "mod"
+ // import {a as A } from "mod";
+ // import * as NS from "mod"
+ // import d, {a, b as B} from "mod"
+ // import i = require("mod");
+ //
+ // export * from "mod"
+ // export {a as b} from "mod"
+ // export import i = require("mod")
+ // (for JavaScript files) require("mod")
+ while (true) {
+ if (scanner.getToken() === 1 /* EndOfFileToken */) {
+ break;
+ }
+ // check if at least one of alternative have moved scanner forward
+ if (tryConsumeDeclare() ||
+ tryConsumeImport() ||
+ tryConsumeExport() ||
+ (detectJavaScriptImports && (tryConsumeRequireCall(/*skipCurrentToken*/ false) || tryConsumeDefine()))) {
+ continue;
+ }
+ else {
+ scanner.scan();
+ }
}
scanner.setText(undefined);
}
if (readImportFiles) {
- processImport();
+ processImports();
}
processTripleSlashDirectives();
return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: ambientExternalModules };
@@ -44220,7 +48029,7 @@ var ts;
/// Helpers
function getTargetLabel(referenceNode, labelName) {
while (referenceNode) {
- if (referenceNode.kind === 207 /* LabeledStatement */ && referenceNode.label.text === labelName) {
+ if (referenceNode.kind === 210 /* LabeledStatement */ && referenceNode.label.text === labelName) {
return referenceNode.label;
}
referenceNode = referenceNode.parent;
@@ -44229,12 +48038,12 @@ var ts;
}
function isJumpStatementTarget(node) {
return node.kind === 69 /* Identifier */ &&
- (node.parent.kind === 203 /* BreakStatement */ || node.parent.kind === 202 /* ContinueStatement */) &&
+ (node.parent.kind === 206 /* BreakStatement */ || node.parent.kind === 205 /* ContinueStatement */) &&
node.parent.label === node;
}
function isLabelOfLabeledStatement(node) {
return node.kind === 69 /* Identifier */ &&
- node.parent.kind === 207 /* LabeledStatement */ &&
+ node.parent.kind === 210 /* LabeledStatement */ &&
node.parent.label === node;
}
/**
@@ -44242,7 +48051,7 @@ var ts;
* Note: 'node' cannot be a SourceFile.
*/
function isLabeledBy(node, labelName) {
- for (var owner = node.parent; owner.kind === 207 /* LabeledStatement */; owner = owner.parent) {
+ for (var owner = node.parent; owner.kind === 210 /* LabeledStatement */; owner = owner.parent) {
if (owner.label.text === labelName) {
return true;
}
@@ -44253,25 +48062,25 @@ var ts;
return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node);
}
function isRightSideOfQualifiedName(node) {
- return node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node;
+ return node.parent.kind === 136 /* QualifiedName */ && node.parent.right === node;
}
function isRightSideOfPropertyAccess(node) {
- return node && node.parent && node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.name === node;
+ return node && node.parent && node.parent.kind === 169 /* PropertyAccessExpression */ && node.parent.name === node;
}
function isCallExpressionTarget(node) {
if (isRightSideOfPropertyAccess(node)) {
node = node.parent;
}
- return node && node.parent && node.parent.kind === 168 /* CallExpression */ && node.parent.expression === node;
+ return node && node.parent && node.parent.kind === 171 /* CallExpression */ && node.parent.expression === node;
}
function isNewExpressionTarget(node) {
if (isRightSideOfPropertyAccess(node)) {
node = node.parent;
}
- return node && node.parent && node.parent.kind === 169 /* NewExpression */ && node.parent.expression === node;
+ return node && node.parent && node.parent.kind === 172 /* NewExpression */ && node.parent.expression === node;
}
function isNameOfModuleDeclaration(node) {
- return node.parent.kind === 218 /* ModuleDeclaration */ && node.parent.name === node;
+ return node.parent.kind === 221 /* ModuleDeclaration */ && node.parent.name === node;
}
function isNameOfFunctionDeclaration(node) {
return node.kind === 69 /* Identifier */ &&
@@ -44280,22 +48089,22 @@ var ts;
/** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */
function isNameOfPropertyAssignment(node) {
return (node.kind === 69 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) &&
- (node.parent.kind === 245 /* PropertyAssignment */ || node.parent.kind === 246 /* ShorthandPropertyAssignment */) && node.parent.name === node;
+ (node.parent.kind === 248 /* PropertyAssignment */ || node.parent.kind === 249 /* ShorthandPropertyAssignment */) && node.parent.name === node;
}
function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) {
if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) {
switch (node.parent.kind) {
- case 141 /* PropertyDeclaration */:
- case 140 /* PropertySignature */:
- case 245 /* PropertyAssignment */:
- case 247 /* EnumMember */:
- case 143 /* MethodDeclaration */:
- case 142 /* MethodSignature */:
- case 145 /* GetAccessor */:
- case 146 /* SetAccessor */:
- case 218 /* ModuleDeclaration */:
+ case 142 /* PropertyDeclaration */:
+ case 141 /* PropertySignature */:
+ case 248 /* PropertyAssignment */:
+ case 250 /* EnumMember */:
+ case 144 /* MethodDeclaration */:
+ case 143 /* MethodSignature */:
+ case 146 /* GetAccessor */:
+ case 147 /* SetAccessor */:
+ case 221 /* ModuleDeclaration */:
return node.parent.name === node;
- case 167 /* ElementAccessExpression */:
+ case 170 /* ElementAccessExpression */:
return node.parent.argumentExpression === node;
}
}
@@ -44354,7 +48163,7 @@ var ts;
})(BreakContinueSearchType || (BreakContinueSearchType = {}));
// A cache of completion entries for keywords, these do not change between sessions
var keywordCompletions = [];
- for (var i = 70 /* FirstKeyword */; i <= 134 /* LastKeyword */; i++) {
+ for (var i = 70 /* FirstKeyword */; i <= 135 /* LastKeyword */; i++) {
keywordCompletions.push({
name: ts.tokenToString(i),
kind: ScriptElementKind.keyword,
@@ -44369,17 +48178,17 @@ var ts;
return undefined;
}
switch (node.kind) {
- case 248 /* SourceFile */:
- case 143 /* MethodDeclaration */:
- case 142 /* MethodSignature */:
- case 213 /* FunctionDeclaration */:
- case 173 /* FunctionExpression */:
- case 145 /* GetAccessor */:
- case 146 /* SetAccessor */:
- case 214 /* ClassDeclaration */:
- case 215 /* InterfaceDeclaration */:
- case 217 /* EnumDeclaration */:
- case 218 /* ModuleDeclaration */:
+ case 251 /* SourceFile */:
+ case 144 /* MethodDeclaration */:
+ case 143 /* MethodSignature */:
+ case 216 /* FunctionDeclaration */:
+ case 176 /* FunctionExpression */:
+ case 146 /* GetAccessor */:
+ case 147 /* SetAccessor */:
+ case 217 /* ClassDeclaration */:
+ case 218 /* InterfaceDeclaration */:
+ case 220 /* EnumDeclaration */:
+ case 221 /* ModuleDeclaration */:
return node;
}
}
@@ -44387,38 +48196,38 @@ var ts;
ts.getContainerNode = getContainerNode;
/* @internal */ function getNodeKind(node) {
switch (node.kind) {
- case 218 /* ModuleDeclaration */: return ScriptElementKind.moduleElement;
- case 214 /* ClassDeclaration */: return ScriptElementKind.classElement;
- case 215 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement;
- case 216 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement;
- case 217 /* EnumDeclaration */: return ScriptElementKind.enumElement;
- case 211 /* VariableDeclaration */:
+ case 221 /* ModuleDeclaration */: return ScriptElementKind.moduleElement;
+ case 217 /* ClassDeclaration */: return ScriptElementKind.classElement;
+ case 218 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement;
+ case 219 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement;
+ case 220 /* EnumDeclaration */: return ScriptElementKind.enumElement;
+ case 214 /* VariableDeclaration */:
return ts.isConst(node)
? ScriptElementKind.constElement
: ts.isLet(node)
? ScriptElementKind.letElement
: ScriptElementKind.variableElement;
- case 213 /* FunctionDeclaration */: return ScriptElementKind.functionElement;
- case 145 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement;
- case 146 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement;
- case 143 /* MethodDeclaration */:
- case 142 /* MethodSignature */:
+ case 216 /* FunctionDeclaration */: return ScriptElementKind.functionElement;
+ case 146 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement;
+ case 147 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement;
+ case 144 /* MethodDeclaration */:
+ case 143 /* MethodSignature */:
return ScriptElementKind.memberFunctionElement;
- case 141 /* PropertyDeclaration */:
- case 140 /* PropertySignature */:
+ case 142 /* PropertyDeclaration */:
+ case 141 /* PropertySignature */:
return ScriptElementKind.memberVariableElement;
- case 149 /* IndexSignature */: return ScriptElementKind.indexSignatureElement;
- case 148 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement;
- case 147 /* CallSignature */: return ScriptElementKind.callSignatureElement;
- case 144 /* Constructor */: return ScriptElementKind.constructorImplementationElement;
- case 137 /* TypeParameter */: return ScriptElementKind.typeParameterElement;
- case 247 /* EnumMember */: return ScriptElementKind.variableElement;
- case 138 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement;
- case 221 /* ImportEqualsDeclaration */:
- case 226 /* ImportSpecifier */:
- case 223 /* ImportClause */:
- case 230 /* ExportSpecifier */:
- case 224 /* NamespaceImport */:
+ case 150 /* IndexSignature */: return ScriptElementKind.indexSignatureElement;
+ case 149 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement;
+ case 148 /* CallSignature */: return ScriptElementKind.callSignatureElement;
+ case 145 /* Constructor */: return ScriptElementKind.constructorImplementationElement;
+ case 138 /* TypeParameter */: return ScriptElementKind.typeParameterElement;
+ case 250 /* EnumMember */: return ScriptElementKind.variableElement;
+ case 139 /* Parameter */: return (node.flags & 56 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement;
+ case 224 /* ImportEqualsDeclaration */:
+ case 229 /* ImportSpecifier */:
+ case 226 /* ImportClause */:
+ case 233 /* ExportSpecifier */:
+ case 227 /* NamespaceImport */:
return ScriptElementKind.alias;
}
return ScriptElementKind.unknown;
@@ -44437,15 +48246,16 @@ var ts;
}
};
return CancellationTokenObject;
- })();
+ }());
function createLanguageService(host, documentRegistry) {
- if (documentRegistry === void 0) { documentRegistry = createDocumentRegistry(); }
+ if (documentRegistry === void 0) { documentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); }
var syntaxTreeCache = new SyntaxTreeCache(host);
var ruleProvider;
var program;
var lastProjectVersion;
var useCaseSensitivefileNames = false;
var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken());
+ var currentDirectory = host.getCurrentDirectory();
// Check if the localized messages json is set, otherwise query the host for it
if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) {
ts.localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages();
@@ -44455,10 +48265,9 @@ var ts;
host.log(message);
}
}
- var getCanonicalFileName = createGetCanonicalFileName(useCaseSensitivefileNames);
+ var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitivefileNames);
function getValidSourceFile(fileName) {
- fileName = ts.normalizeSlashes(fileName);
- var sourceFile = program.getSourceFile(getCanonicalFileName(fileName));
+ var sourceFile = program.getSourceFile(fileName);
if (!sourceFile) {
throw new Error("Could not find file: '" + fileName + "'.");
}
@@ -44500,7 +48309,8 @@ var ts;
(oldSettings.target !== newSettings.target ||
oldSettings.module !== newSettings.module ||
oldSettings.noResolve !== newSettings.noResolve ||
- oldSettings.jsx !== newSettings.jsx);
+ oldSettings.jsx !== newSettings.jsx ||
+ oldSettings.allowJs !== newSettings.allowJs);
// Now create a new compiler
var compilerHost = {
getSourceFile: getOrCreateSourceFile,
@@ -44510,7 +48320,7 @@ var ts;
getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); },
getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); },
writeFile: function (fileName, data, writeByteOrderMark) { },
- getCurrentDirectory: function () { return host.getCurrentDirectory(); },
+ getCurrentDirectory: function () { return currentDirectory; },
fileExists: function (fileName) {
// stub missing host functionality
ts.Debug.assert(!host.resolveModuleNames);
@@ -44520,6 +48330,10 @@ var ts;
// stub missing host functionality
var entry = hostCache.getOrCreateEntry(fileName);
return entry && entry.scriptSnapshot.getText(0, entry.scriptSnapshot.getLength());
+ },
+ directoryExists: function (directoryName) {
+ ts.Debug.assert(!host.resolveModuleNames);
+ return ts.directoryProbablyExists(directoryName, host);
}
};
if (host.resolveModuleNames) {
@@ -44530,11 +48344,10 @@ var ts;
// not part of the new program.
if (program) {
var oldSourceFiles = program.getSourceFiles();
- for (var _i = 0; _i < oldSourceFiles.length; _i++) {
- var oldSourceFile = oldSourceFiles[_i];
- var fileName = oldSourceFile.fileName;
- if (!newProgram.getSourceFile(fileName) || changesInCompilationSettingsAffectSyntax) {
- documentRegistry.releaseDocument(fileName, oldSettings);
+ for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) {
+ var oldSourceFile = oldSourceFiles_1[_i];
+ if (!newProgram.getSourceFile(oldSourceFile.fileName) || changesInCompilationSettingsAffectSyntax) {
+ documentRegistry.releaseDocument(oldSourceFile.fileName, oldSettings);
}
}
}
@@ -44590,7 +48403,11 @@ var ts;
return documentRegistry.acquireDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version);
}
function sourceFileUpToDate(sourceFile) {
- return sourceFile && sourceFile.version === hostCache.getVersion(sourceFile.fileName);
+ if (!sourceFile) {
+ return false;
+ }
+ var path = sourceFile.path || ts.toPath(sourceFile.fileName, currentDirectory, getCanonicalFileName);
+ return sourceFile.version === hostCache.getVersion(path);
}
function programUpToDate() {
// If we haven't create a program yet, then it is not up-to-date
@@ -44603,8 +48420,8 @@ var ts;
return false;
}
// If any file is not up-to-date, then the whole program is not up-to-date
- for (var _i = 0; _i < rootFileNames.length; _i++) {
- var fileName = rootFileNames[_i];
+ for (var _i = 0, rootFileNames_2 = rootFileNames; _i < rootFileNames_2.length; _i++) {
+ var fileName = rootFileNames_2[_i];
if (!sourceFileUpToDate(program.getSourceFile(fileName))) {
return false;
}
@@ -44639,12 +48456,6 @@ var ts;
function getSemanticDiagnostics(fileName) {
synchronizeHostData();
var targetSourceFile = getValidSourceFile(fileName);
- // For JavaScript files, we don't want to report the normal typescript semantic errors.
- // Instead, we just report errors for using TypeScript-only constructs from within a
- // JavaScript file.
- if (ts.isJavaScript(fileName)) {
- return getJavaScriptSemanticDiagnostics(targetSourceFile);
- }
// Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file.
// Therefore only get diagnostics for given file.
var semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile, cancellationToken);
@@ -44655,151 +48466,6 @@ var ts;
var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken);
return ts.concatenate(semanticDiagnostics, declarationDiagnostics);
}
- function getJavaScriptSemanticDiagnostics(sourceFile) {
- var diagnostics = [];
- walk(sourceFile);
- return diagnostics;
- function walk(node) {
- if (!node) {
- return false;
- }
- switch (node.kind) {
- case 221 /* ImportEqualsDeclaration */:
- diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file));
- return true;
- case 227 /* ExportAssignment */:
- diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file));
- return true;
- case 214 /* ClassDeclaration */:
- var classDeclaration = node;
- if (checkModifiers(classDeclaration.modifiers) ||
- checkTypeParameters(classDeclaration.typeParameters)) {
- return true;
- }
- break;
- case 243 /* HeritageClause */:
- var heritageClause = node;
- if (heritageClause.token === 106 /* ImplementsKeyword */) {
- diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file));
- return true;
- }
- break;
- case 215 /* InterfaceDeclaration */:
- diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file));
- return true;
- case 218 /* ModuleDeclaration */:
- diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file));
- return true;
- case 216 /* TypeAliasDeclaration */:
- diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file));
- return true;
- case 143 /* MethodDeclaration */:
- case 142 /* MethodSignature */:
- case 144 /* Constructor */:
- case 145 /* GetAccessor */:
- case 146 /* SetAccessor */:
- case 173 /* FunctionExpression */:
- case 213 /* FunctionDeclaration */:
- case 174 /* ArrowFunction */:
- case 213 /* FunctionDeclaration */:
- var functionDeclaration = node;
- if (checkModifiers(functionDeclaration.modifiers) ||
- checkTypeParameters(functionDeclaration.typeParameters) ||
- checkTypeAnnotation(functionDeclaration.type)) {
- return true;
- }
- break;
- case 193 /* VariableStatement */:
- var variableStatement = node;
- if (checkModifiers(variableStatement.modifiers)) {
- return true;
- }
- break;
- case 211 /* VariableDeclaration */:
- var variableDeclaration = node;
- if (checkTypeAnnotation(variableDeclaration.type)) {
- return true;
- }
- break;
- case 168 /* CallExpression */:
- case 169 /* NewExpression */:
- var expression = node;
- if (expression.typeArguments && expression.typeArguments.length > 0) {
- var start = expression.typeArguments.pos;
- diagnostics.push(ts.createFileDiagnostic(sourceFile, start, expression.typeArguments.end - start, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file));
- return true;
- }
- break;
- case 138 /* Parameter */:
- var parameter = node;
- if (parameter.modifiers) {
- var start = parameter.modifiers.pos;
- diagnostics.push(ts.createFileDiagnostic(sourceFile, start, parameter.modifiers.end - start, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file));
- return true;
- }
- if (parameter.questionToken) {
- diagnostics.push(ts.createDiagnosticForNode(parameter.questionToken, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, '?'));
- return true;
- }
- if (parameter.type) {
- diagnostics.push(ts.createDiagnosticForNode(parameter.type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file));
- return true;
- }
- break;
- case 141 /* PropertyDeclaration */:
- diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file));
- return true;
- case 217 /* EnumDeclaration */:
- diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file));
- return true;
- case 171 /* TypeAssertionExpression */:
- var typeAssertionExpression = node;
- diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file));
- return true;
- case 139 /* Decorator */:
- diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file));
- return true;
- }
- return ts.forEachChild(node, walk);
- }
- function checkTypeParameters(typeParameters) {
- if (typeParameters) {
- var start = typeParameters.pos;
- diagnostics.push(ts.createFileDiagnostic(sourceFile, start, typeParameters.end - start, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file));
- return true;
- }
- return false;
- }
- function checkTypeAnnotation(type) {
- if (type) {
- diagnostics.push(ts.createDiagnosticForNode(type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file));
- return true;
- }
- return false;
- }
- function checkModifiers(modifiers) {
- if (modifiers) {
- for (var _i = 0; _i < modifiers.length; _i++) {
- var modifier = modifiers[_i];
- switch (modifier.kind) {
- case 112 /* PublicKeyword */:
- case 110 /* PrivateKeyword */:
- case 111 /* ProtectedKeyword */:
- case 122 /* DeclareKeyword */:
- diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind)));
- return true;
- // These are all legal modifiers.
- case 113 /* StaticKeyword */:
- case 82 /* ExportKeyword */:
- case 74 /* ConstKeyword */:
- case 77 /* DefaultKeyword */:
- case 115 /* AbstractKeyword */:
- }
- }
- }
- return false;
- }
- }
function getCompilerOptionsDiagnostics() {
synchronizeHostData();
return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken));
@@ -44816,7 +48482,7 @@ var ts;
// First check of the displayName is not external module; if it is an external module, it is not valid entry
if ((symbol.flags & 1536 /* Namespace */) && (firstCharCode === 39 /* singleQuote */ || firstCharCode === 34 /* doubleQuote */)) {
// If the symbol is external module, don't show it in the completion list
- // (i.e declare module "http" { let x; } | // <= request completion here, "http" should not be there)
+ // (i.e declare module "http" { const x; } | // <= request completion here, "http" should not be there)
return undefined;
}
}
@@ -44839,22 +48505,16 @@ var ts;
// e.g "b a" is valid quoted name but when we strip off the quotes, it is invalid.
// We, thus, need to check if whatever was inside the quotes is actually a valid identifier name.
if (performCharacterChecks) {
- if (!ts.isIdentifierStart(name.charCodeAt(0), target)) {
+ if (!ts.isIdentifier(name, target)) {
return undefined;
}
- for (var i = 1, n = name.length; i < n; i++) {
- if (!ts.isIdentifierPart(name.charCodeAt(i), target)) {
- return undefined;
- }
- }
}
return name;
}
function getCompletionData(fileName, position) {
var typeChecker = program.getTypeChecker();
- var syntacticStart = new Date().getTime();
var sourceFile = getValidSourceFile(fileName);
- var isJavaScriptFile = ts.isJavaScript(fileName);
+ var isJavaScriptFile = ts.isSourceFileJavaScript(sourceFile);
var isJsDocTagName = false;
var start = new Date().getTime();
var currentToken = ts.getTokenAtPosition(sourceFile, position);
@@ -44864,7 +48524,7 @@ var ts;
var insideComment = isInsideComment(sourceFile, currentToken, position);
log("getCompletionData: Is inside comment: " + (new Date().getTime() - start));
if (insideComment) {
- // The current position is next to the '@' sign, when no tag name being provided yet.
+ // The current position is next to the '@' sign, when no tag name being provided yet.
// Provide a full list of tag names
if (ts.hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === 64 /* at */) {
isJsDocTagName = true;
@@ -44879,9 +48539,9 @@ var ts;
isJsDocTagName = true;
}
switch (tag.kind) {
- case 269 /* JSDocTypeTag */:
- case 267 /* JSDocParameterTag */:
- case 268 /* JSDocReturnTag */:
+ case 272 /* JSDocTypeTag */:
+ case 270 /* JSDocParameterTag */:
+ case 271 /* JSDocReturnTag */:
var tagWithExpression = tag;
if (tagWithExpression.typeExpression) {
insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end;
@@ -44893,7 +48553,7 @@ var ts;
return { symbols: undefined, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName: isJsDocTagName };
}
if (!insideJsDocTagExpression) {
- // Proceed if the current position is in jsDoc tag expression; otherwise it is a normal
+ // Proceed if the current position is in jsDoc tag expression; otherwise it is a normal
// comment or the plain text part of a jsDoc comment, so no completion should be available
log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment.");
return undefined;
@@ -44908,9 +48568,9 @@ var ts;
// Check if the caret is at the end of an identifier; this is a partial identifier that we want to complete: e.g. a.toS|
// Skip this partial identifier and adjust the contextToken to the token that precedes it.
if (contextToken && position <= contextToken.end && ts.isWord(contextToken.kind)) {
- var start_3 = new Date().getTime();
+ var start_6 = new Date().getTime();
contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile);
- log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_3));
+ log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_6));
}
// Find the node where completion is requested on.
// Also determine whether we are trying to complete with members of that node
@@ -44926,13 +48586,13 @@ var ts;
log("Returning an empty list because completion was requested in an invalid position.");
return undefined;
}
- var parent_9 = contextToken.parent, kind = contextToken.kind;
+ var parent_11 = contextToken.parent, kind = contextToken.kind;
if (kind === 21 /* DotToken */) {
- if (parent_9.kind === 166 /* PropertyAccessExpression */) {
+ if (parent_11.kind === 169 /* PropertyAccessExpression */) {
node = contextToken.parent.expression;
isRightOfDot = true;
}
- else if (parent_9.kind === 135 /* QualifiedName */) {
+ else if (parent_11.kind === 136 /* QualifiedName */) {
node = contextToken.parent.left;
isRightOfDot = true;
}
@@ -44947,8 +48607,9 @@ var ts;
isRightOfOpenTag = true;
location = contextToken;
}
- else if (kind === 39 /* SlashToken */ && contextToken.parent.kind === 237 /* JsxClosingElement */) {
+ else if (kind === 39 /* SlashToken */ && contextToken.parent.kind === 240 /* JsxClosingElement */) {
isStartingCloseTag = true;
+ location = contextToken;
}
}
}
@@ -44972,7 +48633,10 @@ var ts;
}
else if (isStartingCloseTag) {
var tagName = contextToken.parent.parent.openingElement.tagName;
- symbols = [typeChecker.getSymbolAtLocation(tagName)];
+ var tagSymbol = typeChecker.getSymbolAtLocation(tagName);
+ if (!typeChecker.isUnknownSymbol(tagSymbol)) {
+ symbols = [tagSymbol];
+ }
isMemberCompletion = true;
isNewIdentifierLocation = false;
}
@@ -44990,7 +48654,7 @@ var ts;
// Right of dot member completion list
isMemberCompletion = true;
isNewIdentifierLocation = false;
- if (node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */ || node.kind === 166 /* PropertyAccessExpression */) {
+ if (node.kind === 69 /* Identifier */ || node.kind === 136 /* QualifiedName */ || node.kind === 169 /* PropertyAccessExpression */) {
var symbol = typeChecker.getSymbolAtLocation(node);
// This is an alias, follow what it aliases
if (symbol && symbol.flags & 8388608 /* Alias */) {
@@ -45045,8 +48709,8 @@ var ts;
return tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports);
}
if (jsxContainer = tryGetContainingJsxElement(contextToken)) {
- var attrsType;
- if ((jsxContainer.kind === 234 /* JsxSelfClosingElement */) || (jsxContainer.kind === 235 /* JsxOpeningElement */)) {
+ var attrsType = void 0;
+ if ((jsxContainer.kind === 237 /* JsxSelfClosingElement */) || (jsxContainer.kind === 238 /* JsxOpeningElement */)) {
// Cursor is inside a JSX self-closing element or opening element
attrsType = typeChecker.getJsxElementAttributesType(jsxContainer);
if (attrsType) {
@@ -45118,15 +48782,15 @@ var ts;
return result;
}
function isInJsxText(contextToken) {
- if (contextToken.kind === 236 /* JsxText */) {
+ if (contextToken.kind === 239 /* JsxText */) {
return true;
}
if (contextToken.kind === 27 /* GreaterThanToken */ && contextToken.parent) {
- if (contextToken.parent.kind === 235 /* JsxOpeningElement */) {
+ if (contextToken.parent.kind === 238 /* JsxOpeningElement */) {
return true;
}
- if (contextToken.parent.kind === 237 /* JsxClosingElement */ || contextToken.parent.kind === 234 /* JsxSelfClosingElement */) {
- return contextToken.parent.parent && contextToken.parent.parent.kind === 233 /* JsxElement */;
+ if (contextToken.parent.kind === 240 /* JsxClosingElement */ || contextToken.parent.kind === 237 /* JsxSelfClosingElement */) {
+ return contextToken.parent.parent && contextToken.parent.parent.kind === 236 /* JsxElement */;
}
}
return false;
@@ -45136,40 +48800,40 @@ var ts;
var containingNodeKind = previousToken.parent.kind;
switch (previousToken.kind) {
case 24 /* CommaToken */:
- return containingNodeKind === 168 /* CallExpression */ // func( a, |
- || containingNodeKind === 144 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */
- || containingNodeKind === 169 /* NewExpression */ // new C(a, |
- || containingNodeKind === 164 /* ArrayLiteralExpression */ // [a, |
- || containingNodeKind === 181 /* BinaryExpression */ // let x = (a, |
- || containingNodeKind === 152 /* FunctionType */; // var x: (s: string, list|
+ return containingNodeKind === 171 /* CallExpression */ // func( a, |
+ || containingNodeKind === 145 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */
+ || containingNodeKind === 172 /* NewExpression */ // new C(a, |
+ || containingNodeKind === 167 /* ArrayLiteralExpression */ // [a, |
+ || containingNodeKind === 184 /* BinaryExpression */ // const x = (a, |
+ || containingNodeKind === 153 /* FunctionType */; // var x: (s: string, list|
case 17 /* OpenParenToken */:
- return containingNodeKind === 168 /* CallExpression */ // func( |
- || containingNodeKind === 144 /* Constructor */ // constructor( |
- || containingNodeKind === 169 /* NewExpression */ // new C(a|
- || containingNodeKind === 172 /* ParenthesizedExpression */ // let x = (a|
- || containingNodeKind === 160 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */
+ return containingNodeKind === 171 /* CallExpression */ // func( |
+ || containingNodeKind === 145 /* Constructor */ // constructor( |
+ || containingNodeKind === 172 /* NewExpression */ // new C(a|
+ || containingNodeKind === 175 /* ParenthesizedExpression */ // const x = (a|
+ || containingNodeKind === 161 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */
case 19 /* OpenBracketToken */:
- return containingNodeKind === 164 /* ArrayLiteralExpression */ // [ |
- || containingNodeKind === 149 /* IndexSignature */ // [ | : string ]
- || containingNodeKind === 136 /* ComputedPropertyName */; // [ | /* this can become an index signature */
+ return containingNodeKind === 167 /* ArrayLiteralExpression */ // [ |
+ || containingNodeKind === 150 /* IndexSignature */ // [ | : string ]
+ || containingNodeKind === 137 /* ComputedPropertyName */; // [ | /* this can become an index signature */
case 125 /* ModuleKeyword */: // module |
case 126 /* NamespaceKeyword */:
return true;
case 21 /* DotToken */:
- return containingNodeKind === 218 /* ModuleDeclaration */; // module A.|
+ return containingNodeKind === 221 /* ModuleDeclaration */; // module A.|
case 15 /* OpenBraceToken */:
- return containingNodeKind === 214 /* ClassDeclaration */; // class A{ |
+ return containingNodeKind === 217 /* ClassDeclaration */; // class A{ |
case 56 /* EqualsToken */:
- return containingNodeKind === 211 /* VariableDeclaration */ // let x = a|
- || containingNodeKind === 181 /* BinaryExpression */; // x = a|
+ return containingNodeKind === 214 /* VariableDeclaration */ // const x = a|
+ || containingNodeKind === 184 /* BinaryExpression */; // x = a|
case 12 /* TemplateHead */:
- return containingNodeKind === 183 /* TemplateExpression */; // `aa ${|
+ return containingNodeKind === 186 /* TemplateExpression */; // `aa ${|
case 13 /* TemplateMiddle */:
- return containingNodeKind === 190 /* TemplateSpan */; // `aa ${10} dd ${|
+ return containingNodeKind === 193 /* TemplateSpan */; // `aa ${10} dd ${|
case 112 /* PublicKeyword */:
case 110 /* PrivateKeyword */:
case 111 /* ProtectedKeyword */:
- return containingNodeKind === 141 /* PropertyDeclaration */; // class A{ public |
+ return containingNodeKind === 142 /* PropertyDeclaration */; // class A{ public |
}
// Previous token may have been a keyword that was converted to an identifier.
switch (previousToken.getText()) {
@@ -45183,15 +48847,16 @@ var ts;
}
function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) {
if (contextToken.kind === 9 /* StringLiteral */
+ || contextToken.kind === 163 /* StringLiteralType */
|| contextToken.kind === 10 /* RegularExpressionLiteral */
|| ts.isTemplateLiteralKind(contextToken.kind)) {
- var start_4 = contextToken.getStart();
+ var start_7 = contextToken.getStart();
var end = contextToken.getEnd();
// To be "in" one of these literals, the position has to be:
// 1. entirely within the token text.
// 2. at the end position of an unterminated token.
// 3. at the end of a regular expression (due to trailing flags like '/foo/g').
- if (start_4 < position && position < end) {
+ if (start_7 < position && position < end) {
return true;
}
if (position === end) {
@@ -45212,14 +48877,14 @@ var ts;
isMemberCompletion = true;
var typeForObject;
var existingMembers;
- if (objectLikeContainer.kind === 165 /* ObjectLiteralExpression */) {
+ if (objectLikeContainer.kind === 168 /* ObjectLiteralExpression */) {
// We are completing on contextual types, but may also include properties
// other than those within the declared type.
isNewIdentifierLocation = true;
typeForObject = typeChecker.getContextualType(objectLikeContainer);
existingMembers = objectLikeContainer.properties;
}
- else if (objectLikeContainer.kind === 161 /* ObjectBindingPattern */) {
+ else if (objectLikeContainer.kind === 164 /* ObjectBindingPattern */) {
// We are *only* completing on properties from the type being destructured.
isNewIdentifierLocation = false;
var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent);
@@ -45265,9 +48930,9 @@ var ts;
* @returns true if 'symbols' was successfully populated; false otherwise.
*/
function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) {
- var declarationKind = namedImportsOrExports.kind === 225 /* NamedImports */ ?
- 222 /* ImportDeclaration */ :
- 228 /* ExportDeclaration */;
+ var declarationKind = namedImportsOrExports.kind === 228 /* NamedImports */ ?
+ 225 /* ImportDeclaration */ :
+ 231 /* ExportDeclaration */;
var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind);
var moduleSpecifier = importOrExportDeclaration.moduleSpecifier;
if (!moduleSpecifier) {
@@ -45290,11 +48955,11 @@ var ts;
function tryGetObjectLikeCompletionContainer(contextToken) {
if (contextToken) {
switch (contextToken.kind) {
- case 15 /* OpenBraceToken */: // let x = { |
+ case 15 /* OpenBraceToken */: // const x = { |
case 24 /* CommaToken */:
- var parent_10 = contextToken.parent;
- if (parent_10 && (parent_10.kind === 165 /* ObjectLiteralExpression */ || parent_10.kind === 161 /* ObjectBindingPattern */)) {
- return parent_10;
+ var parent_12 = contextToken.parent;
+ if (parent_12 && (parent_12.kind === 168 /* ObjectLiteralExpression */ || parent_12.kind === 164 /* ObjectBindingPattern */)) {
+ return parent_12;
}
break;
}
@@ -45311,8 +48976,8 @@ var ts;
case 15 /* OpenBraceToken */: // import { |
case 24 /* CommaToken */:
switch (contextToken.parent.kind) {
- case 225 /* NamedImports */:
- case 229 /* NamedExports */:
+ case 228 /* NamedImports */:
+ case 232 /* NamedExports */:
return contextToken.parent;
}
}
@@ -45321,37 +48986,37 @@ var ts;
}
function tryGetContainingJsxElement(contextToken) {
if (contextToken) {
- var parent_11 = contextToken.parent;
+ var parent_13 = contextToken.parent;
switch (contextToken.kind) {
case 26 /* LessThanSlashToken */:
case 39 /* SlashToken */:
case 69 /* Identifier */:
- case 238 /* JsxAttribute */:
- case 239 /* JsxSpreadAttribute */:
- if (parent_11 && (parent_11.kind === 234 /* JsxSelfClosingElement */ || parent_11.kind === 235 /* JsxOpeningElement */)) {
- return parent_11;
+ case 241 /* JsxAttribute */:
+ case 242 /* JsxSpreadAttribute */:
+ if (parent_13 && (parent_13.kind === 237 /* JsxSelfClosingElement */ || parent_13.kind === 238 /* JsxOpeningElement */)) {
+ return parent_13;
}
- else if (parent_11.kind === 238 /* JsxAttribute */) {
- return parent_11.parent;
+ else if (parent_13.kind === 241 /* JsxAttribute */) {
+ return parent_13.parent;
}
break;
// The context token is the closing } or " of an attribute, which means
// its parent is a JsxExpression, whose parent is a JsxAttribute,
// whose parent is a JsxOpeningLikeElement
case 9 /* StringLiteral */:
- if (parent_11 && ((parent_11.kind === 238 /* JsxAttribute */) || (parent_11.kind === 239 /* JsxSpreadAttribute */))) {
- return parent_11.parent;
+ if (parent_13 && ((parent_13.kind === 241 /* JsxAttribute */) || (parent_13.kind === 242 /* JsxSpreadAttribute */))) {
+ return parent_13.parent;
}
break;
case 16 /* CloseBraceToken */:
- if (parent_11 &&
- parent_11.kind === 240 /* JsxExpression */ &&
- parent_11.parent &&
- (parent_11.parent.kind === 238 /* JsxAttribute */)) {
- return parent_11.parent.parent;
+ if (parent_13 &&
+ parent_13.kind === 243 /* JsxExpression */ &&
+ parent_13.parent &&
+ (parent_13.parent.kind === 241 /* JsxAttribute */)) {
+ return parent_13.parent.parent;
}
- if (parent_11 && parent_11.kind === 239 /* JsxSpreadAttribute */) {
- return parent_11.parent;
+ if (parent_13 && parent_13.kind === 242 /* JsxSpreadAttribute */) {
+ return parent_13.parent;
}
break;
}
@@ -45360,16 +49025,16 @@ var ts;
}
function isFunction(kind) {
switch (kind) {
- case 173 /* FunctionExpression */:
- case 174 /* ArrowFunction */:
- case 213 /* FunctionDeclaration */:
- case 143 /* MethodDeclaration */:
- case 142 /* MethodSignature */:
- case 145 /* GetAccessor */:
- case 146 /* SetAccessor */:
- case 147 /* CallSignature */:
- case 148 /* ConstructSignature */:
- case 149 /* IndexSignature */:
+ case 176 /* FunctionExpression */:
+ case 177 /* ArrowFunction */:
+ case 216 /* FunctionDeclaration */:
+ case 144 /* MethodDeclaration */:
+ case 143 /* MethodSignature */:
+ case 146 /* GetAccessor */:
+ case 147 /* SetAccessor */:
+ case 148 /* CallSignature */:
+ case 149 /* ConstructSignature */:
+ case 150 /* IndexSignature */:
return true;
}
return false;
@@ -45381,54 +49046,54 @@ var ts;
var containingNodeKind = contextToken.parent.kind;
switch (contextToken.kind) {
case 24 /* CommaToken */:
- return containingNodeKind === 211 /* VariableDeclaration */ ||
- containingNodeKind === 212 /* VariableDeclarationList */ ||
- containingNodeKind === 193 /* VariableStatement */ ||
- containingNodeKind === 217 /* EnumDeclaration */ ||
+ return containingNodeKind === 214 /* VariableDeclaration */ ||
+ containingNodeKind === 215 /* VariableDeclarationList */ ||
+ containingNodeKind === 196 /* VariableStatement */ ||
+ containingNodeKind === 220 /* EnumDeclaration */ ||
isFunction(containingNodeKind) ||
- containingNodeKind === 214 /* ClassDeclaration */ ||
- containingNodeKind === 186 /* ClassExpression */ ||
- containingNodeKind === 215 /* InterfaceDeclaration */ ||
- containingNodeKind === 162 /* ArrayBindingPattern */ ||
- containingNodeKind === 216 /* TypeAliasDeclaration */; // type Map, K, |
+ containingNodeKind === 217 /* ClassDeclaration */ ||
+ containingNodeKind === 189 /* ClassExpression */ ||
+ containingNodeKind === 218 /* InterfaceDeclaration */ ||
+ containingNodeKind === 165 /* ArrayBindingPattern */ ||
+ containingNodeKind === 219 /* TypeAliasDeclaration */; // type Map, K, |
case 21 /* DotToken */:
- return containingNodeKind === 162 /* ArrayBindingPattern */; // var [.|
+ return containingNodeKind === 165 /* ArrayBindingPattern */; // var [.|
case 54 /* ColonToken */:
- return containingNodeKind === 163 /* BindingElement */; // var {x :html|
+ return containingNodeKind === 166 /* BindingElement */; // var {x :html|
case 19 /* OpenBracketToken */:
- return containingNodeKind === 162 /* ArrayBindingPattern */; // var [x|
+ return containingNodeKind === 165 /* ArrayBindingPattern */; // var [x|
case 17 /* OpenParenToken */:
- return containingNodeKind === 244 /* CatchClause */ ||
+ return containingNodeKind === 247 /* CatchClause */ ||
isFunction(containingNodeKind);
case 15 /* OpenBraceToken */:
- return containingNodeKind === 217 /* EnumDeclaration */ ||
- containingNodeKind === 215 /* InterfaceDeclaration */ ||
- containingNodeKind === 155 /* TypeLiteral */; // let x : { |
+ return containingNodeKind === 220 /* EnumDeclaration */ ||
+ containingNodeKind === 218 /* InterfaceDeclaration */ ||
+ containingNodeKind === 156 /* TypeLiteral */; // const x : { |
case 23 /* SemicolonToken */:
- return containingNodeKind === 140 /* PropertySignature */ &&
+ return containingNodeKind === 141 /* PropertySignature */ &&
contextToken.parent && contextToken.parent.parent &&
- (contextToken.parent.parent.kind === 215 /* InterfaceDeclaration */ ||
- contextToken.parent.parent.kind === 155 /* TypeLiteral */); // let x : { a; |
+ (contextToken.parent.parent.kind === 218 /* InterfaceDeclaration */ ||
+ contextToken.parent.parent.kind === 156 /* TypeLiteral */); // const x : { a; |
case 25 /* LessThanToken */:
- return containingNodeKind === 214 /* ClassDeclaration */ ||
- containingNodeKind === 186 /* ClassExpression */ ||
- containingNodeKind === 215 /* InterfaceDeclaration */ ||
- containingNodeKind === 216 /* TypeAliasDeclaration */ ||
+ return containingNodeKind === 217 /* ClassDeclaration */ ||
+ containingNodeKind === 189 /* ClassExpression */ ||
+ containingNodeKind === 218 /* InterfaceDeclaration */ ||
+ containingNodeKind === 219 /* TypeAliasDeclaration */ ||
isFunction(containingNodeKind);
case 113 /* StaticKeyword */:
- return containingNodeKind === 141 /* PropertyDeclaration */;
+ return containingNodeKind === 142 /* PropertyDeclaration */;
case 22 /* DotDotDotToken */:
- return containingNodeKind === 138 /* Parameter */ ||
+ return containingNodeKind === 139 /* Parameter */ ||
(contextToken.parent && contextToken.parent.parent &&
- contextToken.parent.parent.kind === 162 /* ArrayBindingPattern */); // var [...z|
+ contextToken.parent.parent.kind === 165 /* ArrayBindingPattern */); // var [...z|
case 112 /* PublicKeyword */:
case 110 /* PrivateKeyword */:
case 111 /* ProtectedKeyword */:
- return containingNodeKind === 138 /* Parameter */;
+ return containingNodeKind === 139 /* Parameter */;
case 116 /* AsKeyword */:
- return containingNodeKind === 226 /* ImportSpecifier */ ||
- containingNodeKind === 230 /* ExportSpecifier */ ||
- containingNodeKind === 224 /* NamespaceImport */;
+ return containingNodeKind === 229 /* ImportSpecifier */ ||
+ containingNodeKind === 233 /* ExportSpecifier */ ||
+ containingNodeKind === 227 /* NamespaceImport */;
case 73 /* ClassKeyword */:
case 81 /* EnumKeyword */:
case 107 /* InterfaceKeyword */:
@@ -45482,14 +49147,14 @@ var ts;
*/
function filterNamedImportOrExportCompletionItems(exportsOfModule, namedImportsOrExports) {
var exisingImportsOrExports = {};
- for (var _i = 0; _i < namedImportsOrExports.length; _i++) {
- var element = namedImportsOrExports[_i];
+ for (var _i = 0, namedImportsOrExports_1 = namedImportsOrExports; _i < namedImportsOrExports_1.length; _i++) {
+ var element = namedImportsOrExports_1[_i];
// If this is the current item we are editing right now, do not filter it out
if (element.getStart() <= position && position <= element.getEnd()) {
continue;
}
- var name_32 = element.propertyName || element.name;
- exisingImportsOrExports[name_32.text] = true;
+ var name_35 = element.propertyName || element.name;
+ exisingImportsOrExports[name_35.text] = true;
}
if (ts.isEmpty(exisingImportsOrExports)) {
return exportsOfModule;
@@ -45507,12 +49172,13 @@ var ts;
return contextualMemberSymbols;
}
var existingMemberNames = {};
- for (var _i = 0; _i < existingMembers.length; _i++) {
- var m = existingMembers[_i];
+ for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) {
+ var m = existingMembers_1[_i];
// Ignore omitted expressions for missing members
- if (m.kind !== 245 /* PropertyAssignment */ &&
- m.kind !== 246 /* ShorthandPropertyAssignment */ &&
- m.kind !== 163 /* BindingElement */) {
+ if (m.kind !== 248 /* PropertyAssignment */ &&
+ m.kind !== 249 /* ShorthandPropertyAssignment */ &&
+ m.kind !== 166 /* BindingElement */ &&
+ m.kind !== 144 /* MethodDeclaration */) {
continue;
}
// If this is the current item we are editing right now, do not filter it out
@@ -45520,8 +49186,11 @@ var ts;
continue;
}
var existingName = void 0;
- if (m.kind === 163 /* BindingElement */ && m.propertyName) {
- existingName = m.propertyName.text;
+ if (m.kind === 166 /* BindingElement */ && m.propertyName) {
+ // include only identifiers in completion list
+ if (m.propertyName.kind === 69 /* Identifier */) {
+ existingName = m.propertyName.text;
+ }
}
else {
// TODO(jfreeman): Account for computed property name
@@ -45541,13 +49210,13 @@ var ts;
*/
function filterJsxAttributes(symbols, attributes) {
var seenNames = {};
- for (var _i = 0; _i < attributes.length; _i++) {
- var attr = attributes[_i];
+ for (var _i = 0, attributes_1 = attributes; _i < attributes_1.length; _i++) {
+ var attr = attributes_1[_i];
// If this is the current item we are editing right now, do not filter it out
if (attr.getStart() <= position && position <= attr.getEnd()) {
continue;
}
- if (attr.kind === 238 /* JsxAttribute */) {
+ if (attr.kind === 241 /* JsxAttribute */) {
seenNames[attr.name.text] = true;
}
}
@@ -45560,47 +49229,64 @@ var ts;
if (!completionData) {
return undefined;
}
- var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName;
- var entries;
+ var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isJsDocTagName = completionData.isJsDocTagName;
if (isJsDocTagName) {
// If the current position is a jsDoc tag name, only tag names should be provided for completion
return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() };
}
- if (isRightOfDot && ts.isJavaScript(fileName)) {
- entries = getCompletionEntriesFromSymbols(symbols);
- ts.addRange(entries, getJavaScriptCompletionEntries());
+ var sourceFile = getValidSourceFile(fileName);
+ var entries = [];
+ if (ts.isSourceFileJavaScript(sourceFile)) {
+ var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries);
+ ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames));
}
else {
if (!symbols || symbols.length === 0) {
- return undefined;
+ if (sourceFile.languageVariant === 1 /* JSX */ &&
+ location.parent && location.parent.kind === 240 /* JsxClosingElement */) {
+ // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag,
+ // instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element.
+ // For example:
+ // var x = /*1*/> completion list at "1" will contain "div" with type any
+ var tagName = location.parent.parent.openingElement.tagName;
+ entries.push({
+ name: tagName.text,
+ kind: undefined,
+ kindModifiers: undefined,
+ sortText: "0"
+ });
+ }
+ else {
+ return undefined;
+ }
}
- entries = getCompletionEntriesFromSymbols(symbols);
+ getCompletionEntriesFromSymbols(symbols, entries);
}
// Add keywords if this is not a member completion list
if (!isMemberCompletion && !isJsDocTagName) {
ts.addRange(entries, keywordCompletions);
}
return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries };
- function getJavaScriptCompletionEntries() {
+ function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) {
var entries = [];
- var allNames = {};
var target = program.getCompilerOptions().target;
- for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
- var sourceFile = _a[_i];
- var nameTable = getNameTable(sourceFile);
- for (var name_33 in nameTable) {
- if (!allNames[name_33]) {
- allNames[name_33] = name_33;
- var displayName = getCompletionEntryDisplayName(name_33, target, /*performCharacterChecks:*/ true);
- if (displayName) {
- var entry = {
- name: displayName,
- kind: ScriptElementKind.warning,
- kindModifiers: "",
- sortText: "1"
- };
- entries.push(entry);
- }
+ var nameTable = getNameTable(sourceFile);
+ for (var name_36 in nameTable) {
+ // Skip identifiers produced only from the current location
+ if (nameTable[name_36] === position) {
+ continue;
+ }
+ if (!uniqueNames[name_36]) {
+ uniqueNames[name_36] = name_36;
+ var displayName = getCompletionEntryDisplayName(name_36, target, /*performCharacterChecks*/ true);
+ if (displayName) {
+ var entry = {
+ name: displayName,
+ kind: ScriptElementKind.warning,
+ kindModifiers: "",
+ sortText: "1"
+ };
+ entries.push(entry);
}
}
}
@@ -45620,7 +49306,7 @@ var ts;
// Try to get a valid display name for this symbol, if we could not find one, then ignore it.
// We would like to only show things that can be added after a dot, so for instance numeric properties can
// not be accessed with a dot (a.1 <- invalid)
- var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, /*performCharacterChecks:*/ true, location);
+ var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, /*performCharacterChecks*/ true, location);
if (!displayName) {
return undefined;
}
@@ -45638,25 +49324,24 @@ var ts;
sortText: "0"
};
}
- function getCompletionEntriesFromSymbols(symbols) {
+ function getCompletionEntriesFromSymbols(symbols, entries) {
var start = new Date().getTime();
- var entries = [];
+ var uniqueNames = {};
if (symbols) {
- var nameToSymbol = {};
- for (var _i = 0; _i < symbols.length; _i++) {
- var symbol = symbols[_i];
+ for (var _i = 0, symbols_4 = symbols; _i < symbols_4.length; _i++) {
+ var symbol = symbols_4[_i];
var entry = createCompletionEntry(symbol, location);
if (entry) {
var id = ts.escapeIdentifier(entry.name);
- if (!ts.lookUp(nameToSymbol, id)) {
+ if (!ts.lookUp(uniqueNames, id)) {
entries.push(entry);
- nameToSymbol[id] = symbol;
+ uniqueNames[id] = id;
}
}
}
}
log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - start));
- return entries;
+ return uniqueNames;
}
}
function getCompletionEntryDetails(fileName, position, entryName) {
@@ -45666,11 +49351,11 @@ var ts;
if (completionData) {
var symbols = completionData.symbols, location_2 = completionData.location;
// Find the symbol with the matching entry name.
- var target = program.getCompilerOptions().target;
+ var target_2 = program.getCompilerOptions().target;
// We don't need to perform character checks here because we're only comparing the
// name against 'entryName' (which is known to be good), not building a new
// completion entry.
- var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, /*performCharacterChecks:*/ false, location_2) === entryName ? s : undefined; });
+ var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target_2, /*performCharacterChecks*/ false, location_2) === entryName ? s : undefined; });
if (symbol) {
var _a = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, location_2, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind;
return {
@@ -45699,7 +49384,7 @@ var ts;
function getSymbolKind(symbol, location) {
var flags = symbol.getFlags();
if (flags & 32 /* Class */)
- return ts.getDeclarationOfKind(symbol, 186 /* ClassExpression */) ?
+ return ts.getDeclarationOfKind(symbol, 189 /* ClassExpression */) ?
ScriptElementKind.localClassElement : ScriptElementKind.classElement;
if (flags & 384 /* Enum */)
return ScriptElementKind.enumElement;
@@ -45764,7 +49449,7 @@ var ts;
});
if (!unionPropertyKind) {
// If this was union of all methods,
- //make sure it has call signatures before we can label it as method
+ // make sure it has call signatures before we can label it as method
var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
if (typeOfUnionProperty.getCallSignatures().length) {
return ScriptElementKind.memberFunctionElement;
@@ -45798,10 +49483,10 @@ var ts;
if (symbolKind === ScriptElementKind.memberGetAccessorElement || symbolKind === ScriptElementKind.memberSetAccessorElement) {
symbolKind = ScriptElementKind.memberVariableElement;
}
- var signature;
+ var signature = void 0;
type = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
if (type) {
- if (location.parent && location.parent.kind === 166 /* PropertyAccessExpression */) {
+ if (location.parent && location.parent.kind === 169 /* PropertyAccessExpression */) {
var right = location.parent.name;
// Either the location is on the right of a property access, or on the left and the right is missing
if (right === location || (right && right.getFullWidth() === 0)) {
@@ -45809,8 +49494,8 @@ var ts;
}
}
// try get the call/construct signature from the type if it matches
- var callExpression;
- if (location.kind === 168 /* CallExpression */ || location.kind === 169 /* NewExpression */) {
+ var callExpression = void 0;
+ if (location.kind === 171 /* CallExpression */ || location.kind === 172 /* NewExpression */) {
callExpression = location;
}
else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) {
@@ -45823,7 +49508,7 @@ var ts;
// Use the first candidate:
signature = candidateSignatures[0];
}
- var useConstructSignatures = callExpression.kind === 169 /* NewExpression */ || callExpression.expression.kind === 95 /* SuperKeyword */;
+ var useConstructSignatures = callExpression.kind === 172 /* NewExpression */ || callExpression.expression.kind === 95 /* SuperKeyword */;
var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures();
if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) {
// Get the first signature if there is one -- allSignatures may contain
@@ -45876,24 +49561,24 @@ var ts;
}
}
else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) ||
- (location.kind === 121 /* ConstructorKeyword */ && location.parent.kind === 144 /* Constructor */)) {
+ (location.kind === 121 /* ConstructorKeyword */ && location.parent.kind === 145 /* Constructor */)) {
// get the signature from the declaration and write it
var functionDeclaration = location.parent;
- var allSignatures = functionDeclaration.kind === 144 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures();
+ var allSignatures = functionDeclaration.kind === 145 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures();
if (!typeChecker.isImplementationOfOverload(functionDeclaration)) {
signature = typeChecker.getSignatureFromDeclaration(functionDeclaration);
}
else {
signature = allSignatures[0];
}
- if (functionDeclaration.kind === 144 /* Constructor */) {
+ if (functionDeclaration.kind === 145 /* Constructor */) {
// show (constructor) Type(...) signature
symbolKind = ScriptElementKind.constructorImplementationElement;
addPrefixForAnyFunctionOrVar(type.symbol, symbolKind);
}
else {
// (function/method) symbol(..signature)
- addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 147 /* CallSignature */ &&
+ addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 148 /* CallSignature */ &&
!(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind);
}
addSignatureDisplayParts(signature, allSignatures);
@@ -45902,7 +49587,7 @@ var ts;
}
}
if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo) {
- if (ts.getDeclarationOfKind(symbol, 186 /* ClassExpression */)) {
+ if (ts.getDeclarationOfKind(symbol, 189 /* ClassExpression */)) {
// Special case for class expressions because we would like to indicate that
// the class name is local to the class body (similar to function expression)
// (local class) class
@@ -45946,7 +49631,7 @@ var ts;
}
if (symbolFlags & 1536 /* Module */) {
addNewLineIfDisplayPartsExist();
- var declaration = ts.getDeclarationOfKind(symbol, 218 /* ModuleDeclaration */);
+ var declaration = ts.getDeclarationOfKind(symbol, 221 /* ModuleDeclaration */);
var isNamespace = declaration && declaration.name && declaration.name.kind === 69 /* Identifier */;
displayParts.push(ts.keywordPart(isNamespace ? 126 /* NamespaceKeyword */ : 125 /* ModuleKeyword */));
displayParts.push(ts.spacePart());
@@ -45969,35 +49654,37 @@ var ts;
}
else {
// Method/function type parameter
- var container = ts.getContainingFunction(location);
- if (container) {
- var signatureDeclaration = ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).parent;
- var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration);
- if (signatureDeclaration.kind === 148 /* ConstructSignature */) {
- displayParts.push(ts.keywordPart(92 /* NewKeyword */));
- displayParts.push(ts.spacePart());
+ var declaration = ts.getDeclarationOfKind(symbol, 138 /* TypeParameter */);
+ ts.Debug.assert(declaration !== undefined);
+ declaration = declaration.parent;
+ if (declaration) {
+ if (ts.isFunctionLikeKind(declaration.kind)) {
+ var signature = typeChecker.getSignatureFromDeclaration(declaration);
+ if (declaration.kind === 149 /* ConstructSignature */) {
+ displayParts.push(ts.keywordPart(92 /* NewKeyword */));
+ displayParts.push(ts.spacePart());
+ }
+ else if (declaration.kind !== 148 /* CallSignature */ && declaration.name) {
+ addFullSymbolName(declaration.symbol);
+ }
+ ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */));
}
- else if (signatureDeclaration.kind !== 147 /* CallSignature */ && signatureDeclaration.name) {
- addFullSymbolName(signatureDeclaration.symbol);
+ else {
+ // Type alias type parameter
+ // For example
+ // type list = T[]; // Both T will go through same code path
+ displayParts.push(ts.keywordPart(132 /* TypeKeyword */));
+ displayParts.push(ts.spacePart());
+ addFullSymbolName(declaration.symbol);
+ writeTypeParametersOfSymbol(declaration.symbol, sourceFile);
}
- ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */));
- }
- else {
- // Type aliash type parameter
- // For example
- // type list = T[]; // Both T will go through same code path
- var declaration = ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).parent;
- displayParts.push(ts.keywordPart(132 /* TypeKeyword */));
- displayParts.push(ts.spacePart());
- addFullSymbolName(declaration.symbol);
- writeTypeParametersOfSymbol(declaration.symbol, sourceFile);
}
}
}
if (symbolFlags & 8 /* EnumMember */) {
addPrefixForAnyFunctionOrVar(symbol, "enum member");
var declaration = symbol.declarations[0];
- if (declaration.kind === 247 /* EnumMember */) {
+ if (declaration.kind === 250 /* EnumMember */) {
var constantValue = typeChecker.getConstantValue(declaration);
if (constantValue !== undefined) {
displayParts.push(ts.spacePart());
@@ -46013,7 +49700,7 @@ var ts;
displayParts.push(ts.spacePart());
addFullSymbolName(symbol);
ts.forEach(symbol.declarations, function (declaration) {
- if (declaration.kind === 221 /* ImportEqualsDeclaration */) {
+ if (declaration.kind === 224 /* ImportEqualsDeclaration */) {
var importEqualsDeclaration = declaration;
if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) {
displayParts.push(ts.spacePart());
@@ -46142,13 +49829,14 @@ var ts;
}
var typeChecker = program.getTypeChecker();
var symbol = typeChecker.getSymbolAtLocation(node);
- if (!symbol) {
+ if (!symbol || typeChecker.isUnknownSymbol(symbol)) {
// Try getting just type at this position and show
switch (node.kind) {
case 69 /* Identifier */:
- case 166 /* PropertyAccessExpression */:
- case 135 /* QualifiedName */:
+ case 169 /* PropertyAccessExpression */:
+ case 136 /* QualifiedName */:
case 97 /* ThisKeyword */:
+ case 162 /* ThisType */:
case 95 /* SuperKeyword */:
// For the identifiers/this/super etc get the type at position
var type = typeChecker.getTypeAtLocation(node);
@@ -46227,8 +49915,8 @@ var ts;
var declarations = [];
var definition;
ts.forEach(signatureDeclarations, function (d) {
- if ((selectConstructors && d.kind === 144 /* Constructor */) ||
- (!selectConstructors && (d.kind === 213 /* FunctionDeclaration */ || d.kind === 143 /* MethodDeclaration */ || d.kind === 142 /* MethodSignature */))) {
+ if ((selectConstructors && d.kind === 145 /* Constructor */) ||
+ (!selectConstructors && (d.kind === 216 /* FunctionDeclaration */ || d.kind === 144 /* MethodDeclaration */ || d.kind === 143 /* MethodSignature */))) {
declarations.push(d);
if (d.body)
definition = d;
@@ -46297,16 +49985,16 @@ var ts;
// go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition
// is performed at the location of property access, we would like to go to definition of the property in the short-hand
// assignment. This case and others are handled by the following code.
- if (node.parent.kind === 246 /* ShorthandPropertyAssignment */) {
+ if (node.parent.kind === 249 /* ShorthandPropertyAssignment */) {
var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
if (!shorthandSymbol) {
return [];
}
var shorthandDeclarations = shorthandSymbol.getDeclarations();
- var shorthandSymbolKind = getSymbolKind(shorthandSymbol, node);
- var shorthandSymbolName = typeChecker.symbolToString(shorthandSymbol);
- var shorthandContainerName = typeChecker.symbolToString(symbol.parent, node);
- return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName); });
+ var shorthandSymbolKind_1 = getSymbolKind(shorthandSymbol, node);
+ var shorthandSymbolName_1 = typeChecker.symbolToString(shorthandSymbol);
+ var shorthandContainerName_1 = typeChecker.symbolToString(symbol.parent, node);
+ return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind_1, shorthandSymbolName_1, shorthandContainerName_1); });
}
return getDefinitionFromSymbol(symbol, node);
}
@@ -46328,13 +50016,13 @@ var ts;
return undefined;
}
if (type.flags & 16384 /* Union */) {
- var result = [];
+ var result_4 = [];
ts.forEach(type.types, function (t) {
if (t.symbol) {
- ts.addRange(/*to*/ result, /*from*/ getDefinitionFromSymbol(t.symbol, node));
+ ts.addRange(/*to*/ result_4, /*from*/ getDefinitionFromSymbol(t.symbol, node));
}
});
- return result;
+ return result_4;
}
if (!type.symbol) {
return undefined;
@@ -46344,10 +50032,10 @@ var ts;
function getOccurrencesAtPosition(fileName, position) {
var results = getOccurrencesAtPositionCore(fileName, position);
if (results) {
- var sourceFile = getCanonicalFileName(ts.normalizeSlashes(fileName));
+ var sourceFile_2 = getCanonicalFileName(ts.normalizeSlashes(fileName));
// Get occurrences only supports reporting occurrences for the file queried. So
// filter down to that list.
- results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile; });
+ results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile_2; });
}
return results;
}
@@ -46373,10 +50061,11 @@ var ts;
function getSemanticDocumentHighlights(node) {
if (node.kind === 69 /* Identifier */ ||
node.kind === 97 /* ThisKeyword */ ||
+ node.kind === 162 /* ThisType */ ||
node.kind === 95 /* SuperKeyword */ ||
isLiteralNameOfPropertyDeclarationOrIndexAccess(node) ||
isNameOfExternalModuleImportOrDeclaration(node)) {
- var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, /*findInStrings:*/ false, /*findInComments:*/ false);
+ var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, /*findInStrings*/ false, /*findInComments*/ false);
return convertReferencedSymbols(referencedSymbols);
}
return undefined;
@@ -46386,8 +50075,8 @@ var ts;
}
var fileNameToDocumentHighlights = {};
var result = [];
- for (var _i = 0; _i < referencedSymbols.length; _i++) {
- var referencedSymbol = referencedSymbols[_i];
+ for (var _i = 0, referencedSymbols_1 = referencedSymbols; _i < referencedSymbols_1.length; _i++) {
+ var referencedSymbol = referencedSymbols_1[_i];
for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) {
var referenceEntry = _b[_a];
var fileName_1 = referenceEntry.fileName;
@@ -46426,75 +50115,75 @@ var ts;
switch (node.kind) {
case 88 /* IfKeyword */:
case 80 /* ElseKeyword */:
- if (hasKind(node.parent, 196 /* IfStatement */)) {
+ if (hasKind(node.parent, 199 /* IfStatement */)) {
return getIfElseOccurrences(node.parent);
}
break;
case 94 /* ReturnKeyword */:
- if (hasKind(node.parent, 204 /* ReturnStatement */)) {
+ if (hasKind(node.parent, 207 /* ReturnStatement */)) {
return getReturnOccurrences(node.parent);
}
break;
case 98 /* ThrowKeyword */:
- if (hasKind(node.parent, 208 /* ThrowStatement */)) {
+ if (hasKind(node.parent, 211 /* ThrowStatement */)) {
return getThrowOccurrences(node.parent);
}
break;
case 72 /* CatchKeyword */:
- if (hasKind(parent(parent(node)), 209 /* TryStatement */)) {
+ if (hasKind(parent(parent(node)), 212 /* TryStatement */)) {
return getTryCatchFinallyOccurrences(node.parent.parent);
}
break;
case 100 /* TryKeyword */:
case 85 /* FinallyKeyword */:
- if (hasKind(parent(node), 209 /* TryStatement */)) {
+ if (hasKind(parent(node), 212 /* TryStatement */)) {
return getTryCatchFinallyOccurrences(node.parent);
}
break;
case 96 /* SwitchKeyword */:
- if (hasKind(node.parent, 206 /* SwitchStatement */)) {
+ if (hasKind(node.parent, 209 /* SwitchStatement */)) {
return getSwitchCaseDefaultOccurrences(node.parent);
}
break;
case 71 /* CaseKeyword */:
case 77 /* DefaultKeyword */:
- if (hasKind(parent(parent(parent(node))), 206 /* SwitchStatement */)) {
+ if (hasKind(parent(parent(parent(node))), 209 /* SwitchStatement */)) {
return getSwitchCaseDefaultOccurrences(node.parent.parent.parent);
}
break;
case 70 /* BreakKeyword */:
case 75 /* ContinueKeyword */:
- if (hasKind(node.parent, 203 /* BreakStatement */) || hasKind(node.parent, 202 /* ContinueStatement */)) {
+ if (hasKind(node.parent, 206 /* BreakStatement */) || hasKind(node.parent, 205 /* ContinueStatement */)) {
return getBreakOrContinueStatementOccurrences(node.parent);
}
break;
case 86 /* ForKeyword */:
- if (hasKind(node.parent, 199 /* ForStatement */) ||
- hasKind(node.parent, 200 /* ForInStatement */) ||
- hasKind(node.parent, 201 /* ForOfStatement */)) {
+ if (hasKind(node.parent, 202 /* ForStatement */) ||
+ hasKind(node.parent, 203 /* ForInStatement */) ||
+ hasKind(node.parent, 204 /* ForOfStatement */)) {
return getLoopBreakContinueOccurrences(node.parent);
}
break;
case 104 /* WhileKeyword */:
case 79 /* DoKeyword */:
- if (hasKind(node.parent, 198 /* WhileStatement */) || hasKind(node.parent, 197 /* DoStatement */)) {
+ if (hasKind(node.parent, 201 /* WhileStatement */) || hasKind(node.parent, 200 /* DoStatement */)) {
return getLoopBreakContinueOccurrences(node.parent);
}
break;
case 121 /* ConstructorKeyword */:
- if (hasKind(node.parent, 144 /* Constructor */)) {
+ if (hasKind(node.parent, 145 /* Constructor */)) {
return getConstructorOccurrences(node.parent);
}
break;
case 123 /* GetKeyword */:
case 129 /* SetKeyword */:
- if (hasKind(node.parent, 145 /* GetAccessor */) || hasKind(node.parent, 146 /* SetAccessor */)) {
+ if (hasKind(node.parent, 146 /* GetAccessor */) || hasKind(node.parent, 147 /* SetAccessor */)) {
return getGetAndSetOccurrences(node.parent);
}
break;
default:
- if (ts.isModifier(node.kind) && node.parent &&
- (ts.isDeclaration(node.parent) || node.parent.kind === 193 /* VariableStatement */)) {
+ if (ts.isModifierKind(node.kind) && node.parent &&
+ (ts.isDeclaration(node.parent) || node.parent.kind === 196 /* VariableStatement */)) {
return getModifierOccurrences(node.kind, node.parent);
}
}
@@ -46510,10 +50199,10 @@ var ts;
aggregate(node);
return statementAccumulator;
function aggregate(node) {
- if (node.kind === 208 /* ThrowStatement */) {
+ if (node.kind === 211 /* ThrowStatement */) {
statementAccumulator.push(node);
}
- else if (node.kind === 209 /* TryStatement */) {
+ else if (node.kind === 212 /* TryStatement */) {
var tryStatement = node;
if (tryStatement.catchClause) {
aggregate(tryStatement.catchClause);
@@ -46531,7 +50220,6 @@ var ts;
ts.forEachChild(node, aggregate);
}
}
- ;
}
/**
* For lack of a better name, this function takes a throw statement and returns the
@@ -46541,19 +50229,19 @@ var ts;
function getThrowStatementOwner(throwStatement) {
var child = throwStatement;
while (child.parent) {
- var parent_12 = child.parent;
- if (ts.isFunctionBlock(parent_12) || parent_12.kind === 248 /* SourceFile */) {
- return parent_12;
+ var parent_14 = child.parent;
+ if (ts.isFunctionBlock(parent_14) || parent_14.kind === 251 /* SourceFile */) {
+ return parent_14;
}
// A throw-statement is only owned by a try-statement if the try-statement has
// a catch clause, and if the throw-statement occurs within the try block.
- if (parent_12.kind === 209 /* TryStatement */) {
- var tryStatement = parent_12;
+ if (parent_14.kind === 212 /* TryStatement */) {
+ var tryStatement = parent_14;
if (tryStatement.tryBlock === child && tryStatement.catchClause) {
return child;
}
}
- child = parent_12;
+ child = parent_14;
}
return undefined;
}
@@ -46562,14 +50250,13 @@ var ts;
aggregate(node);
return statementAccumulator;
function aggregate(node) {
- if (node.kind === 203 /* BreakStatement */ || node.kind === 202 /* ContinueStatement */) {
+ if (node.kind === 206 /* BreakStatement */ || node.kind === 205 /* ContinueStatement */) {
statementAccumulator.push(node);
}
else if (!ts.isFunctionLike(node)) {
ts.forEachChild(node, aggregate);
}
}
- ;
}
function ownsBreakOrContinueStatement(owner, statement) {
var actualOwner = getBreakOrContinueOwner(statement);
@@ -46578,16 +50265,16 @@ var ts;
function getBreakOrContinueOwner(statement) {
for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) {
switch (node_2.kind) {
- case 206 /* SwitchStatement */:
- if (statement.kind === 202 /* ContinueStatement */) {
+ case 209 /* SwitchStatement */:
+ if (statement.kind === 205 /* ContinueStatement */) {
continue;
}
// Fall through.
- case 199 /* ForStatement */:
- case 200 /* ForInStatement */:
- case 201 /* ForOfStatement */:
- case 198 /* WhileStatement */:
- case 197 /* DoStatement */:
+ case 202 /* ForStatement */:
+ case 203 /* ForInStatement */:
+ case 204 /* ForOfStatement */:
+ case 201 /* WhileStatement */:
+ case 200 /* DoStatement */:
if (!statement.label || isLabeledBy(node_2, statement.label.text)) {
return node_2;
}
@@ -46606,24 +50293,24 @@ var ts;
var container = declaration.parent;
// Make sure we only highlight the keyword when it makes sense to do so.
if (ts.isAccessibilityModifier(modifier)) {
- if (!(container.kind === 214 /* ClassDeclaration */ ||
- container.kind === 186 /* ClassExpression */ ||
- (declaration.kind === 138 /* Parameter */ && hasKind(container, 144 /* Constructor */)))) {
+ if (!(container.kind === 217 /* ClassDeclaration */ ||
+ container.kind === 189 /* ClassExpression */ ||
+ (declaration.kind === 139 /* Parameter */ && hasKind(container, 145 /* Constructor */)))) {
return undefined;
}
}
else if (modifier === 113 /* StaticKeyword */) {
- if (!(container.kind === 214 /* ClassDeclaration */ || container.kind === 186 /* ClassExpression */)) {
+ if (!(container.kind === 217 /* ClassDeclaration */ || container.kind === 189 /* ClassExpression */)) {
return undefined;
}
}
else if (modifier === 82 /* ExportKeyword */ || modifier === 122 /* DeclareKeyword */) {
- if (!(container.kind === 219 /* ModuleBlock */ || container.kind === 248 /* SourceFile */)) {
+ if (!(container.kind === 222 /* ModuleBlock */ || container.kind === 251 /* SourceFile */)) {
return undefined;
}
}
else if (modifier === 115 /* AbstractKeyword */) {
- if (!(container.kind === 214 /* ClassDeclaration */ || declaration.kind === 214 /* ClassDeclaration */)) {
+ if (!(container.kind === 217 /* ClassDeclaration */ || declaration.kind === 217 /* ClassDeclaration */)) {
return undefined;
}
}
@@ -46635,33 +50322,33 @@ var ts;
var modifierFlag = getFlagFromModifier(modifier);
var nodes;
switch (container.kind) {
- case 219 /* ModuleBlock */:
- case 248 /* SourceFile */:
+ case 222 /* ModuleBlock */:
+ case 251 /* SourceFile */:
// Container is either a class declaration or the declaration is a classDeclaration
- if (modifierFlag & 256 /* Abstract */) {
+ if (modifierFlag & 128 /* Abstract */) {
nodes = declaration.members.concat(declaration);
}
else {
nodes = container.statements;
}
break;
- case 144 /* Constructor */:
+ case 145 /* Constructor */:
nodes = container.parameters.concat(container.parent.members);
break;
- case 214 /* ClassDeclaration */:
- case 186 /* ClassExpression */:
+ case 217 /* ClassDeclaration */:
+ case 189 /* ClassExpression */:
nodes = container.members;
// If we're an accessibility modifier, we're in an instance member and should search
// the constructor's parameter list for instance members as well.
- if (modifierFlag & 112 /* AccessibilityModifier */) {
+ if (modifierFlag & 56 /* AccessibilityModifier */) {
var constructor = ts.forEach(container.members, function (member) {
- return member.kind === 144 /* Constructor */ && member;
+ return member.kind === 145 /* Constructor */ && member;
});
if (constructor) {
nodes = nodes.concat(constructor.parameters);
}
}
- else if (modifierFlag & 256 /* Abstract */) {
+ else if (modifierFlag & 128 /* Abstract */) {
nodes = nodes.concat(container);
}
break;
@@ -46677,19 +50364,19 @@ var ts;
function getFlagFromModifier(modifier) {
switch (modifier) {
case 112 /* PublicKeyword */:
- return 16 /* Public */;
+ return 8 /* Public */;
case 110 /* PrivateKeyword */:
- return 32 /* Private */;
+ return 16 /* Private */;
case 111 /* ProtectedKeyword */:
- return 64 /* Protected */;
+ return 32 /* Protected */;
case 113 /* StaticKeyword */:
- return 128 /* Static */;
+ return 64 /* Static */;
case 82 /* ExportKeyword */:
- return 1 /* Export */;
+ return 2 /* Export */;
case 122 /* DeclareKeyword */:
- return 2 /* Ambient */;
+ return 4 /* Ambient */;
case 115 /* AbstractKeyword */:
- return 256 /* Abstract */;
+ return 128 /* Abstract */;
default:
ts.Debug.fail();
}
@@ -46708,8 +50395,8 @@ var ts;
}
function getGetAndSetOccurrences(accessorDeclaration) {
var keywords = [];
- tryPushAccessorKeyword(accessorDeclaration.symbol, 145 /* GetAccessor */);
- tryPushAccessorKeyword(accessorDeclaration.symbol, 146 /* SetAccessor */);
+ tryPushAccessorKeyword(accessorDeclaration.symbol, 146 /* GetAccessor */);
+ tryPushAccessorKeyword(accessorDeclaration.symbol, 147 /* SetAccessor */);
return ts.map(keywords, getHighlightSpanForNode);
function tryPushAccessorKeyword(accessorSymbol, accessorKind) {
var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind);
@@ -46732,7 +50419,7 @@ var ts;
var keywords = [];
if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86 /* ForKeyword */, 104 /* WhileKeyword */, 79 /* DoKeyword */)) {
// If we succeeded and got a do-while loop, then start looking for a 'while' keyword.
- if (loopNode.kind === 197 /* DoStatement */) {
+ if (loopNode.kind === 200 /* DoStatement */) {
var loopTokens = loopNode.getChildren();
for (var i = loopTokens.length - 1; i >= 0; i--) {
if (pushKeywordIf(keywords, loopTokens[i], 104 /* WhileKeyword */)) {
@@ -46753,13 +50440,13 @@ var ts;
var owner = getBreakOrContinueOwner(breakOrContinueStatement);
if (owner) {
switch (owner.kind) {
- case 199 /* ForStatement */:
- case 200 /* ForInStatement */:
- case 201 /* ForOfStatement */:
- case 197 /* DoStatement */:
- case 198 /* WhileStatement */:
+ case 202 /* ForStatement */:
+ case 203 /* ForInStatement */:
+ case 204 /* ForOfStatement */:
+ case 200 /* DoStatement */:
+ case 201 /* WhileStatement */:
return getLoopBreakContinueOccurrences(owner);
- case 206 /* SwitchStatement */:
+ case 209 /* SwitchStatement */:
return getSwitchCaseDefaultOccurrences(owner);
}
}
@@ -46813,7 +50500,7 @@ var ts;
function getReturnOccurrences(returnStatement) {
var func = ts.getContainingFunction(returnStatement);
// If we didn't find a containing function with a block body, bail out.
- if (!(func && hasKind(func.body, 192 /* Block */))) {
+ if (!(func && hasKind(func.body, 195 /* Block */))) {
return undefined;
}
var keywords = [];
@@ -46829,7 +50516,7 @@ var ts;
function getIfElseOccurrences(ifStatement) {
var keywords = [];
// Traverse upwards through all parent if-statements linked by their else-branches.
- while (hasKind(ifStatement.parent, 196 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) {
+ while (hasKind(ifStatement.parent, 199 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) {
ifStatement = ifStatement.parent;
}
// Now traverse back down through the else branches, aggregating if/else keywords of if-statements.
@@ -46842,7 +50529,7 @@ var ts;
break;
}
}
- if (!hasKind(ifStatement.elseStatement, 196 /* IfStatement */)) {
+ if (!hasKind(ifStatement.elseStatement, 199 /* IfStatement */)) {
break;
}
ifStatement = ifStatement.elseStatement;
@@ -46888,8 +50575,8 @@ var ts;
return undefined;
}
var result = [];
- for (var _i = 0; _i < documentHighlights.length; _i++) {
- var entry = documentHighlights[_i];
+ for (var _i = 0, documentHighlights_1 = documentHighlights; _i < documentHighlights_1.length; _i++) {
+ var entry = documentHighlights_1[_i];
for (var _a = 0, _b = entry.highlightSpans; _a < _b.length; _a++) {
var highlightSpan = _b[_a];
result.push({
@@ -46907,8 +50594,8 @@ var ts;
return undefined;
}
var referenceEntries = [];
- for (var _i = 0; _i < referenceSymbols.length; _i++) {
- var referenceSymbol = referenceSymbols[_i];
+ for (var _i = 0, referenceSymbols_1 = referenceSymbols; _i < referenceSymbols_1.length; _i++) {
+ var referenceSymbol = referenceSymbols_1[_i];
ts.addRange(referenceEntries, referenceSymbol.references);
}
return referenceEntries;
@@ -46918,11 +50605,11 @@ var ts;
return convertReferences(referencedSymbols);
}
function getReferencesAtPosition(fileName, position) {
- var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false);
+ var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false);
return convertReferences(referencedSymbols);
}
function findReferences(fileName, position) {
- var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false);
+ var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false);
// Only include referenced symbols that have a valid definition.
return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; });
}
@@ -46935,8 +50622,8 @@ var ts;
}
if (node.kind !== 69 /* Identifier */ &&
// TODO (drosen): This should be enabled in a later release - currently breaks rename.
- //node.kind !== SyntaxKind.ThisKeyword &&
- //node.kind !== SyntaxKind.SuperKeyword &&
+ // node.kind !== SyntaxKind.ThisKeyword &&
+ // node.kind !== SyntaxKind.SuperKeyword &&
!isLiteralNameOfPropertyDeclarationOrIndexAccess(node) &&
!isNameOfExternalModuleImportOrDeclaration(node)) {
return undefined;
@@ -46959,7 +50646,7 @@ var ts;
return getLabelReferencesInNode(node.parent, node);
}
}
- if (node.kind === 97 /* ThisKeyword */) {
+ if (node.kind === 97 /* ThisKeyword */ || node.kind === 162 /* ThisType */) {
return getReferencesForThisKeyword(node, sourceFiles);
}
if (node.kind === 95 /* SuperKeyword */) {
@@ -46993,11 +50680,11 @@ var ts;
}
else {
var internedName = getInternedName(symbol, node, declarations);
- for (var _i = 0; _i < sourceFiles.length; _i++) {
- var sourceFile = sourceFiles[_i];
+ for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) {
+ var sourceFile = sourceFiles_3[_i];
cancellationToken.throwIfCancellationRequested();
var nameTable = getNameTable(sourceFile);
- if (ts.lookUp(nameTable, internedName)) {
+ if (ts.lookUp(nameTable, internedName) !== undefined) {
result = result || [];
getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex);
}
@@ -47020,10 +50707,8 @@ var ts;
textSpan: ts.createTextSpan(declarations[0].getStart(), 0)
};
}
- function isImportOrExportSpecifierImportSymbol(symbol) {
- return (symbol.flags & 8388608 /* Alias */) && ts.forEach(symbol.declarations, function (declaration) {
- return declaration.kind === 226 /* ImportSpecifier */ || declaration.kind === 230 /* ExportSpecifier */;
- });
+ function isImportSpecifierSymbol(symbol) {
+ return (symbol.flags & 8388608 /* Alias */) && !!ts.getDeclarationOfKind(symbol, 229 /* ImportSpecifier */);
}
function getInternedName(symbol, location, declarations) {
// If this is an export or import specifier it could have been renamed using the 'as' syntax.
@@ -47049,14 +50734,14 @@ var ts;
// If this is the symbol of a named function expression or named class expression,
// then named references are limited to its own scope.
var valueDeclaration = symbol.valueDeclaration;
- if (valueDeclaration && (valueDeclaration.kind === 173 /* FunctionExpression */ || valueDeclaration.kind === 186 /* ClassExpression */)) {
+ if (valueDeclaration && (valueDeclaration.kind === 176 /* FunctionExpression */ || valueDeclaration.kind === 189 /* ClassExpression */)) {
return valueDeclaration;
}
// If this is private property or method, the scope is the containing class
if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) {
- var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; });
+ var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 16 /* Private */) ? d : undefined; });
if (privateDeclaration) {
- return ts.getAncestor(privateDeclaration, 214 /* ClassDeclaration */);
+ return ts.getAncestor(privateDeclaration, 217 /* ClassDeclaration */);
}
}
// If the symbol is an import we would like to find it if we are looking for what it imports.
@@ -47069,11 +50754,11 @@ var ts;
if (symbol.parent || (symbol.flags & 268435456 /* SyntheticProperty */)) {
return undefined;
}
- var scope = undefined;
+ var scope;
var declarations = symbol.getDeclarations();
if (declarations) {
- for (var _i = 0; _i < declarations.length; _i++) {
- var declaration = declarations[_i];
+ for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
+ var declaration = declarations_8[_i];
var container = getContainerNode(declaration);
if (!container) {
return undefined;
@@ -47082,7 +50767,7 @@ var ts;
// Different declarations have different containers, bail out
return undefined;
}
- if (container.kind === 248 /* SourceFile */ && !ts.isExternalModule(container)) {
+ if (container.kind === 251 /* SourceFile */ && !ts.isExternalModule(container)) {
// This is a global variable and not an external module, any declaration defined
// within this scope is visible outside the file
return undefined;
@@ -47181,7 +50866,7 @@ var ts;
var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, container.getStart(), container.getEnd());
if (possiblePositions.length) {
// Build the set of symbols to search for, initially it has only the current symbol
- var searchSymbols = populateSearchSymbolSet(searchSymbol, searchLocation);
+ var searchSymbols_1 = populateSearchSymbolSet(searchSymbol, searchLocation);
ts.forEach(possiblePositions, function (position) {
cancellationToken.throwIfCancellationRequested();
var referenceLocation = ts.getTouchingPropertyName(sourceFile, position);
@@ -47213,12 +50898,12 @@ var ts;
if (referenceSymbol) {
var referenceSymbolDeclaration = referenceSymbol.valueDeclaration;
var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration);
- var relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation);
+ var relatedSymbol = getRelatedSymbol(searchSymbols_1, referenceSymbol, referenceLocation);
if (relatedSymbol) {
var referencedSymbol = getReferencedSymbol(relatedSymbol);
referencedSymbol.references.push(getReferenceEntryFromNode(referenceLocation));
}
- else if (!(referenceSymbol.flags & 67108864 /* Transient */) && searchSymbols.indexOf(shorthandValueSymbol) >= 0) {
+ else if (!(referenceSymbol.flags & 67108864 /* Transient */) && searchSymbols_1.indexOf(shorthandValueSymbol) >= 0) {
var referencedSymbol = getReferencedSymbol(shorthandValueSymbol);
referencedSymbol.references.push(getReferenceEntryFromNode(referenceSymbolDeclaration.name));
}
@@ -47248,20 +50933,20 @@ var ts;
}
}
function getReferencesForSuperKeyword(superKeyword) {
- var searchSpaceNode = ts.getSuperContainer(superKeyword, /*includeFunctions*/ false);
+ var searchSpaceNode = ts.getSuperContainer(superKeyword, /*stopOnFunctions*/ false);
if (!searchSpaceNode) {
return undefined;
}
// Whether 'super' occurs in a static context within a class.
- var staticFlag = 128 /* Static */;
+ var staticFlag = 64 /* Static */;
switch (searchSpaceNode.kind) {
- case 141 /* PropertyDeclaration */:
- case 140 /* PropertySignature */:
- case 143 /* MethodDeclaration */:
- case 142 /* MethodSignature */:
- case 144 /* Constructor */:
- case 145 /* GetAccessor */:
- case 146 /* SetAccessor */:
+ case 142 /* PropertyDeclaration */:
+ case 141 /* PropertySignature */:
+ case 144 /* MethodDeclaration */:
+ case 143 /* MethodSignature */:
+ case 145 /* Constructor */:
+ case 146 /* GetAccessor */:
+ case 147 /* SetAccessor */:
staticFlag &= searchSpaceNode.flags;
searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class
break;
@@ -47277,11 +50962,11 @@ var ts;
if (!node || node.kind !== 95 /* SuperKeyword */) {
return;
}
- var container = ts.getSuperContainer(node, /*includeFunctions*/ false);
+ var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false);
// If we have a 'super' container, we must have an enclosing class.
// Now make sure the owning class is the same as the search-space
// and has the same static qualifier as the original 'super's owner.
- if (container && (128 /* Static */ & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) {
+ if (container && (64 /* Static */ & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) {
references.push(getReferenceEntryFromNode(node));
}
});
@@ -47291,29 +50976,29 @@ var ts;
function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) {
var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false);
// Whether 'this' occurs in a static context within a class.
- var staticFlag = 128 /* Static */;
+ var staticFlag = 64 /* Static */;
switch (searchSpaceNode.kind) {
- case 143 /* MethodDeclaration */:
- case 142 /* MethodSignature */:
+ case 144 /* MethodDeclaration */:
+ case 143 /* MethodSignature */:
if (ts.isObjectLiteralMethod(searchSpaceNode)) {
break;
}
// fall through
- case 141 /* PropertyDeclaration */:
- case 140 /* PropertySignature */:
- case 144 /* Constructor */:
- case 145 /* GetAccessor */:
- case 146 /* SetAccessor */:
+ case 142 /* PropertyDeclaration */:
+ case 141 /* PropertySignature */:
+ case 145 /* Constructor */:
+ case 146 /* GetAccessor */:
+ case 147 /* SetAccessor */:
staticFlag &= searchSpaceNode.flags;
searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class
break;
- case 248 /* SourceFile */:
+ case 251 /* SourceFile */:
if (ts.isExternalModule(searchSpaceNode)) {
return undefined;
}
// Fall through
- case 213 /* FunctionDeclaration */:
- case 173 /* FunctionExpression */:
+ case 216 /* FunctionDeclaration */:
+ case 176 /* FunctionExpression */:
break;
// Computed properties in classes are not handled here because references to this are illegal,
// so there is no point finding references to them.
@@ -47322,7 +51007,7 @@ var ts;
}
var references = [];
var possiblePositions;
- if (searchSpaceNode.kind === 248 /* SourceFile */) {
+ if (searchSpaceNode.kind === 251 /* SourceFile */) {
ts.forEach(sourceFiles, function (sourceFile) {
possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd());
getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references);
@@ -47348,33 +51033,33 @@ var ts;
ts.forEach(possiblePositions, function (position) {
cancellationToken.throwIfCancellationRequested();
var node = ts.getTouchingWord(sourceFile, position);
- if (!node || node.kind !== 97 /* ThisKeyword */) {
+ if (!node || (node.kind !== 97 /* ThisKeyword */ && node.kind !== 162 /* ThisType */)) {
return;
}
var container = ts.getThisContainer(node, /* includeArrowFunctions */ false);
switch (searchSpaceNode.kind) {
- case 173 /* FunctionExpression */:
- case 213 /* FunctionDeclaration */:
+ case 176 /* FunctionExpression */:
+ case 216 /* FunctionDeclaration */:
if (searchSpaceNode.symbol === container.symbol) {
result.push(getReferenceEntryFromNode(node));
}
break;
- case 143 /* MethodDeclaration */:
- case 142 /* MethodSignature */:
+ case 144 /* MethodDeclaration */:
+ case 143 /* MethodSignature */:
if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) {
result.push(getReferenceEntryFromNode(node));
}
break;
- case 186 /* ClassExpression */:
- case 214 /* ClassDeclaration */:
+ case 189 /* ClassExpression */:
+ case 217 /* ClassDeclaration */:
// Make sure the container belongs to the same class
// and has the appropriate static modifier from the original container.
- if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) {
+ if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 64 /* Static */) === staticFlag) {
result.push(getReferenceEntryFromNode(node));
}
break;
- case 248 /* SourceFile */:
- if (container.kind === 248 /* SourceFile */ && !ts.isExternalModule(container)) {
+ case 251 /* SourceFile */:
+ if (container.kind === 251 /* SourceFile */ && !ts.isExternalModule(container)) {
result.push(getReferenceEntryFromNode(node));
}
break;
@@ -47386,9 +51071,17 @@ var ts;
// The search set contains at least the current symbol
var result = [symbol];
// If the symbol is an alias, add what it alaises to the list
- if (isImportOrExportSpecifierImportSymbol(symbol)) {
+ if (isImportSpecifierSymbol(symbol)) {
result.push(typeChecker.getAliasedSymbol(symbol));
}
+ // For export specifiers, the exported name can be refering to a local symbol, e.g.:
+ // import {a} from "mod";
+ // export {a as somethingElse}
+ // We want the *local* declaration of 'a' as declared in the import,
+ // *not* as declared within "mod" (or farther)
+ if (location.parent.kind === 233 /* ExportSpecifier */) {
+ result.push(typeChecker.getExportSpecifierLocalTargetSymbol(location.parent));
+ }
// If the location is in a context sensitive location (i.e. in an object literal) try
// to get a contextual type for it, and add the property symbol from the contextual
// type to the search set
@@ -47401,8 +51094,8 @@ var ts;
* property name and variable declaration of the identifier.
* Like in below example, when querying for all references for an identifier 'name', of the property assignment, the language service
* should show both 'name' in 'obj' and 'name' in variable declaration
- * let name = "Foo";
- * let obj = { name };
+ * const name = "Foo";
+ * const obj = { name };
* In order to do that, we will populate the search set with the value symbol of the identifier as a value of the property assignment
* so that when matching with potential reference symbol, both symbols from property declaration and variable declaration
* will be included correctly.
@@ -47412,6 +51105,14 @@ var ts;
result.push(shorthandValueSymbol);
}
}
+ // If the symbol.valueDeclaration is a property parameter declaration,
+ // we should include both parameter declaration symbol and property declaration symbol
+ // Parameter Declaration symbol is only visible within function scope, so the symbol is stored in contructor.locals.
+ // Property Declaration symbol is a member of the class, so the symbol is stored in its class Declaration.symbol.members
+ if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 139 /* Parameter */ &&
+ ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) {
+ result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name));
+ }
// If this is a union property, add all the symbols from all its source symbols in all unioned types.
// If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list
ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) {
@@ -47420,19 +51121,44 @@ var ts;
}
// Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions
if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) {
- getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result);
+ getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ {});
}
});
return result;
}
- function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) {
- if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) {
+ /**
+ * Find symbol of the given property-name and add the symbol to the given result array
+ * @param symbol a symbol to start searching for the given propertyName
+ * @param propertyName a name of property to serach for
+ * @param result an array of symbol of found property symbols
+ * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisitng of the same symbol.
+ * The value of previousIterationSymbol is undefined when the function is first called.
+ */
+ function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache) {
+ if (!symbol) {
+ return;
+ }
+ // If the current symbol is the same as the previous-iteration symbol, we can just return the symbol that has already been visited
+ // This is particularly important for the following cases, so that we do not infinitely visit the same symbol.
+ // For example:
+ // interface C extends C {
+ // /*findRef*/propName: string;
+ // }
+ // The first time getPropertySymbolsFromBaseTypes is called when finding-all-references at propName,
+ // the symbol argument will be the symbol of an interface "C" and previousIterationSymbol is undefined,
+ // the function will add any found symbol of the property-name, then its sub-routine will call
+ // getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already
+ // visited symbol, interface "C", the sub-routine will pass the current symbol as previousIterationSymbol.
+ if (ts.hasProperty(previousIterationSymbolsCache, symbol.name)) {
+ return;
+ }
+ if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) {
ts.forEach(symbol.getDeclarations(), function (declaration) {
- if (declaration.kind === 214 /* ClassDeclaration */) {
+ if (declaration.kind === 217 /* ClassDeclaration */) {
getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration));
ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference);
}
- else if (declaration.kind === 215 /* InterfaceDeclaration */) {
+ else if (declaration.kind === 218 /* InterfaceDeclaration */) {
ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference);
}
});
@@ -47447,7 +51173,8 @@ var ts;
result.push(propertySymbol);
}
// Visit the typeReference as well to see if it directly or indirectly use that property
- getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result);
+ previousIterationSymbolsCache[symbol.name] = symbol;
+ getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache);
}
}
}
@@ -47458,12 +51185,22 @@ var ts;
}
// If the reference symbol is an alias, check if what it is aliasing is one of the search
// symbols.
- if (isImportOrExportSpecifierImportSymbol(referenceSymbol)) {
+ if (isImportSpecifierSymbol(referenceSymbol)) {
var aliasedSymbol = typeChecker.getAliasedSymbol(referenceSymbol);
if (searchSymbols.indexOf(aliasedSymbol) >= 0) {
return aliasedSymbol;
}
}
+ // For export specifiers, it can be a local symbol, e.g.
+ // import {a} from "mod";
+ // export {a as somethingElse}
+ // We want the local target of the export (i.e. the import symbol) and not the final target (i.e. "mod".a)
+ if (referenceLocation.parent.kind === 233 /* ExportSpecifier */) {
+ var aliasedSymbol = typeChecker.getExportSpecifierLocalTargetSymbol(referenceLocation.parent);
+ if (searchSymbols.indexOf(aliasedSymbol) >= 0) {
+ return aliasedSymbol;
+ }
+ }
// If the reference location is in an object literal, try to get the contextual type for the
// object literal, lookup the property symbol in the contextual type, and use this symbol to
// compare to our searchSymbol
@@ -47482,9 +51219,9 @@ var ts;
// Finally, try all properties with the same name in any type the containing type extended or implemented, and
// see if any is in the list
if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) {
- var result_3 = [];
- getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_3);
- return ts.forEach(result_3, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; });
+ var result_5 = [];
+ getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_5, /*previousIterationSymbolsCache*/ {});
+ return ts.forEach(result_5, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; });
}
return undefined;
});
@@ -47493,28 +51230,28 @@ var ts;
if (isNameOfPropertyAssignment(node)) {
var objectLiteral = node.parent.parent;
var contextualType = typeChecker.getContextualType(objectLiteral);
- var name_34 = node.text;
+ var name_37 = node.text;
if (contextualType) {
if (contextualType.flags & 16384 /* Union */) {
// This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types)
// if not, search the constituent types for the property
- var unionProperty = contextualType.getProperty(name_34);
+ var unionProperty = contextualType.getProperty(name_37);
if (unionProperty) {
return [unionProperty];
}
else {
- var result_4 = [];
+ var result_6 = [];
ts.forEach(contextualType.types, function (t) {
- var symbol = t.getProperty(name_34);
+ var symbol = t.getProperty(name_37);
if (symbol) {
- result_4.push(symbol);
+ result_6.push(symbol);
}
});
- return result_4;
+ return result_6;
}
}
else {
- var symbol_1 = contextualType.getProperty(name_34);
+ var symbol_1 = contextualType.getProperty(name_37);
if (symbol_1) {
return [symbol_1];
}
@@ -47532,7 +51269,7 @@ var ts;
*/
function getIntersectingMeaningFromDeclarations(meaning, declarations) {
if (declarations) {
- var lastIterationMeaning;
+ var lastIterationMeaning = void 0;
do {
// The result is order-sensitive, for instance if initialMeaning === Namespace, and declarations = [class, instantiated module]
// we need to consider both as they initialMeaning intersects with the module in the namespace space, and the module
@@ -47540,8 +51277,8 @@ var ts;
// To achieve that we will keep iterating until the result stabilizes.
// Remember the last meaning
lastIterationMeaning = meaning;
- for (var _i = 0; _i < declarations.length; _i++) {
- var declaration = declarations[_i];
+ for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) {
+ var declaration = declarations_9[_i];
var declarationMeaning = getMeaningFromDeclaration(declaration);
if (declarationMeaning & meaning) {
meaning |= declarationMeaning;
@@ -47572,10 +51309,10 @@ var ts;
}
var parent = node.parent;
if (parent) {
- if (parent.kind === 180 /* PostfixUnaryExpression */ || parent.kind === 179 /* PrefixUnaryExpression */) {
+ if (parent.kind === 183 /* PostfixUnaryExpression */ || parent.kind === 182 /* PrefixUnaryExpression */) {
return true;
}
- else if (parent.kind === 181 /* BinaryExpression */ && parent.left === node) {
+ else if (parent.kind === 184 /* BinaryExpression */ && parent.left === node) {
var operator = parent.operatorToken.kind;
return 56 /* FirstAssignment */ <= operator && operator <= 68 /* LastAssignment */;
}
@@ -47587,9 +51324,6 @@ var ts;
synchronizeHostData();
return ts.NavigateTo.getNavigateToItems(program, cancellationToken, searchValue, maxResultCount);
}
- function containErrors(diagnostics) {
- return ts.forEach(diagnostics, function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; });
- }
function getEmitOutput(fileName) {
synchronizeHostData();
var sourceFile = getValidSourceFile(fileName);
@@ -47609,34 +51343,34 @@ var ts;
}
function getMeaningFromDeclaration(node) {
switch (node.kind) {
- case 138 /* Parameter */:
- case 211 /* VariableDeclaration */:
- case 163 /* BindingElement */:
- case 141 /* PropertyDeclaration */:
- case 140 /* PropertySignature */:
- case 245 /* PropertyAssignment */:
- case 246 /* ShorthandPropertyAssignment */:
- case 247 /* EnumMember */:
- case 143 /* MethodDeclaration */:
- case 142 /* MethodSignature */:
- case 144 /* Constructor */:
- case 145 /* GetAccessor */:
- case 146 /* SetAccessor */:
- case 213 /* FunctionDeclaration */:
- case 173 /* FunctionExpression */:
- case 174 /* ArrowFunction */:
- case 244 /* CatchClause */:
+ case 139 /* Parameter */:
+ case 214 /* VariableDeclaration */:
+ case 166 /* BindingElement */:
+ case 142 /* PropertyDeclaration */:
+ case 141 /* PropertySignature */:
+ case 248 /* PropertyAssignment */:
+ case 249 /* ShorthandPropertyAssignment */:
+ case 250 /* EnumMember */:
+ case 144 /* MethodDeclaration */:
+ case 143 /* MethodSignature */:
+ case 145 /* Constructor */:
+ case 146 /* GetAccessor */:
+ case 147 /* SetAccessor */:
+ case 216 /* FunctionDeclaration */:
+ case 176 /* FunctionExpression */:
+ case 177 /* ArrowFunction */:
+ case 247 /* CatchClause */:
return 1 /* Value */;
- case 137 /* TypeParameter */:
- case 215 /* InterfaceDeclaration */:
- case 216 /* TypeAliasDeclaration */:
- case 155 /* TypeLiteral */:
+ case 138 /* TypeParameter */:
+ case 218 /* InterfaceDeclaration */:
+ case 219 /* TypeAliasDeclaration */:
+ case 156 /* TypeLiteral */:
return 2 /* Type */;
- case 214 /* ClassDeclaration */:
- case 217 /* EnumDeclaration */:
+ case 217 /* ClassDeclaration */:
+ case 220 /* EnumDeclaration */:
return 1 /* Value */ | 2 /* Type */;
- case 218 /* ModuleDeclaration */:
- if (node.name.kind === 9 /* StringLiteral */) {
+ case 221 /* ModuleDeclaration */:
+ if (ts.isAmbientModule(node)) {
return 4 /* Namespace */ | 1 /* Value */;
}
else if (ts.getModuleInstanceState(node) === 1 /* Instantiated */) {
@@ -47645,27 +51379,27 @@ var ts;
else {
return 4 /* Namespace */;
}
- case 225 /* NamedImports */:
- case 226 /* ImportSpecifier */:
- case 221 /* ImportEqualsDeclaration */:
- case 222 /* ImportDeclaration */:
- case 227 /* ExportAssignment */:
- case 228 /* ExportDeclaration */:
+ case 228 /* NamedImports */:
+ case 229 /* ImportSpecifier */:
+ case 224 /* ImportEqualsDeclaration */:
+ case 225 /* ImportDeclaration */:
+ case 230 /* ExportAssignment */:
+ case 231 /* ExportDeclaration */:
return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */;
// An external module can be a Value
- case 248 /* SourceFile */:
+ case 251 /* SourceFile */:
return 4 /* Namespace */ | 1 /* Value */;
}
return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */;
- ts.Debug.fail("Unknown declaration type");
}
function isTypeReference(node) {
if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) {
node = node.parent;
}
- return node.parent.kind === 151 /* TypeReference */ ||
- (node.parent.kind === 188 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) ||
- node.kind === 97 /* ThisKeyword */ && !ts.isExpression(node);
+ return node.parent.kind === 152 /* TypeReference */ ||
+ (node.parent.kind === 191 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) ||
+ (node.kind === 97 /* ThisKeyword */ && !ts.isExpression(node)) ||
+ node.kind === 162 /* ThisType */;
}
function isNamespaceReference(node) {
return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node);
@@ -47673,32 +51407,32 @@ var ts;
function isPropertyAccessNamespaceReference(node) {
var root = node;
var isLastClause = true;
- if (root.parent.kind === 166 /* PropertyAccessExpression */) {
- while (root.parent && root.parent.kind === 166 /* PropertyAccessExpression */) {
+ if (root.parent.kind === 169 /* PropertyAccessExpression */) {
+ while (root.parent && root.parent.kind === 169 /* PropertyAccessExpression */) {
root = root.parent;
}
isLastClause = root.name === node;
}
- if (!isLastClause && root.parent.kind === 188 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 243 /* HeritageClause */) {
+ if (!isLastClause && root.parent.kind === 191 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 246 /* HeritageClause */) {
var decl = root.parent.parent.parent;
- return (decl.kind === 214 /* ClassDeclaration */ && root.parent.parent.token === 106 /* ImplementsKeyword */) ||
- (decl.kind === 215 /* InterfaceDeclaration */ && root.parent.parent.token === 83 /* ExtendsKeyword */);
+ return (decl.kind === 217 /* ClassDeclaration */ && root.parent.parent.token === 106 /* ImplementsKeyword */) ||
+ (decl.kind === 218 /* InterfaceDeclaration */ && root.parent.parent.token === 83 /* ExtendsKeyword */);
}
return false;
}
function isQualifiedNameNamespaceReference(node) {
var root = node;
var isLastClause = true;
- if (root.parent.kind === 135 /* QualifiedName */) {
- while (root.parent && root.parent.kind === 135 /* QualifiedName */) {
+ if (root.parent.kind === 136 /* QualifiedName */) {
+ while (root.parent && root.parent.kind === 136 /* QualifiedName */) {
root = root.parent;
}
isLastClause = root.right === node;
}
- return root.parent.kind === 151 /* TypeReference */ && !isLastClause;
+ return root.parent.kind === 152 /* TypeReference */ && !isLastClause;
}
function isInRightSideOfImport(node) {
- while (node.parent.kind === 135 /* QualifiedName */) {
+ while (node.parent.kind === 136 /* QualifiedName */) {
node = node.parent;
}
return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node;
@@ -47708,15 +51442,15 @@ var ts;
// import a = |b|; // Namespace
// import a = |b.c|; // Value, type, namespace
// import a = |b.c|.d; // Namespace
- if (node.parent.kind === 135 /* QualifiedName */ &&
+ if (node.parent.kind === 136 /* QualifiedName */ &&
node.parent.right === node &&
- node.parent.parent.kind === 221 /* ImportEqualsDeclaration */) {
+ node.parent.parent.kind === 224 /* ImportEqualsDeclaration */) {
return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */;
}
return 4 /* Namespace */;
}
function getMeaningFromLocation(node) {
- if (node.parent.kind === 227 /* ExportAssignment */) {
+ if (node.parent.kind === 230 /* ExportAssignment */) {
return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */;
}
else if (isInRightSideOfImport(node)) {
@@ -47756,14 +51490,16 @@ var ts;
return;
}
switch (node.kind) {
- case 166 /* PropertyAccessExpression */:
- case 135 /* QualifiedName */:
+ case 169 /* PropertyAccessExpression */:
+ case 136 /* QualifiedName */:
case 9 /* StringLiteral */:
+ case 163 /* StringLiteralType */:
case 84 /* FalseKeyword */:
case 99 /* TrueKeyword */:
case 93 /* NullKeyword */:
case 95 /* SuperKeyword */:
case 97 /* ThisKeyword */:
+ case 162 /* ThisType */:
case 69 /* Identifier */:
break;
// Cant create the text span
@@ -47780,7 +51516,7 @@ var ts;
// If this is name of a module declarations, check if this is right side of dotted module name
// If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of
// Then this name is name from dotted module
- if (nodeForStartPos.parent.parent.kind === 218 /* ModuleDeclaration */ &&
+ if (nodeForStartPos.parent.parent.kind === 221 /* ModuleDeclaration */ &&
nodeForStartPos.parent.parent.body === nodeForStartPos.parent) {
// Use parent module declarations name for start pos
nodeForStartPos = nodeForStartPos.parent.parent.name;
@@ -47804,7 +51540,7 @@ var ts;
}
function getNavigationBarItems(fileName) {
var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
- return ts.NavigationBar.getNavigationBarItems(sourceFile);
+ return ts.NavigationBar.getNavigationBarItems(sourceFile, host.getCompilationSettings());
}
function getSemanticClassifications(fileName, span) {
return convertClassifications(getEncodedSemanticClassifications(fileName, span));
@@ -47821,10 +51557,10 @@ var ts;
// That means we're calling back into the host around every 1.2k of the file we process.
// Lib.d.ts has similar numbers.
switch (kind) {
- case 218 /* ModuleDeclaration */:
- case 214 /* ClassDeclaration */:
- case 215 /* InterfaceDeclaration */:
- case 213 /* FunctionDeclaration */:
+ case 221 /* ModuleDeclaration */:
+ case 217 /* ClassDeclaration */:
+ case 218 /* InterfaceDeclaration */:
+ case 216 /* FunctionDeclaration */:
cancellationToken.throwIfCancellationRequested();
}
}
@@ -47878,7 +51614,7 @@ var ts;
*/
function hasValueSideModule(symbol) {
return ts.forEach(symbol.declarations, function (declaration) {
- return declaration.kind === 218 /* ModuleDeclaration */ &&
+ return declaration.kind === 221 /* ModuleDeclaration */ &&
ts.getModuleInstanceState(declaration) === 1 /* Instantiated */;
});
}
@@ -47926,6 +51662,12 @@ var ts;
case 16 /* typeAliasName */: return ClassificationTypeNames.typeAliasName;
case 17 /* parameterName */: return ClassificationTypeNames.parameterName;
case 18 /* docCommentTagName */: return ClassificationTypeNames.docCommentTagName;
+ case 19 /* jsxOpenTagName */: return ClassificationTypeNames.jsxOpenTagName;
+ case 20 /* jsxCloseTagName */: return ClassificationTypeNames.jsxCloseTagName;
+ case 21 /* jsxSelfClosingTagName */: return ClassificationTypeNames.jsxSelfClosingTagName;
+ case 22 /* jsxAttribute */: return ClassificationTypeNames.jsxAttribute;
+ case 23 /* jsxText */: return ClassificationTypeNames.jsxText;
+ case 24 /* jsxAttributeStringLiteralValue */: return ClassificationTypeNames.jsxAttributeStringLiteralValue;
}
}
function convertClassifications(classifications) {
@@ -47949,8 +51691,8 @@ var ts;
var spanStart = span.start;
var spanLength = span.length;
// Make a scanner we can get trivia from.
- var triviaScanner = ts.createScanner(2 /* Latest */, /*skipTrivia:*/ false, sourceFile.languageVariant, sourceFile.text);
- var mergeConflictScanner = ts.createScanner(2 /* Latest */, /*skipTrivia:*/ false, sourceFile.languageVariant, sourceFile.text);
+ var triviaScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text);
+ var mergeConflictScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text);
var result = [];
processElement(sourceFile);
return { spans: result, endOfLineState: 0 /* None */ };
@@ -48033,16 +51775,16 @@ var ts;
pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */);
pos = tag.tagName.end;
switch (tag.kind) {
- case 267 /* JSDocParameterTag */:
+ case 270 /* JSDocParameterTag */:
processJSDocParameterTag(tag);
break;
- case 270 /* JSDocTemplateTag */:
+ case 273 /* JSDocTemplateTag */:
processJSDocTemplateTag(tag);
break;
- case 269 /* JSDocTypeTag */:
+ case 272 /* JSDocTypeTag */:
processElement(tag.typeExpression);
break;
- case 268 /* JSDocReturnTag */:
+ case 271 /* JSDocReturnTag */:
processElement(tag.typeExpression);
break;
}
@@ -48079,7 +51821,8 @@ var ts;
function classifyDisabledMergeCode(text, start, end) {
// Classify the line that the ======= marker is on as a comment. Then just lex
// all further tokens and add them to the result.
- for (var i = start; i < end; i++) {
+ var i;
+ for (i = start; i < end; i++) {
if (ts.isLineBreak(text.charCodeAt(i))) {
break;
}
@@ -48099,19 +51842,53 @@ var ts;
pushClassification(start, end - start, type);
}
}
- function classifyToken(token) {
- if (ts.nodeIsMissing(token)) {
- return;
+ /**
+ * Returns true if node should be treated as classified and no further processing is required.
+ * False will mean that node is not classified and traverse routine should recurse into node contents.
+ */
+ function tryClassifyNode(node) {
+ if (ts.nodeIsMissing(node)) {
+ return true;
+ }
+ var classifiedElementName = tryClassifyJsxElementName(node);
+ if (!ts.isToken(node) && node.kind !== 239 /* JsxText */ && classifiedElementName === undefined) {
+ return false;
}
- var tokenStart = classifyLeadingTriviaAndGetTokenStart(token);
- var tokenWidth = token.end - tokenStart;
+ var tokenStart = node.kind === 239 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node);
+ var tokenWidth = node.end - tokenStart;
ts.Debug.assert(tokenWidth >= 0);
if (tokenWidth > 0) {
- var type = classifyTokenType(token.kind, token);
+ var type = classifiedElementName || classifyTokenType(node.kind, node);
if (type) {
pushClassification(tokenStart, tokenWidth, type);
}
}
+ return true;
+ }
+ function tryClassifyJsxElementName(token) {
+ switch (token.parent && token.parent.kind) {
+ case 238 /* JsxOpeningElement */:
+ if (token.parent.tagName === token) {
+ return 19 /* jsxOpenTagName */;
+ }
+ break;
+ case 240 /* JsxClosingElement */:
+ if (token.parent.tagName === token) {
+ return 20 /* jsxCloseTagName */;
+ }
+ break;
+ case 237 /* JsxSelfClosingElement */:
+ if (token.parent.tagName === token) {
+ return 21 /* jsxSelfClosingTagName */;
+ }
+ break;
+ case 241 /* JsxAttribute */:
+ if (token.parent.name === token) {
+ return 22 /* jsxAttribute */;
+ }
+ break;
+ }
+ return undefined;
}
// for accurate classification, the actual token should be passed in. however, for
// cases like 'disabled merge code' classification, we just get the token kind and
@@ -48133,16 +51910,17 @@ var ts;
if (token) {
if (tokenKind === 56 /* EqualsToken */) {
// the '=' in a variable declaration is special cased here.
- if (token.parent.kind === 211 /* VariableDeclaration */ ||
- token.parent.kind === 141 /* PropertyDeclaration */ ||
- token.parent.kind === 138 /* Parameter */) {
+ if (token.parent.kind === 214 /* VariableDeclaration */ ||
+ token.parent.kind === 142 /* PropertyDeclaration */ ||
+ token.parent.kind === 139 /* Parameter */ ||
+ token.parent.kind === 241 /* JsxAttribute */) {
return 5 /* operator */;
}
}
- if (token.parent.kind === 181 /* BinaryExpression */ ||
- token.parent.kind === 179 /* PrefixUnaryExpression */ ||
- token.parent.kind === 180 /* PostfixUnaryExpression */ ||
- token.parent.kind === 182 /* ConditionalExpression */) {
+ if (token.parent.kind === 184 /* BinaryExpression */ ||
+ token.parent.kind === 182 /* PrefixUnaryExpression */ ||
+ token.parent.kind === 183 /* PostfixUnaryExpression */ ||
+ token.parent.kind === 185 /* ConditionalExpression */) {
return 5 /* operator */;
}
}
@@ -48151,8 +51929,8 @@ var ts;
else if (tokenKind === 8 /* NumericLiteral */) {
return 4 /* numericLiteral */;
}
- else if (tokenKind === 9 /* StringLiteral */) {
- return 6 /* stringLiteral */;
+ else if (tokenKind === 9 /* StringLiteral */ || tokenKind === 163 /* StringLiteralType */) {
+ return token.parent.kind === 241 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */;
}
else if (tokenKind === 10 /* RegularExpressionLiteral */) {
// TODO: we should get another classification type for these literals.
@@ -48162,35 +51940,38 @@ var ts;
// TODO (drosen): we should *also* get another classification type for these literals.
return 6 /* stringLiteral */;
}
+ else if (tokenKind === 239 /* JsxText */) {
+ return 23 /* jsxText */;
+ }
else if (tokenKind === 69 /* Identifier */) {
if (token) {
switch (token.parent.kind) {
- case 214 /* ClassDeclaration */:
+ case 217 /* ClassDeclaration */:
if (token.parent.name === token) {
return 11 /* className */;
}
return;
- case 137 /* TypeParameter */:
+ case 138 /* TypeParameter */:
if (token.parent.name === token) {
return 15 /* typeParameterName */;
}
return;
- case 215 /* InterfaceDeclaration */:
+ case 218 /* InterfaceDeclaration */:
if (token.parent.name === token) {
return 13 /* interfaceName */;
}
return;
- case 217 /* EnumDeclaration */:
+ case 220 /* EnumDeclaration */:
if (token.parent.name === token) {
return 12 /* enumName */;
}
return;
- case 218 /* ModuleDeclaration */:
+ case 221 /* ModuleDeclaration */:
if (token.parent.name === token) {
return 14 /* moduleName */;
}
return;
- case 138 /* Parameter */:
+ case 139 /* Parameter */:
if (token.parent.name === token) {
return 17 /* parameterName */;
}
@@ -48210,10 +51991,7 @@ var ts;
var children = element.getChildren(sourceFile);
for (var i = 0, n = children.length; i < n; i++) {
var child = children[i];
- if (ts.isToken(child)) {
- classifyToken(child);
- }
- else {
+ if (!tryClassifyNode(child)) {
// Recurse into our child nodes.
processElement(child);
}
@@ -48236,8 +52014,8 @@ var ts;
if (matchKind) {
var parentElement = token.parent;
var childNodes = parentElement.getChildren(sourceFile);
- for (var _i = 0; _i < childNodes.length; _i++) {
- var current = childNodes[_i];
+ for (var _i = 0, childNodes_1 = childNodes; _i < childNodes_1.length; _i++) {
+ var current = childNodes_1[_i];
if (current.kind === matchKind) {
var range1 = ts.createTextSpan(token.getStart(sourceFile), token.getWidth(sourceFile));
var range2 = ts.createTextSpan(current.getStart(sourceFile), current.getWidth(sourceFile));
@@ -48319,7 +52097,6 @@ var ts;
* be performed.
*/
function getDocCommentTemplateAtPosition(fileName, position) {
- var start = new Date().getTime();
var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
// Check if in a context where we don't want to perform any insertion
if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position) || ts.hasDocComment(sourceFile, position)) {
@@ -48338,19 +52115,19 @@ var ts;
var commentOwner;
findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) {
switch (commentOwner.kind) {
- case 213 /* FunctionDeclaration */:
- case 143 /* MethodDeclaration */:
- case 144 /* Constructor */:
- case 214 /* ClassDeclaration */:
- case 193 /* VariableStatement */:
+ case 216 /* FunctionDeclaration */:
+ case 144 /* MethodDeclaration */:
+ case 145 /* Constructor */:
+ case 217 /* ClassDeclaration */:
+ case 196 /* VariableStatement */:
break findOwner;
- case 248 /* SourceFile */:
+ case 251 /* SourceFile */:
return undefined;
- case 218 /* ModuleDeclaration */:
+ case 221 /* ModuleDeclaration */:
// If in walking up the tree, we hit a a nested namespace declaration,
// then we must be somewhere within a dotted namespace name; however we don't
// want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'.
- if (commentOwner.parent.kind === 218 /* ModuleDeclaration */) {
+ if (commentOwner.parent.kind === 221 /* ModuleDeclaration */) {
return undefined;
}
break findOwner;
@@ -48363,8 +52140,7 @@ var ts;
var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position);
var lineStart = sourceFile.getLineStarts()[posLineAndChar.line];
var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character);
- // TODO: call a helper method instead once PR #4133 gets merged in.
- var newLine = host.getNewLine ? host.getNewLine() : "\r\n";
+ var newLine = ts.getNewLineOrDefaultFromHost(host);
var docParams = "";
for (var i = 0, numParams = parameters.length; i < numParams; i++) {
var currentName = parameters[i].name;
@@ -48392,7 +52168,7 @@ var ts;
if (ts.isFunctionLike(commentOwner)) {
return commentOwner.parameters;
}
- if (commentOwner.kind === 193 /* VariableStatement */) {
+ if (commentOwner.kind === 196 /* VariableStatement */) {
var varStatement = commentOwner;
var varDeclarations = varStatement.declarationList.declarations;
if (varDeclarations.length === 1 && varDeclarations[0].initializer) {
@@ -48410,17 +52186,17 @@ var ts;
* @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'.
*/
function getParametersFromRightHandSideOfAssignment(rightHandSide) {
- while (rightHandSide.kind === 172 /* ParenthesizedExpression */) {
+ while (rightHandSide.kind === 175 /* ParenthesizedExpression */) {
rightHandSide = rightHandSide.expression;
}
switch (rightHandSide.kind) {
- case 173 /* FunctionExpression */:
- case 174 /* ArrowFunction */:
+ case 176 /* FunctionExpression */:
+ case 177 /* ArrowFunction */:
return rightHandSide.parameters;
- case 186 /* ClassExpression */:
+ case 189 /* ClassExpression */:
for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) {
var member = _a[_i];
- if (member.kind === 144 /* Constructor */) {
+ if (member.kind === 145 /* Constructor */) {
return member.parameters;
}
}
@@ -48442,7 +52218,7 @@ var ts;
var result = [];
if (descriptors.length > 0) {
var regExp = getTodoCommentsRegExp();
- var matchArray;
+ var matchArray = void 0;
while (matchArray = regExp.exec(fileContents)) {
cancellationToken.throwIfCancellationRequested();
// If we got a match, here is what the match array will look like. Say the source text is:
@@ -48566,13 +52342,18 @@ var ts;
if (declarations && declarations.length > 0) {
// Disallow rename for elements that are defined in the standard TypeScript library.
var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings());
+ var canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName));
if (defaultLibFileName) {
- for (var _i = 0; _i < declarations.length; _i++) {
- var current = declarations[_i];
- var sourceFile_2 = current.getSourceFile();
- var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName));
- if (sourceFile_2 && getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) {
- return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library.key));
+ for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) {
+ var current = declarations_10[_i];
+ var sourceFile_3 = current.getSourceFile();
+ // TODO (drosen): When is there no source file?
+ if (!sourceFile_3) {
+ continue;
+ }
+ var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_3.fileName));
+ if (canonicalName === canonicalDefaultLibName) {
+ return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library));
}
}
}
@@ -48581,10 +52362,10 @@ var ts;
if (kind) {
return {
canRename: true,
- localizedErrorMessage: undefined,
+ kind: kind,
displayName: displayName,
+ localizedErrorMessage: undefined,
fullDisplayName: typeChecker.getFullyQualifiedName(symbol),
- kind: kind,
kindModifiers: getSymbolModifiers(symbol),
triggerSpan: ts.createTextSpan(node.getStart(), node.getWidth())
};
@@ -48592,7 +52373,7 @@ var ts;
}
}
}
- return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_this_element.key));
+ return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_this_element));
function getRenameInfoError(localizedErrorMessage) {
return {
canRename: false,
@@ -48660,7 +52441,7 @@ var ts;
function walk(node) {
switch (node.kind) {
case 69 /* Identifier */:
- nameTable[node.text] = node.text;
+ nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1;
break;
case 9 /* StringLiteral */:
case 8 /* NumericLiteral */:
@@ -48669,9 +52450,9 @@ var ts;
// then we want 'something' to be in the name table. Similarly, if we have
// "a['propname']" then we want to store "propname" in the name table.
if (ts.isDeclarationName(node) ||
- node.parent.kind === 232 /* ExternalModuleReference */ ||
+ node.parent.kind === 235 /* ExternalModuleReference */ ||
isArgumentOfElementAccessExpression(node)) {
- nameTable[node.text] = node.text;
+ nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1;
}
break;
default:
@@ -48682,7 +52463,7 @@ var ts;
function isArgumentOfElementAccessExpression(node) {
return node &&
node.parent &&
- node.parent.kind === 167 /* ElementAccessExpression */ &&
+ node.parent.kind === 170 /* ElementAccessExpression */ &&
node.parent.argumentExpression === node;
}
/// Classifier
@@ -48811,7 +52592,7 @@ var ts;
// (and a newline). That way when we lex we'll think we're still in a multiline comment.
switch (lexState) {
case 3 /* InDoubleQuoteStringLiteral */:
- text = '"\\\n' + text;
+ text = "\"\\\n" + text;
offset = 3;
break;
case 2 /* InSingleQuoteStringLiteral */:
@@ -48941,7 +52722,7 @@ var ts;
var end = scanner.getTextPos();
addResult(start, end, classFromKind(token));
if (end >= text.length) {
- if (token === 9 /* StringLiteral */) {
+ if (token === 9 /* StringLiteral */ || token === 163 /* StringLiteralType */) {
// Check to see if we finished up on a multiline string literal.
var tokenText = scanner.getTokenText();
if (scanner.isUnterminated()) {
@@ -49064,7 +52845,7 @@ var ts;
}
}
function isKeyword(token) {
- return token >= 70 /* FirstKeyword */ && token <= 134 /* LastKeyword */;
+ return token >= 70 /* FirstKeyword */ && token <= 135 /* LastKeyword */;
}
function classFromKind(token) {
if (isKeyword(token)) {
@@ -49080,6 +52861,7 @@ var ts;
case 8 /* NumericLiteral */:
return 4 /* numericLiteral */;
case 9 /* StringLiteral */:
+ case 163 /* StringLiteralType */:
return 6 /* stringLiteral */;
case 10 /* RegularExpressionLiteral */:
return 7 /* regularExpressionLiteral */;
@@ -49119,18 +52901,8 @@ var ts;
ts.getDefaultLibFilePath = getDefaultLibFilePath;
function initializeServices() {
ts.objectAllocator = {
- getNodeConstructor: function (kind) {
- function Node() {
- }
- var proto = kind === 248 /* SourceFile */ ? new SourceFileObject() : new NodeObject();
- proto.kind = kind;
- proto.pos = -1;
- proto.end = -1;
- proto.flags = 0;
- proto.parent = undefined;
- Node.prototype = proto;
- return Node;
- },
+ getNodeConstructor: function () { return NodeObject; },
+ getSourceFileConstructor: function () { return SourceFileObject; },
getSymbolConstructor: function () { return SymbolObject; },
getTypeConstructor: function () { return TypeObject; },
getSignatureConstructor: function () { return SignatureObject; }
@@ -49151,12 +52923,12 @@ var ts;
*/
function spanInSourceFileAtLocation(sourceFile, position) {
// Cannot set breakpoint in dts file
- if (sourceFile.flags & 8192 /* DeclarationFile */) {
+ if (sourceFile.flags & 4096 /* DeclarationFile */) {
return undefined;
}
var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position);
var lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
- if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart()).line > lineOfPosition) {
+ if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart(sourceFile)).line > lineOfPosition) {
// Get previous token if the token is returned starts on new line
// eg: let x =10; |--- cursor is here
// let y = 10;
@@ -49175,14 +52947,23 @@ var ts;
// Get the span in the node based on its syntax
return spanInNode(tokenAtLocation);
function textSpan(startNode, endNode) {
- return ts.createTextSpanFromBounds(startNode.getStart(), (endNode || startNode).getEnd());
+ var start = startNode.decorators ?
+ ts.skipTrivia(sourceFile.text, startNode.decorators.end) :
+ startNode.getStart(sourceFile);
+ return ts.createTextSpanFromBounds(start, (endNode || startNode).getEnd());
+ }
+ function textSpanEndingAtNextToken(startNode, previousTokenToFindNextEndToken) {
+ return textSpan(startNode, ts.findNextToken(previousTokenToFindNextEndToken, previousTokenToFindNextEndToken.parent));
}
function spanInNodeIfStartsOnSameLine(node, otherwiseOnNode) {
- if (node && lineOfPosition === sourceFile.getLineAndCharacterOfPosition(node.getStart()).line) {
+ if (node && lineOfPosition === sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line) {
return spanInNode(node);
}
return spanInNode(otherwiseOnNode);
}
+ function spanInNodeArray(nodeArray) {
+ return ts.createTextSpanFromBounds(ts.skipTrivia(sourceFile.text, nodeArray.pos), nodeArray.end);
+ }
function spanInPreviousNode(node) {
return spanInNode(ts.findPrecedingToken(node.pos, sourceFile));
}
@@ -49191,126 +52972,114 @@ var ts;
}
function spanInNode(node) {
if (node) {
- if (ts.isExpression(node)) {
- if (node.parent.kind === 197 /* DoStatement */) {
- // Set span as if on while keyword
- return spanInPreviousNode(node);
- }
- if (node.parent.kind === 199 /* ForStatement */) {
- // For now lets set the span on this expression, fix it later
- return textSpan(node);
- }
- if (node.parent.kind === 181 /* BinaryExpression */ && node.parent.operatorToken.kind === 24 /* CommaToken */) {
- // if this is comma expression, the breakpoint is possible in this expression
- return textSpan(node);
- }
- if (node.parent.kind === 174 /* ArrowFunction */ && node.parent.body === node) {
- // If this is body of arrow function, it is allowed to have the breakpoint
- return textSpan(node);
- }
- }
switch (node.kind) {
- case 193 /* VariableStatement */:
+ case 196 /* VariableStatement */:
// Span on first variable declaration
return spanInVariableDeclaration(node.declarationList.declarations[0]);
- case 211 /* VariableDeclaration */:
- case 141 /* PropertyDeclaration */:
- case 140 /* PropertySignature */:
+ case 214 /* VariableDeclaration */:
+ case 142 /* PropertyDeclaration */:
+ case 141 /* PropertySignature */:
return spanInVariableDeclaration(node);
- case 138 /* Parameter */:
+ case 139 /* Parameter */:
return spanInParameterDeclaration(node);
- case 213 /* FunctionDeclaration */:
- case 143 /* MethodDeclaration */:
- case 142 /* MethodSignature */:
- case 145 /* GetAccessor */:
- case 146 /* SetAccessor */:
- case 144 /* Constructor */:
- case 173 /* FunctionExpression */:
- case 174 /* ArrowFunction */:
+ case 216 /* FunctionDeclaration */:
+ case 144 /* MethodDeclaration */:
+ case 143 /* MethodSignature */:
+ case 146 /* GetAccessor */:
+ case 147 /* SetAccessor */:
+ case 145 /* Constructor */:
+ case 176 /* FunctionExpression */:
+ case 177 /* ArrowFunction */:
return spanInFunctionDeclaration(node);
- case 192 /* Block */:
+ case 195 /* Block */:
if (ts.isFunctionBlock(node)) {
return spanInFunctionBlock(node);
}
// Fall through
- case 219 /* ModuleBlock */:
+ case 222 /* ModuleBlock */:
return spanInBlock(node);
- case 244 /* CatchClause */:
+ case 247 /* CatchClause */:
return spanInBlock(node.block);
- case 195 /* ExpressionStatement */:
+ case 198 /* ExpressionStatement */:
// span on the expression
return textSpan(node.expression);
- case 204 /* ReturnStatement */:
+ case 207 /* ReturnStatement */:
// span on return keyword and expression if present
return textSpan(node.getChildAt(0), node.expression);
- case 198 /* WhileStatement */:
+ case 201 /* WhileStatement */:
// Span on while(...)
- return textSpan(node, ts.findNextToken(node.expression, node));
- case 197 /* DoStatement */:
+ return textSpanEndingAtNextToken(node, node.expression);
+ case 200 /* DoStatement */:
// span in statement of the do statement
return spanInNode(node.statement);
- case 210 /* DebuggerStatement */:
+ case 213 /* DebuggerStatement */:
// span on debugger keyword
return textSpan(node.getChildAt(0));
- case 196 /* IfStatement */:
+ case 199 /* IfStatement */:
// set on if(..) span
- return textSpan(node, ts.findNextToken(node.expression, node));
- case 207 /* LabeledStatement */:
+ return textSpanEndingAtNextToken(node, node.expression);
+ case 210 /* LabeledStatement */:
// span in statement
return spanInNode(node.statement);
- case 203 /* BreakStatement */:
- case 202 /* ContinueStatement */:
+ case 206 /* BreakStatement */:
+ case 205 /* ContinueStatement */:
// On break or continue keyword and label if present
return textSpan(node.getChildAt(0), node.label);
- case 199 /* ForStatement */:
+ case 202 /* ForStatement */:
return spanInForStatement(node);
- case 200 /* ForInStatement */:
- case 201 /* ForOfStatement */:
- // span on for (a in ...)
- return textSpan(node, ts.findNextToken(node.expression, node));
- case 206 /* SwitchStatement */:
+ case 203 /* ForInStatement */:
+ // span of for (a in ...)
+ return textSpanEndingAtNextToken(node, node.expression);
+ case 204 /* ForOfStatement */:
+ // span in initializer
+ return spanInInitializerOfForLike(node);
+ case 209 /* SwitchStatement */:
// span on switch(...)
- return textSpan(node, ts.findNextToken(node.expression, node));
- case 241 /* CaseClause */:
- case 242 /* DefaultClause */:
+ return textSpanEndingAtNextToken(node, node.expression);
+ case 244 /* CaseClause */:
+ case 245 /* DefaultClause */:
// span in first statement of the clause
return spanInNode(node.statements[0]);
- case 209 /* TryStatement */:
+ case 212 /* TryStatement */:
// span in try block
return spanInBlock(node.tryBlock);
- case 208 /* ThrowStatement */:
+ case 211 /* ThrowStatement */:
// span in throw ...
return textSpan(node, node.expression);
- case 227 /* ExportAssignment */:
+ case 230 /* ExportAssignment */:
// span on export = id
return textSpan(node, node.expression);
- case 221 /* ImportEqualsDeclaration */:
+ case 224 /* ImportEqualsDeclaration */:
// import statement without including semicolon
return textSpan(node, node.moduleReference);
- case 222 /* ImportDeclaration */:
+ case 225 /* ImportDeclaration */:
// import statement without including semicolon
return textSpan(node, node.moduleSpecifier);
- case 228 /* ExportDeclaration */:
+ case 231 /* ExportDeclaration */:
// import statement without including semicolon
return textSpan(node, node.moduleSpecifier);
- case 218 /* ModuleDeclaration */:
+ case 221 /* ModuleDeclaration */:
// span on complete module if it is instantiated
if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) {
return undefined;
}
- case 214 /* ClassDeclaration */:
- case 217 /* EnumDeclaration */:
- case 247 /* EnumMember */:
- case 168 /* CallExpression */:
- case 169 /* NewExpression */:
+ case 217 /* ClassDeclaration */:
+ case 220 /* EnumDeclaration */:
+ case 250 /* EnumMember */:
+ case 166 /* BindingElement */:
// span on complete node
return textSpan(node);
- case 205 /* WithStatement */:
+ case 208 /* WithStatement */:
// span in statement
return spanInNode(node.statement);
+ case 140 /* Decorator */:
+ return spanInNodeArray(node.parent.decorators);
+ case 164 /* ObjectBindingPattern */:
+ case 165 /* ArrayBindingPattern */:
+ return spanInBindingPattern(node);
// No breakpoint in interface, type alias
- case 215 /* InterfaceDeclaration */:
- case 216 /* TypeAliasDeclaration */:
+ case 218 /* InterfaceDeclaration */:
+ case 219 /* TypeAliasDeclaration */:
return undefined;
// Tokens:
case 23 /* SemicolonToken */:
@@ -49322,6 +53091,8 @@ var ts;
return spanInOpenBraceToken(node);
case 16 /* CloseBraceToken */:
return spanInCloseBraceToken(node);
+ case 20 /* CloseBracketToken */:
+ return spanInCloseBracketToken(node);
case 17 /* OpenParenToken */:
return spanInOpenParenToken(node);
case 18 /* CloseParenToken */:
@@ -49338,67 +53109,155 @@ var ts;
case 72 /* CatchKeyword */:
case 85 /* FinallyKeyword */:
return spanInNextNode(node);
+ case 135 /* OfKeyword */:
+ return spanInOfKeyword(node);
default:
+ // Destructuring pattern in destructuring assignment
+ // [a, b, c] of
+ // [a, b, c] = expression
+ if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node)) {
+ return spanInArrayLiteralOrObjectLiteralDestructuringPattern(node);
+ }
+ // Set breakpoint on identifier element of destructuring pattern
+ // a or ...c or d: x from
+ // [a, b, ...c] or { a, b } or { d: x } from destructuring pattern
+ if ((node.kind === 69 /* Identifier */ ||
+ node.kind == 188 /* SpreadElementExpression */ ||
+ node.kind === 248 /* PropertyAssignment */ ||
+ node.kind === 249 /* ShorthandPropertyAssignment */) &&
+ ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) {
+ return textSpan(node);
+ }
+ if (node.kind === 184 /* BinaryExpression */) {
+ var binaryExpression = node;
+ // Set breakpoint in destructuring pattern if its destructuring assignment
+ // [a, b, c] or {a, b, c} of
+ // [a, b, c] = expression or
+ // {a, b, c} = expression
+ if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left)) {
+ return spanInArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left);
+ }
+ if (binaryExpression.operatorToken.kind === 56 /* EqualsToken */ &&
+ ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.parent)) {
+ // Set breakpoint on assignment expression element of destructuring pattern
+ // a = expression of
+ // [a = expression, b, c] = someExpression or
+ // { a = expression, b, c } = someExpression
+ return textSpan(node);
+ }
+ if (binaryExpression.operatorToken.kind === 24 /* CommaToken */) {
+ return spanInNode(binaryExpression.left);
+ }
+ }
+ if (ts.isExpression(node)) {
+ switch (node.parent.kind) {
+ case 200 /* DoStatement */:
+ // Set span as if on while keyword
+ return spanInPreviousNode(node);
+ case 140 /* Decorator */:
+ // Set breakpoint on the decorator emit
+ return spanInNode(node.parent);
+ case 202 /* ForStatement */:
+ case 204 /* ForOfStatement */:
+ return textSpan(node);
+ case 184 /* BinaryExpression */:
+ if (node.parent.operatorToken.kind === 24 /* CommaToken */) {
+ // if this is comma expression, the breakpoint is possible in this expression
+ return textSpan(node);
+ }
+ break;
+ case 177 /* ArrowFunction */:
+ if (node.parent.body === node) {
+ // If this is body of arrow function, it is allowed to have the breakpoint
+ return textSpan(node);
+ }
+ break;
+ }
+ }
// If this is name of property assignment, set breakpoint in the initializer
- if (node.parent.kind === 245 /* PropertyAssignment */ && node.parent.name === node) {
+ if (node.parent.kind === 248 /* PropertyAssignment */ &&
+ node.parent.name === node &&
+ !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) {
return spanInNode(node.parent.initializer);
}
// Breakpoint in type assertion goes to its operand
- if (node.parent.kind === 171 /* TypeAssertionExpression */ && node.parent.type === node) {
- return spanInNode(node.parent.expression);
+ if (node.parent.kind === 174 /* TypeAssertionExpression */ && node.parent.type === node) {
+ return spanInNextNode(node.parent.type);
}
// return type of function go to previous token
if (ts.isFunctionLike(node.parent) && node.parent.type === node) {
return spanInPreviousNode(node);
}
+ // initializer of variable/parameter declaration go to previous node
+ if ((node.parent.kind === 214 /* VariableDeclaration */ ||
+ node.parent.kind === 139 /* Parameter */)) {
+ var paramOrVarDecl = node.parent;
+ if (paramOrVarDecl.initializer === node ||
+ paramOrVarDecl.type === node ||
+ ts.isAssignmentOperator(node.kind)) {
+ return spanInPreviousNode(node);
+ }
+ }
+ if (node.parent.kind === 184 /* BinaryExpression */) {
+ var binaryExpression = node.parent;
+ if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) &&
+ (binaryExpression.right === node ||
+ binaryExpression.operatorToken === node)) {
+ // If initializer of destructuring assignment move to previous token
+ return spanInPreviousNode(node);
+ }
+ }
// Default go to parent to set the breakpoint
return spanInNode(node.parent);
}
}
+ function textSpanFromVariableDeclaration(variableDeclaration) {
+ var declarations = variableDeclaration.parent.declarations;
+ if (declarations && declarations[0] === variableDeclaration) {
+ // First declaration - include let keyword
+ return textSpan(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration);
+ }
+ else {
+ // Span only on this declaration
+ return textSpan(variableDeclaration);
+ }
+ }
function spanInVariableDeclaration(variableDeclaration) {
// If declaration of for in statement, just set the span in parent
- if (variableDeclaration.parent.parent.kind === 200 /* ForInStatement */ ||
- variableDeclaration.parent.parent.kind === 201 /* ForOfStatement */) {
+ if (variableDeclaration.parent.parent.kind === 203 /* ForInStatement */) {
return spanInNode(variableDeclaration.parent.parent);
}
- var isParentVariableStatement = variableDeclaration.parent.parent.kind === 193 /* VariableStatement */;
- var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 199 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration);
- var declarations = isParentVariableStatement
- ? variableDeclaration.parent.parent.declarationList.declarations
- : isDeclarationOfForStatement
- ? variableDeclaration.parent.parent.initializer.declarations
- : undefined;
- // Breakpoint is possible in variableDeclaration only if there is initialization
- if (variableDeclaration.initializer || (variableDeclaration.flags & 1 /* Export */)) {
- if (declarations && declarations[0] === variableDeclaration) {
- if (isParentVariableStatement) {
- // First declaration - include let keyword
- return textSpan(variableDeclaration.parent, variableDeclaration);
- }
- else {
- ts.Debug.assert(isDeclarationOfForStatement);
- // Include let keyword from for statement declarations in the span
- return textSpan(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration);
- }
- }
- else {
- // Span only on this declaration
- return textSpan(variableDeclaration);
- }
+ // If this is a destructuring pattern set breakpoint in binding pattern
+ if (ts.isBindingPattern(variableDeclaration.name)) {
+ return spanInBindingPattern(variableDeclaration.name);
}
- else if (declarations && declarations[0] !== variableDeclaration) {
+ // Breakpoint is possible in variableDeclaration only if there is initialization
+ // or its declaration from 'for of'
+ if (variableDeclaration.initializer ||
+ (variableDeclaration.flags & 2 /* Export */) ||
+ variableDeclaration.parent.parent.kind === 204 /* ForOfStatement */) {
+ return textSpanFromVariableDeclaration(variableDeclaration);
+ }
+ var declarations = variableDeclaration.parent.declarations;
+ if (declarations && declarations[0] !== variableDeclaration) {
// If we cant set breakpoint on this declaration, set it on previous one
- var indexOfCurrentDeclaration = ts.indexOf(declarations, variableDeclaration);
- return spanInVariableDeclaration(declarations[indexOfCurrentDeclaration - 1]);
+ // Because the variable declaration may be binding pattern and
+ // we would like to set breakpoint in last binding element if thats the case,
+ // use preceding token instead
+ return spanInNode(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent));
}
}
function canHaveSpanInParameterDeclaration(parameter) {
// Breakpoint is possible on parameter only if it has initializer, is a rest parameter, or has public or private modifier
return !!parameter.initializer || parameter.dotDotDotToken !== undefined ||
- !!(parameter.flags & 16 /* Public */) || !!(parameter.flags & 32 /* Private */);
+ !!(parameter.flags & 8 /* Public */) || !!(parameter.flags & 16 /* Private */);
}
function spanInParameterDeclaration(parameter) {
- if (canHaveSpanInParameterDeclaration(parameter)) {
+ if (ts.isBindingPattern(parameter.name)) {
+ // set breakpoint in binding pattern
+ return spanInBindingPattern(parameter.name);
+ }
+ else if (canHaveSpanInParameterDeclaration(parameter)) {
return textSpan(parameter);
}
else {
@@ -49415,8 +53274,8 @@ var ts;
}
}
function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) {
- return !!(functionDeclaration.flags & 1 /* Export */) ||
- (functionDeclaration.parent.kind === 214 /* ClassDeclaration */ && functionDeclaration.kind !== 144 /* Constructor */);
+ return !!(functionDeclaration.flags & 2 /* Export */) ||
+ (functionDeclaration.parent.kind === 217 /* ClassDeclaration */ && functionDeclaration.kind !== 145 /* Constructor */);
}
function spanInFunctionDeclaration(functionDeclaration) {
// No breakpoints in the function signature
@@ -49439,34 +53298,39 @@ var ts;
}
function spanInBlock(block) {
switch (block.parent.kind) {
- case 218 /* ModuleDeclaration */:
+ case 221 /* ModuleDeclaration */:
if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) {
return undefined;
}
// Set on parent if on same line otherwise on first statement
- case 198 /* WhileStatement */:
- case 196 /* IfStatement */:
- case 200 /* ForInStatement */:
- case 201 /* ForOfStatement */:
+ case 201 /* WhileStatement */:
+ case 199 /* IfStatement */:
+ case 203 /* ForInStatement */:
return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]);
// Set span on previous token if it starts on same line otherwise on the first statement of the block
- case 199 /* ForStatement */:
+ case 202 /* ForStatement */:
+ case 204 /* ForOfStatement */:
return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]);
}
// Default action is to set on first statement
return spanInNode(block.statements[0]);
}
+ function spanInInitializerOfForLike(forLikeStaement) {
+ if (forLikeStaement.initializer.kind === 215 /* VariableDeclarationList */) {
+ // declaration list, set breakpoint in first declaration
+ var variableDeclarationList = forLikeStaement.initializer;
+ if (variableDeclarationList.declarations.length > 0) {
+ return spanInNode(variableDeclarationList.declarations[0]);
+ }
+ }
+ else {
+ // Expression - set breakpoint in it
+ return spanInNode(forLikeStaement.initializer);
+ }
+ }
function spanInForStatement(forStatement) {
if (forStatement.initializer) {
- if (forStatement.initializer.kind === 212 /* VariableDeclarationList */) {
- var variableDeclarationList = forStatement.initializer;
- if (variableDeclarationList.declarations.length > 0) {
- return spanInNode(variableDeclarationList.declarations[0]);
- }
- }
- else {
- return spanInNode(forStatement.initializer);
- }
+ return spanInInitializerOfForLike(forStatement);
}
if (forStatement.condition) {
return textSpan(forStatement.condition);
@@ -49475,16 +53339,44 @@ var ts;
return textSpan(forStatement.incrementor);
}
}
+ function spanInBindingPattern(bindingPattern) {
+ // Set breakpoint in first binding element
+ var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 190 /* OmittedExpression */ ? element : undefined; });
+ if (firstBindingElement) {
+ return spanInNode(firstBindingElement);
+ }
+ // Empty binding pattern of binding element, set breakpoint on binding element
+ if (bindingPattern.parent.kind === 166 /* BindingElement */) {
+ return textSpan(bindingPattern.parent);
+ }
+ // Variable declaration is used as the span
+ return textSpanFromVariableDeclaration(bindingPattern.parent);
+ }
+ function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) {
+ ts.Debug.assert(node.kind !== 165 /* ArrayBindingPattern */ && node.kind !== 164 /* ObjectBindingPattern */);
+ var elements = node.kind === 167 /* ArrayLiteralExpression */ ?
+ node.elements :
+ node.properties;
+ var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 190 /* OmittedExpression */ ? element : undefined; });
+ if (firstBindingElement) {
+ return spanInNode(firstBindingElement);
+ }
+ // Could be ArrayLiteral from destructuring assignment or
+ // just nested element in another destructuring assignment
+ // set breakpoint on assignment when parent is destructuring assignment
+ // Otherwise set breakpoint for this element
+ return textSpan(node.parent.kind === 184 /* BinaryExpression */ ? node.parent : node);
+ }
// Tokens:
function spanInOpenBraceToken(node) {
switch (node.parent.kind) {
- case 217 /* EnumDeclaration */:
+ case 220 /* EnumDeclaration */:
var enumDeclaration = node.parent;
return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile));
- case 214 /* ClassDeclaration */:
+ case 217 /* ClassDeclaration */:
var classDeclaration = node.parent;
return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile));
- case 220 /* CaseBlock */:
+ case 223 /* CaseBlock */:
return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]);
}
// Default to parent node
@@ -49492,25 +53384,24 @@ var ts;
}
function spanInCloseBraceToken(node) {
switch (node.parent.kind) {
- case 219 /* ModuleBlock */:
+ case 222 /* ModuleBlock */:
// If this is not instantiated module block no bp span
if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) {
return undefined;
}
- case 217 /* EnumDeclaration */:
- case 214 /* ClassDeclaration */:
+ case 220 /* EnumDeclaration */:
+ case 217 /* ClassDeclaration */:
// Span on close brace token
return textSpan(node);
- case 192 /* Block */:
+ case 195 /* Block */:
if (ts.isFunctionBlock(node.parent)) {
// Span on close brace token
return textSpan(node);
}
// fall through.
- case 244 /* CatchClause */:
+ case 247 /* CatchClause */:
return spanInNode(ts.lastOrUndefined(node.parent.statements));
- ;
- case 220 /* CaseBlock */:
+ case 223 /* CaseBlock */:
// breakpoint in last statement of the last clause
var caseBlock = node.parent;
var lastClause = ts.lastOrUndefined(caseBlock.clauses);
@@ -49518,58 +53409,99 @@ var ts;
return spanInNode(ts.lastOrUndefined(lastClause.statements));
}
return undefined;
+ case 164 /* ObjectBindingPattern */:
+ // Breakpoint in last binding element or binding pattern if it contains no elements
+ var bindingPattern = node.parent;
+ return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern);
// Default to parent node
default:
+ if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) {
+ // Breakpoint in last binding element or binding pattern if it contains no elements
+ var objectLiteral = node.parent;
+ return textSpan(ts.lastOrUndefined(objectLiteral.properties) || objectLiteral);
+ }
+ return spanInNode(node.parent);
+ }
+ }
+ function spanInCloseBracketToken(node) {
+ switch (node.parent.kind) {
+ case 165 /* ArrayBindingPattern */:
+ // Breakpoint in last binding element or binding pattern if it contains no elements
+ var bindingPattern = node.parent;
+ return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern);
+ default:
+ if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) {
+ // Breakpoint in last binding element or binding pattern if it contains no elements
+ var arrayLiteral = node.parent;
+ return textSpan(ts.lastOrUndefined(arrayLiteral.elements) || arrayLiteral);
+ }
+ // Default to parent node
return spanInNode(node.parent);
}
}
function spanInOpenParenToken(node) {
- if (node.parent.kind === 197 /* DoStatement */) {
- // Go to while keyword and do action instead
+ if (node.parent.kind === 200 /* DoStatement */ ||
+ node.parent.kind === 171 /* CallExpression */ ||
+ node.parent.kind === 172 /* NewExpression */) {
return spanInPreviousNode(node);
}
+ if (node.parent.kind === 175 /* ParenthesizedExpression */) {
+ return spanInNextNode(node);
+ }
// Default to parent node
return spanInNode(node.parent);
}
function spanInCloseParenToken(node) {
// Is this close paren token of parameter list, set span in previous token
switch (node.parent.kind) {
- case 173 /* FunctionExpression */:
- case 213 /* FunctionDeclaration */:
- case 174 /* ArrowFunction */:
- case 143 /* MethodDeclaration */:
- case 142 /* MethodSignature */:
- case 145 /* GetAccessor */:
- case 146 /* SetAccessor */:
- case 144 /* Constructor */:
- case 198 /* WhileStatement */:
- case 197 /* DoStatement */:
- case 199 /* ForStatement */:
+ case 176 /* FunctionExpression */:
+ case 216 /* FunctionDeclaration */:
+ case 177 /* ArrowFunction */:
+ case 144 /* MethodDeclaration */:
+ case 143 /* MethodSignature */:
+ case 146 /* GetAccessor */:
+ case 147 /* SetAccessor */:
+ case 145 /* Constructor */:
+ case 201 /* WhileStatement */:
+ case 200 /* DoStatement */:
+ case 202 /* ForStatement */:
+ case 204 /* ForOfStatement */:
+ case 171 /* CallExpression */:
+ case 172 /* NewExpression */:
+ case 175 /* ParenthesizedExpression */:
return spanInPreviousNode(node);
// Default to parent node
default:
return spanInNode(node.parent);
}
- // Default to parent node
- return spanInNode(node.parent);
}
function spanInColonToken(node) {
// Is this : specifying return annotation of the function declaration
- if (ts.isFunctionLike(node.parent) || node.parent.kind === 245 /* PropertyAssignment */) {
+ if (ts.isFunctionLike(node.parent) ||
+ node.parent.kind === 248 /* PropertyAssignment */ ||
+ node.parent.kind === 139 /* Parameter */) {
return spanInPreviousNode(node);
}
return spanInNode(node.parent);
}
function spanInGreaterThanOrLessThanToken(node) {
- if (node.parent.kind === 171 /* TypeAssertionExpression */) {
- return spanInNode(node.parent.expression);
+ if (node.parent.kind === 174 /* TypeAssertionExpression */) {
+ return spanInNextNode(node);
}
return spanInNode(node.parent);
}
function spanInWhileKeyword(node) {
- if (node.parent.kind === 197 /* DoStatement */) {
+ if (node.parent.kind === 200 /* DoStatement */) {
// Set span on while expression
- return textSpan(node, ts.findNextToken(node.parent.expression, node.parent));
+ return textSpanEndingAtNextToken(node, node.parent.expression);
+ }
+ // Default to parent node
+ return spanInNode(node.parent);
+ }
+ function spanInOfKeyword(node) {
+ if (node.parent.kind === 204 /* ForOfStatement */) {
+ // set using next token
+ return spanInNextNode(node);
}
// Default to parent node
return spanInNode(node.parent);
@@ -49596,6 +53528,9 @@ var ts;
///
/* @internal */
var debugObjectHost = this;
+// We need to use 'null' to interface with the managed side.
+/* tslint:disable:no-null */
+/* tslint:disable:no-in-operator */
/* @internal */
var ts;
(function (ts) {
@@ -49607,7 +53542,6 @@ var ts;
var ScriptSnapshotShimAdapter = (function () {
function ScriptSnapshotShimAdapter(scriptSnapshotShim) {
this.scriptSnapshotShim = scriptSnapshotShim;
- this.lineStartPositions = null;
}
ScriptSnapshotShimAdapter.prototype.getText = function (start, end) {
return this.scriptSnapshotShim.getText(start, end);
@@ -49633,7 +53567,7 @@ var ts;
}
};
return ScriptSnapshotShimAdapter;
- })();
+ }());
var LanguageServiceShimHostAdapter = (function () {
function LanguageServiceShimHostAdapter(shimHost) {
var _this = this;
@@ -49651,6 +53585,9 @@ var ts;
});
};
}
+ if ("directoryExists" in this.shimHost) {
+ this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); };
+ }
}
LanguageServiceShimHostAdapter.prototype.log = function (s) {
if (this.loggingEnabled) {
@@ -49680,7 +53617,6 @@ var ts;
// TODO: should this be '==='?
if (settingsJson == null || settingsJson == "") {
throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings");
- return null;
}
return JSON.parse(settingsJson);
};
@@ -49689,11 +53625,6 @@ var ts;
return this.files = JSON.parse(encoded);
};
LanguageServiceShimHostAdapter.prototype.getScriptSnapshot = function (fileName) {
- // Shim the API changes for 1.5 release. This should be removed once
- // TypeScript 1.5 has shipped.
- if (this.files && this.files.indexOf(fileName) < 0) {
- return undefined;
- }
var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName);
return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot);
};
@@ -49721,17 +53652,10 @@ var ts;
return this.shimHost.getCurrentDirectory();
};
LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) {
- // Wrap the API changes for 1.5 release. This try/catch
- // should be removed once TypeScript 1.5 has shipped.
- try {
- return this.shimHost.getDefaultLibFileName(JSON.stringify(options));
- }
- catch (e) {
- return "";
- }
+ return this.shimHost.getDefaultLibFileName(JSON.stringify(options));
};
return LanguageServiceShimHostAdapter;
- })();
+ }());
ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter;
/** A cancellation that throttles calls to the host */
var ThrottledCancellationToken = (function () {
@@ -49753,23 +53677,17 @@ var ts;
return false;
};
return ThrottledCancellationToken;
- })();
+ }());
var CoreServicesShimHostAdapter = (function () {
function CoreServicesShimHostAdapter(shimHost) {
+ var _this = this;
this.shimHost = shimHost;
+ if ("directoryExists" in this.shimHost) {
+ this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); };
+ }
}
CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension, exclude) {
- // Wrap the API changes for 1.5 release. This try/catch
- // should be removed once TypeScript 1.5 has shipped.
- // Also consider removing the optional designation for
- // the exclude param at this time.
- var encoded;
- try {
- encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude));
- }
- catch (e) {
- encoded = this.shimHost.readDirectory(rootDir, extension);
- }
+ var encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude));
return JSON.parse(encoded);
};
CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) {
@@ -49779,18 +53697,19 @@ var ts;
return this.shimHost.readFile(fileName);
};
return CoreServicesShimHostAdapter;
- })();
+ }());
ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter;
function simpleForwardCall(logger, actionDescription, action, logPerformance) {
+ var start;
if (logPerformance) {
logger.log(actionDescription);
- var start = Date.now();
+ start = Date.now();
}
var result = action();
if (logPerformance) {
var end = Date.now();
logger.log(actionDescription + " completed in " + (end - start) + " msec");
- if (typeof (result) === "string") {
+ if (typeof result === "string") {
var str = result;
if (str.length > 128) {
str = str.substring(0, 128) + "...";
@@ -49823,7 +53742,7 @@ var ts;
this.factory.unregisterShim(this);
};
return ShimBase;
- })();
+ }());
function realizeDiagnostics(diagnostics, newLine) {
return diagnostics.map(function (d) { return realizeDiagnostic(d, newLine); });
}
@@ -49872,9 +53791,7 @@ var ts;
* Update the list of scripts known to the compiler
*/
LanguageServiceShimObject.prototype.refresh = function (throwOnError) {
- this.forwardJSONCall("refresh(" + throwOnError + ")", function () {
- return null;
- });
+ this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; });
};
LanguageServiceShimObject.prototype.cleanupSemanticCache = function () {
var _this = this;
@@ -49889,33 +53806,25 @@ var ts;
};
LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) {
var _this = this;
- return this.forwardJSONCall("getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () {
- var classifications = _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length));
- return classifications;
- });
+ return this.forwardJSONCall("getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); });
};
LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) {
var _this = this;
- return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () {
- var classifications = _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length));
- return classifications;
- });
+ return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); });
};
LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) {
var _this = this;
- return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () {
- // directly serialize the spans out to a string. This is much faster to decode
- // on the managed side versus a full JSON array.
- return convertClassifications(_this.languageService.getEncodedSyntacticClassifications(fileName, ts.createTextSpan(start, length)));
- });
+ return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")",
+ // directly serialize the spans out to a string. This is much faster to decode
+ // on the managed side versus a full JSON array.
+ function () { return convertClassifications(_this.languageService.getEncodedSyntacticClassifications(fileName, ts.createTextSpan(start, length))); });
};
LanguageServiceShimObject.prototype.getEncodedSemanticClassifications = function (fileName, start, length) {
var _this = this;
- return this.forwardJSONCall("getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () {
- // directly serialize the spans out to a string. This is much faster to decode
- // on the managed side versus a full JSON array.
- return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length)));
- });
+ return this.forwardJSONCall("getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")",
+ // directly serialize the spans out to a string. This is much faster to decode
+ // on the managed side versus a full JSON array.
+ function () { return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); });
};
LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) {
var _this = this;
@@ -49945,10 +53854,7 @@ var ts;
*/
LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) {
var _this = this;
- return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () {
- var quickInfo = _this.languageService.getQuickInfoAtPosition(fileName, position);
- return quickInfo;
- });
+ return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); });
};
/// NAMEORDOTTEDNAMESPAN
/**
@@ -49957,10 +53863,7 @@ var ts;
*/
LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) {
var _this = this;
- return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () {
- var spanInfo = _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos);
- return spanInfo;
- });
+ return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); });
};
/**
* STATEMENTSPAN
@@ -49968,18 +53871,12 @@ var ts;
*/
LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) {
var _this = this;
- return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () {
- var spanInfo = _this.languageService.getBreakpointStatementAtPosition(fileName, position);
- return spanInfo;
- });
+ return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); });
};
/// SIGNATUREHELP
LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) {
var _this = this;
- return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () {
- var signatureInfo = _this.languageService.getSignatureHelpItems(fileName, position);
- return signatureInfo;
- });
+ return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position); });
};
/// GOTO DEFINITION
/**
@@ -49988,9 +53885,7 @@ var ts;
*/
LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) {
var _this = this;
- return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () {
- return _this.languageService.getDefinitionAtPosition(fileName, position);
- });
+ return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAtPosition(fileName, position); });
};
/// GOTO Type
/**
@@ -49999,29 +53894,20 @@ var ts;
*/
LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) {
var _this = this;
- return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () {
- return _this.languageService.getTypeDefinitionAtPosition(fileName, position);
- });
+ return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); });
};
LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position) {
var _this = this;
- return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () {
- return _this.languageService.getRenameInfo(fileName, position);
- });
+ return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position); });
};
LanguageServiceShimObject.prototype.findRenameLocations = function (fileName, position, findInStrings, findInComments) {
var _this = this;
- return this.forwardJSONCall("findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ")", function () {
- return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments);
- });
+ return this.forwardJSONCall("findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ")", function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments); });
};
/// GET BRACE MATCHING
LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) {
var _this = this;
- return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () {
- var textRanges = _this.languageService.getBraceMatchingAtPosition(fileName, position);
- return textRanges;
- });
+ return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); });
};
/// GET SMART INDENT
LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options /*Services.EditorOptions*/) {
@@ -50034,21 +53920,15 @@ var ts;
/// GET REFERENCES
LanguageServiceShimObject.prototype.getReferencesAtPosition = function (fileName, position) {
var _this = this;
- return this.forwardJSONCall("getReferencesAtPosition('" + fileName + "', " + position + ")", function () {
- return _this.languageService.getReferencesAtPosition(fileName, position);
- });
+ return this.forwardJSONCall("getReferencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getReferencesAtPosition(fileName, position); });
};
LanguageServiceShimObject.prototype.findReferences = function (fileName, position) {
var _this = this;
- return this.forwardJSONCall("findReferences('" + fileName + "', " + position + ")", function () {
- return _this.languageService.findReferences(fileName, position);
- });
+ return this.forwardJSONCall("findReferences('" + fileName + "', " + position + ")", function () { return _this.languageService.findReferences(fileName, position); });
};
LanguageServiceShimObject.prototype.getOccurrencesAtPosition = function (fileName, position) {
var _this = this;
- return this.forwardJSONCall("getOccurrencesAtPosition('" + fileName + "', " + position + ")", function () {
- return _this.languageService.getOccurrencesAtPosition(fileName, position);
- });
+ return this.forwardJSONCall("getOccurrencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); });
};
LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) {
var _this = this;
@@ -50067,41 +53947,32 @@ var ts;
*/
LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position) {
var _this = this;
- return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ")", function () {
- var completion = _this.languageService.getCompletionsAtPosition(fileName, position);
- return completion;
- });
+ return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position); });
};
/** Get a string based representation of a completion list entry details */
LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName) {
var _this = this;
- return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", " + entryName + ")", function () {
- var details = _this.languageService.getCompletionEntryDetails(fileName, position, entryName);
- return details;
- });
+ return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { return _this.languageService.getCompletionEntryDetails(fileName, position, entryName); });
};
LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options /*Services.FormatCodeOptions*/) {
var _this = this;
return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () {
var localOptions = JSON.parse(options);
- var edits = _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions);
- return edits;
+ return _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions);
});
};
LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options /*Services.FormatCodeOptions*/) {
var _this = this;
return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () {
var localOptions = JSON.parse(options);
- var edits = _this.languageService.getFormattingEditsForDocument(fileName, localOptions);
- return edits;
+ return _this.languageService.getFormattingEditsForDocument(fileName, localOptions);
});
};
LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options /*Services.FormatCodeOptions*/) {
var _this = this;
return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () {
var localOptions = JSON.parse(options);
- var edits = _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions);
- return edits;
+ return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions);
});
};
LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) {
@@ -50112,45 +53983,27 @@ var ts;
/** Return a list of symbols that are interesting to navigate to */
LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount) {
var _this = this;
- return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ")", function () {
- var items = _this.languageService.getNavigateToItems(searchValue, maxResultCount);
- return items;
- });
+ return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ")", function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount); });
};
LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) {
var _this = this;
- return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () {
- var items = _this.languageService.getNavigationBarItems(fileName);
- return items;
- });
+ return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); });
};
LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) {
var _this = this;
- return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () {
- var items = _this.languageService.getOutliningSpans(fileName);
- return items;
- });
+ return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); });
};
LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) {
var _this = this;
- return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () {
- var items = _this.languageService.getTodoComments(fileName, JSON.parse(descriptors));
- return items;
- });
+ return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); });
};
/// Emit
LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) {
var _this = this;
- return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () {
- var output = _this.languageService.getEmitOutput(fileName);
- // Shim the API changes for 1.5 release. This should be removed once
- // TypeScript 1.5 has shipped.
- output.emitOutputStatus = output.emitSkipped ? 1 : 0;
- return output;
- });
+ return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { return _this.languageService.getEmitOutput(fileName); });
};
return LanguageServiceShimObject;
- })(ShimBase);
+ }(ShimBase));
function convertClassifications(classifications) {
return { spans: classifications.spans.join(","), endOfLineState: classifications.endOfLineState };
}
@@ -50169,17 +54022,17 @@ var ts;
/// COLORIZATION
ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) {
var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics);
- var items = classification.entries;
var result = "";
- for (var i = 0; i < items.length; i++) {
- result += items[i].length + "\n";
- result += items[i].classification + "\n";
+ for (var _i = 0, _a = classification.entries; _i < _a.length; _i++) {
+ var item = _a[_i];
+ result += item.length + "\n";
+ result += item.classification + "\n";
}
result += classification.finalLexState;
return result;
};
return ClassifierShimObject;
- })(ShimBase);
+ }(ShimBase));
var CoreServicesShimObject = (function (_super) {
__extends(CoreServicesShimObject, _super);
function CoreServicesShimObject(factory, logger, host) {
@@ -50204,7 +54057,8 @@ var ts;
};
CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) {
return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () {
- var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()));
+ // for now treat files as JavaScript
+ var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), /* readImportFiles */ true, /* detectJavaScriptImports */ true);
var convertResult = {
referencedFiles: [],
importedFiles: [],
@@ -50237,24 +54091,23 @@ var ts;
return {
options: {},
files: [],
- errors: [realizeDiagnostic(result.error, '\r\n')]
+ errors: [realizeDiagnostic(result.error, "\r\n")]
};
}
- var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(ts.normalizeSlashes(fileName)));
+ var normalizedFileName = ts.normalizeSlashes(fileName);
+ var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(normalizedFileName), /*existingOptions*/ {}, normalizedFileName);
return {
options: configFile.options,
files: configFile.fileNames,
- errors: realizeDiagnostics(configFile.errors, '\r\n')
+ errors: realizeDiagnostics(configFile.errors, "\r\n")
};
});
};
CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () {
- return this.forwardJSONCall("getDefaultCompilationSettings()", function () {
- return ts.getDefaultCompilerOptions();
- });
+ return this.forwardJSONCall("getDefaultCompilationSettings()", function () { return ts.getDefaultCompilerOptions(); });
};
return CoreServicesShimObject;
- })(ShimBase);
+ }(ShimBase));
var TypeScriptServicesFactory = (function () {
function TypeScriptServicesFactory() {
this._shims = [];
@@ -50268,7 +54121,7 @@ var ts;
TypeScriptServicesFactory.prototype.createLanguageServiceShim = function (host) {
try {
if (this.documentRegistry === undefined) {
- this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames());
+ this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory());
}
var hostAdapter = new LanguageServiceShimHostAdapter(host);
var languageService = ts.createLanguageService(hostAdapter, this.documentRegistry);
@@ -50301,7 +54154,7 @@ var ts;
TypeScriptServicesFactory.prototype.close = function () {
// Forget all the registered shims
this._shims = [];
- this.documentRegistry = ts.createDocumentRegistry();
+ this.documentRegistry = undefined;
};
TypeScriptServicesFactory.prototype.registerShim = function (shim) {
this._shims.push(shim);
@@ -50316,12 +54169,14 @@ var ts;
throw new Error("Invalid operation");
};
return TypeScriptServicesFactory;
- })();
+ }());
ts.TypeScriptServicesFactory = TypeScriptServicesFactory;
if (typeof module !== "undefined" && module.exports) {
module.exports = ts;
}
})(ts || (ts = {}));
+/* tslint:enable:no-in-operator */
+/* tslint:enable:no-null */
/// TODO: this is used by VS, clean this up on both sides of the interface
/* @internal */
var TypeScript;
@@ -50331,5 +54186,9 @@ var TypeScript;
Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory;
})(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
+/* tslint:disable:no-unused-variable */
+// 'toolsVersion' gets consumed by the managed side, so it's not unused.
+// TODO: it should be moved into a namespace though.
/* @internal */
-var toolsVersion = "1.7";
+var toolsVersion = "1.8";
+/* tslint:enable:no-unused-variable */
diff --git a/testapp/package.json b/testapp/package.json
index 1af59463d..470669b75 100644
--- a/testapp/package.json
+++ b/testapp/package.json
@@ -10,13 +10,13 @@
"postinstall": "typings install"
},
"dependencies": {
- "angular2": "2.0.0-beta.8",
+ "angular2": "2.0.0-beta.14",
"systemjs": "0.19.22",
"es6-promise": "^3.0.2",
- "es6-shim": "^0.33.3",
+ "es6-shim": "^0.35.0",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2",
- "zone.js": "0.5.15"
+ "zone.js": "0.6.10"
},
"devDependencies": {
"concurrently": "^2.0.0",