2017-05-28 00:38:50 +02:00
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
var ts = require("typescript");
|
|
|
|
var node_1 = require("../typeguard/node");
|
|
|
|
function getChildOfKind(node, kind, sourceFile) {
|
|
|
|
for (var _i = 0, _a = node.getChildren(sourceFile); _i < _a.length; _i++) {
|
|
|
|
var child = _a[_i];
|
|
|
|
if (child.kind === kind)
|
|
|
|
return child;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.getChildOfKind = getChildOfKind;
|
|
|
|
function isTokenKind(kind) {
|
|
|
|
return kind >= ts.SyntaxKind.FirstToken && kind <= ts.SyntaxKind.LastToken;
|
|
|
|
}
|
|
|
|
exports.isTokenKind = isTokenKind;
|
|
|
|
function isNodeKind(kind) {
|
|
|
|
return kind >= ts.SyntaxKind.FirstNode;
|
|
|
|
}
|
|
|
|
exports.isNodeKind = isNodeKind;
|
|
|
|
function isAssignmentKind(kind) {
|
|
|
|
return kind >= ts.SyntaxKind.FirstAssignment && kind <= ts.SyntaxKind.LastAssignment;
|
|
|
|
}
|
|
|
|
exports.isAssignmentKind = isAssignmentKind;
|
|
|
|
function isTypeNodeKind(kind) {
|
|
|
|
return kind >= ts.SyntaxKind.FirstTypeNode && kind <= ts.SyntaxKind.LastTypeNode;
|
|
|
|
}
|
|
|
|
exports.isTypeNodeKind = isTypeNodeKind;
|
|
|
|
function isJsDocKind(kind) {
|
|
|
|
return kind >= ts.SyntaxKind.FirstJSDocNode && kind <= ts.SyntaxKind.LastJSDocNode;
|
|
|
|
}
|
|
|
|
exports.isJsDocKind = isJsDocKind;
|
|
|
|
function isThisParameter(parameter) {
|
|
|
|
return parameter.name.kind === ts.SyntaxKind.Identifier && parameter.name.originalKeywordKind === ts.SyntaxKind.ThisKeyword;
|
|
|
|
}
|
|
|
|
exports.isThisParameter = isThisParameter;
|
2017-08-14 05:01:11 +02:00
|
|
|
function getModifier(node, kind) {
|
|
|
|
if (node.modifiers !== undefined)
|
|
|
|
for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
|
|
|
|
var modifier = _a[_i];
|
|
|
|
if (modifier.kind === kind)
|
|
|
|
return modifier;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.getModifier = getModifier;
|
2017-05-28 00:38:50 +02:00
|
|
|
function hasModifier(modifiers) {
|
|
|
|
var kinds = [];
|
|
|
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
|
|
kinds[_i - 1] = arguments[_i];
|
|
|
|
}
|
|
|
|
if (modifiers === undefined)
|
|
|
|
return false;
|
|
|
|
for (var _a = 0, modifiers_1 = modifiers; _a < modifiers_1.length; _a++) {
|
|
|
|
var modifier = modifiers_1[_a];
|
|
|
|
if (kinds.indexOf(modifier.kind) !== -1)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
exports.hasModifier = hasModifier;
|
|
|
|
function isParameterProperty(node) {
|
|
|
|
return hasModifier(node.modifiers, ts.SyntaxKind.PublicKeyword, ts.SyntaxKind.ProtectedKeyword, ts.SyntaxKind.PrivateKeyword, ts.SyntaxKind.ReadonlyKeyword);
|
|
|
|
}
|
|
|
|
exports.isParameterProperty = isParameterProperty;
|
|
|
|
function hasAccessModifier(node) {
|
|
|
|
return hasModifier(node.modifiers, ts.SyntaxKind.PublicKeyword, ts.SyntaxKind.ProtectedKeyword, ts.SyntaxKind.PrivateKeyword);
|
|
|
|
}
|
|
|
|
exports.hasAccessModifier = hasAccessModifier;
|
|
|
|
function isFlagSet(obj, flag) {
|
|
|
|
return (obj.flags & flag) !== 0;
|
|
|
|
}
|
|
|
|
exports.isNodeFlagSet = isFlagSet;
|
|
|
|
exports.isTypeFlagSet = isFlagSet;
|
|
|
|
exports.isSymbolFlagSet = isFlagSet;
|
|
|
|
function isObjectFlagSet(objectType, flag) {
|
|
|
|
return (objectType.objectFlags & flag) !== 0;
|
|
|
|
}
|
|
|
|
exports.isObjectFlagSet = isObjectFlagSet;
|
2017-08-14 05:01:11 +02:00
|
|
|
function isModifierFlagSet(node, flag) {
|
2017-05-28 00:38:50 +02:00
|
|
|
return (ts.getCombinedModifierFlags(node) & flag) !== 0;
|
|
|
|
}
|
2017-08-14 05:01:11 +02:00
|
|
|
exports.isModifierFlagSet = isModifierFlagSet;
|
|
|
|
function isModfierFlagSet(node, flag) {
|
|
|
|
return isModifierFlagSet(node, flag);
|
|
|
|
}
|
2017-05-28 00:38:50 +02:00
|
|
|
exports.isModfierFlagSet = isModfierFlagSet;
|
|
|
|
function getPreviousStatement(statement) {
|
|
|
|
var parent = statement.parent;
|
|
|
|
if (node_1.isBlockLike(parent)) {
|
|
|
|
var index = parent.statements.indexOf(statement);
|
|
|
|
if (index > 0)
|
|
|
|
return parent.statements[index - 1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.getPreviousStatement = getPreviousStatement;
|
|
|
|
function getNextStatement(statement) {
|
|
|
|
var parent = statement.parent;
|
|
|
|
if (node_1.isBlockLike(parent)) {
|
|
|
|
var index = parent.statements.indexOf(statement);
|
|
|
|
if (index < parent.statements.length)
|
|
|
|
return parent.statements[index + 1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.getNextStatement = getNextStatement;
|
|
|
|
function getPreviousToken(node, sourceFile) {
|
|
|
|
var parent = node.parent;
|
|
|
|
while (parent !== undefined && parent.pos === node.pos)
|
|
|
|
parent = parent.parent;
|
|
|
|
if (parent === undefined)
|
|
|
|
return;
|
|
|
|
outer: while (true) {
|
|
|
|
var children = parent.getChildren(sourceFile);
|
|
|
|
for (var i = children.length - 1; i >= 0; --i) {
|
|
|
|
var child = children[i];
|
|
|
|
if (child.pos < node.pos && child.kind !== ts.SyntaxKind.JSDocComment) {
|
|
|
|
if (isTokenKind(child.kind))
|
|
|
|
return child;
|
|
|
|
parent = child;
|
|
|
|
continue outer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.getPreviousToken = getPreviousToken;
|
|
|
|
function getNextToken(node, sourceFile) {
|
|
|
|
if (sourceFile === void 0) { sourceFile = node.getSourceFile(); }
|
|
|
|
if (node.kind === ts.SyntaxKind.SourceFile || node.kind === ts.SyntaxKind.EndOfFileToken)
|
|
|
|
return;
|
|
|
|
var end = node.end;
|
|
|
|
node = node.parent;
|
|
|
|
while (node.end === end) {
|
|
|
|
if (node.parent === undefined)
|
|
|
|
return node.endOfFileToken;
|
|
|
|
node = node.parent;
|
|
|
|
}
|
2017-08-14 05:01:11 +02:00
|
|
|
return getTokenAtPositionWorker(node, end, sourceFile);
|
2017-05-28 00:38:50 +02:00
|
|
|
}
|
|
|
|
exports.getNextToken = getNextToken;
|
|
|
|
function getTokenAtPosition(parent, pos, sourceFile) {
|
2017-08-14 05:01:11 +02:00
|
|
|
if (pos < parent.pos || pos >= parent.end)
|
2017-05-28 00:38:50 +02:00
|
|
|
return;
|
|
|
|
if (isTokenKind(parent.kind))
|
|
|
|
return parent;
|
|
|
|
if (sourceFile === undefined)
|
|
|
|
sourceFile = parent.getSourceFile();
|
|
|
|
return getTokenAtPositionWorker(parent, pos, sourceFile);
|
|
|
|
}
|
|
|
|
exports.getTokenAtPosition = getTokenAtPosition;
|
|
|
|
function getTokenAtPositionWorker(node, pos, sourceFile) {
|
|
|
|
outer: while (true) {
|
|
|
|
for (var _i = 0, _a = node.getChildren(sourceFile); _i < _a.length; _i++) {
|
|
|
|
var child = _a[_i];
|
2017-08-14 05:01:11 +02:00
|
|
|
if (child.end > pos && child.kind !== ts.SyntaxKind.JSDocComment) {
|
2017-05-28 00:38:50 +02:00
|
|
|
if (isTokenKind(child.kind))
|
|
|
|
return child;
|
|
|
|
node = child;
|
|
|
|
continue outer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2017-08-14 05:01:11 +02:00
|
|
|
function getCommentAtPosition(sourceFile, pos, parent) {
|
2017-05-28 00:38:50 +02:00
|
|
|
if (parent === void 0) { parent = sourceFile; }
|
|
|
|
var token = getTokenAtPosition(parent, pos, sourceFile);
|
2017-08-14 05:01:11 +02:00
|
|
|
if (token === undefined || token.kind === ts.SyntaxKind.JsxText || pos >= token.end - (ts.tokenToString(token.kind) || '').length)
|
|
|
|
return;
|
|
|
|
var cb = function (start, end, kind) {
|
|
|
|
return pos >= start && pos < end ? { end: end, kind: kind, pos: start } : undefined;
|
|
|
|
};
|
2017-05-28 00:38:50 +02:00
|
|
|
return token.pos !== 0 && ts.forEachTrailingCommentRange(sourceFile.text, token.pos, cb) ||
|
2017-08-14 05:01:11 +02:00
|
|
|
ts.forEachLeadingCommentRange(sourceFile.text, token.pos, cb);
|
|
|
|
}
|
|
|
|
exports.getCommentAtPosition = getCommentAtPosition;
|
|
|
|
function isPositionInComment(sourceFile, pos, parent) {
|
|
|
|
return getCommentAtPosition(sourceFile, pos, parent) !== undefined;
|
2017-05-28 00:38:50 +02:00
|
|
|
}
|
|
|
|
exports.isPositionInComment = isPositionInComment;
|
|
|
|
function getPropertyName(propertyName) {
|
|
|
|
if (propertyName.kind === ts.SyntaxKind.ComputedPropertyName) {
|
|
|
|
if (!node_1.isLiteralExpression(propertyName.expression))
|
|
|
|
return;
|
|
|
|
return propertyName.expression.text;
|
|
|
|
}
|
2017-10-14 18:40:54 +02:00
|
|
|
return propertyName.kind === ts.SyntaxKind.Identifier ? getIdentifierText(propertyName) : propertyName.text;
|
2017-05-28 00:38:50 +02:00
|
|
|
}
|
|
|
|
exports.getPropertyName = getPropertyName;
|
|
|
|
function forEachDestructuringIdentifier(pattern, fn) {
|
|
|
|
for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
|
|
|
|
var element = _a[_i];
|
|
|
|
if (element.kind !== ts.SyntaxKind.BindingElement)
|
|
|
|
continue;
|
|
|
|
var result = void 0;
|
|
|
|
if (element.name.kind === ts.SyntaxKind.Identifier) {
|
|
|
|
result = fn(element);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
result = forEachDestructuringIdentifier(element.name, fn);
|
|
|
|
}
|
|
|
|
if (result)
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.forEachDestructuringIdentifier = forEachDestructuringIdentifier;
|
|
|
|
function forEachDeclaredVariable(declarationList, cb) {
|
|
|
|
for (var _i = 0, _a = declarationList.declarations; _i < _a.length; _i++) {
|
|
|
|
var declaration = _a[_i];
|
|
|
|
var result = void 0;
|
|
|
|
if (declaration.name.kind === ts.SyntaxKind.Identifier) {
|
|
|
|
result = cb(declaration);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
result = forEachDestructuringIdentifier(declaration.name, cb);
|
|
|
|
}
|
|
|
|
if (result)
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.forEachDeclaredVariable = forEachDeclaredVariable;
|
|
|
|
var VariableDeclarationKind;
|
|
|
|
(function (VariableDeclarationKind) {
|
|
|
|
VariableDeclarationKind[VariableDeclarationKind["Var"] = 0] = "Var";
|
|
|
|
VariableDeclarationKind[VariableDeclarationKind["Let"] = 1] = "Let";
|
|
|
|
VariableDeclarationKind[VariableDeclarationKind["Const"] = 2] = "Const";
|
|
|
|
})(VariableDeclarationKind = exports.VariableDeclarationKind || (exports.VariableDeclarationKind = {}));
|
|
|
|
function getVariableDeclarationKind(declarationList) {
|
2017-08-14 05:01:11 +02:00
|
|
|
if (declarationList.flags & ts.NodeFlags.Let)
|
2017-05-28 00:38:50 +02:00
|
|
|
return 1;
|
2017-08-14 05:01:11 +02:00
|
|
|
if (declarationList.flags & ts.NodeFlags.Const)
|
2017-05-28 00:38:50 +02:00
|
|
|
return 2;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
exports.getVariableDeclarationKind = getVariableDeclarationKind;
|
|
|
|
function isBlockScopedVariableDeclarationList(declarationList) {
|
2017-08-14 05:01:11 +02:00
|
|
|
return (declarationList.flags & ts.NodeFlags.BlockScoped) !== 0;
|
2017-05-28 00:38:50 +02:00
|
|
|
}
|
|
|
|
exports.isBlockScopedVariableDeclarationList = isBlockScopedVariableDeclarationList;
|
|
|
|
function isBlockScopedVariableDeclaration(declaration) {
|
|
|
|
var parent = declaration.parent;
|
|
|
|
return parent.kind === ts.SyntaxKind.CatchClause ||
|
|
|
|
isBlockScopedVariableDeclarationList(parent);
|
|
|
|
}
|
|
|
|
exports.isBlockScopedVariableDeclaration = isBlockScopedVariableDeclaration;
|
|
|
|
var ScopeBoundary;
|
|
|
|
(function (ScopeBoundary) {
|
|
|
|
ScopeBoundary[ScopeBoundary["None"] = 0] = "None";
|
|
|
|
ScopeBoundary[ScopeBoundary["Function"] = 1] = "Function";
|
|
|
|
ScopeBoundary[ScopeBoundary["Block"] = 2] = "Block";
|
|
|
|
})(ScopeBoundary = exports.ScopeBoundary || (exports.ScopeBoundary = {}));
|
|
|
|
function isScopeBoundary(node) {
|
|
|
|
if (isFunctionScopeBoundary(node))
|
|
|
|
return 1;
|
|
|
|
if (isBlockScopeBoundary(node))
|
|
|
|
return 2;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
exports.isScopeBoundary = isScopeBoundary;
|
|
|
|
function isFunctionScopeBoundary(node) {
|
|
|
|
switch (node.kind) {
|
|
|
|
case ts.SyntaxKind.FunctionExpression:
|
|
|
|
case ts.SyntaxKind.ArrowFunction:
|
|
|
|
case ts.SyntaxKind.Constructor:
|
|
|
|
case ts.SyntaxKind.ModuleDeclaration:
|
|
|
|
case ts.SyntaxKind.ClassDeclaration:
|
|
|
|
case ts.SyntaxKind.ClassExpression:
|
|
|
|
case ts.SyntaxKind.EnumDeclaration:
|
|
|
|
case ts.SyntaxKind.MethodDeclaration:
|
|
|
|
case ts.SyntaxKind.FunctionDeclaration:
|
|
|
|
case ts.SyntaxKind.GetAccessor:
|
|
|
|
case ts.SyntaxKind.SetAccessor:
|
|
|
|
case ts.SyntaxKind.InterfaceDeclaration:
|
|
|
|
case ts.SyntaxKind.TypeAliasDeclaration:
|
|
|
|
case ts.SyntaxKind.MethodSignature:
|
|
|
|
case ts.SyntaxKind.CallSignature:
|
|
|
|
case ts.SyntaxKind.ConstructSignature:
|
|
|
|
case ts.SyntaxKind.ConstructorType:
|
|
|
|
case ts.SyntaxKind.FunctionType:
|
|
|
|
case ts.SyntaxKind.MappedType:
|
|
|
|
return true;
|
|
|
|
case ts.SyntaxKind.SourceFile:
|
|
|
|
return ts.isExternalModule(node);
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.isFunctionScopeBoundary = isFunctionScopeBoundary;
|
|
|
|
function isBlockScopeBoundary(node) {
|
|
|
|
switch (node.kind) {
|
|
|
|
case ts.SyntaxKind.Block:
|
|
|
|
var parent = node.parent;
|
|
|
|
return parent.kind !== ts.SyntaxKind.CatchClause &&
|
|
|
|
(parent.kind === ts.SyntaxKind.SourceFile ||
|
|
|
|
!isFunctionScopeBoundary(parent));
|
|
|
|
case ts.SyntaxKind.ForStatement:
|
|
|
|
case ts.SyntaxKind.ForInStatement:
|
|
|
|
case ts.SyntaxKind.ForOfStatement:
|
|
|
|
case ts.SyntaxKind.CaseBlock:
|
|
|
|
case ts.SyntaxKind.CatchClause:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.isBlockScopeBoundary = isBlockScopeBoundary;
|
|
|
|
function hasOwnThisReference(node) {
|
|
|
|
switch (node.kind) {
|
|
|
|
case ts.SyntaxKind.ClassDeclaration:
|
|
|
|
case ts.SyntaxKind.ClassExpression:
|
|
|
|
case ts.SyntaxKind.FunctionExpression:
|
|
|
|
return true;
|
|
|
|
case ts.SyntaxKind.FunctionDeclaration:
|
|
|
|
return node.body !== undefined;
|
|
|
|
case ts.SyntaxKind.MethodDeclaration:
|
|
|
|
case ts.SyntaxKind.GetAccessor:
|
|
|
|
case ts.SyntaxKind.SetAccessor:
|
|
|
|
return node.parent.kind === ts.SyntaxKind.ObjectLiteralExpression;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.hasOwnThisReference = hasOwnThisReference;
|
|
|
|
function isFunctionWithBody(node) {
|
|
|
|
switch (node.kind) {
|
|
|
|
case ts.SyntaxKind.GetAccessor:
|
|
|
|
case ts.SyntaxKind.SetAccessor:
|
|
|
|
case ts.SyntaxKind.FunctionDeclaration:
|
|
|
|
case ts.SyntaxKind.MethodDeclaration:
|
2017-08-14 05:01:11 +02:00
|
|
|
case ts.SyntaxKind.Constructor:
|
2017-05-28 00:38:50 +02:00
|
|
|
return node.body !== undefined;
|
|
|
|
case ts.SyntaxKind.FunctionExpression:
|
|
|
|
case ts.SyntaxKind.ArrowFunction:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.isFunctionWithBody = isFunctionWithBody;
|
|
|
|
function forEachToken(node, cb, sourceFile) {
|
|
|
|
if (sourceFile === void 0) { sourceFile = node.getSourceFile(); }
|
|
|
|
return (function iterate(child) {
|
|
|
|
if (isTokenKind(child.kind))
|
|
|
|
return cb(child);
|
|
|
|
if (child.kind !== ts.SyntaxKind.JSDocComment)
|
|
|
|
return child.getChildren(sourceFile).forEach(iterate);
|
|
|
|
})(node);
|
|
|
|
}
|
|
|
|
exports.forEachToken = forEachToken;
|
|
|
|
function forEachTokenWithTrivia(node, cb, sourceFile) {
|
|
|
|
if (sourceFile === void 0) { sourceFile = node.getSourceFile(); }
|
|
|
|
var fullText = sourceFile.text;
|
|
|
|
var notJsx = sourceFile.languageVariant !== ts.LanguageVariant.JSX;
|
|
|
|
var scanner = ts.createScanner(sourceFile.languageVersion, false, sourceFile.languageVariant, fullText);
|
|
|
|
return forEachToken(node, function (token) {
|
2017-10-14 18:40:54 +02:00
|
|
|
var tokenStart = token.kind === ts.SyntaxKind.JsxText ? token.pos : token.getStart(sourceFile);
|
2017-05-28 00:38:50 +02:00
|
|
|
var end = token.end;
|
|
|
|
if (tokenStart !== token.pos && (notJsx || canHaveLeadingTrivia(token))) {
|
|
|
|
scanner.setTextPos(token.pos);
|
2017-10-14 18:40:54 +02:00
|
|
|
var kind = scanner.scan();
|
|
|
|
var pos = scanner.getTokenPos();
|
|
|
|
while (pos < tokenStart) {
|
|
|
|
var textPos = scanner.getTextPos();
|
|
|
|
cb(fullText, kind, { pos: pos, end: textPos }, token.parent);
|
|
|
|
if (textPos === tokenStart)
|
|
|
|
break;
|
|
|
|
kind = scanner.scan();
|
|
|
|
pos = scanner.getTokenPos();
|
|
|
|
}
|
2017-05-28 00:38:50 +02:00
|
|
|
}
|
|
|
|
return cb(fullText, token.kind, { end: end, pos: tokenStart }, token.parent);
|
|
|
|
}, sourceFile);
|
|
|
|
}
|
|
|
|
exports.forEachTokenWithTrivia = forEachTokenWithTrivia;
|
|
|
|
function forEachComment(node, cb, sourceFile) {
|
|
|
|
if (sourceFile === void 0) { sourceFile = node.getSourceFile(); }
|
|
|
|
var fullText = sourceFile.text;
|
|
|
|
var notJsx = sourceFile.languageVariant !== ts.LanguageVariant.JSX;
|
|
|
|
return forEachToken(node, function (token) {
|
|
|
|
if (notJsx || canHaveLeadingTrivia(token))
|
|
|
|
ts.forEachLeadingCommentRange(fullText, token.pos, commentCallback);
|
|
|
|
if (notJsx || canHaveTrailingTrivia(token))
|
|
|
|
return ts.forEachTrailingCommentRange(fullText, token.end, commentCallback);
|
|
|
|
}, sourceFile);
|
|
|
|
function commentCallback(pos, end, kind) {
|
2017-08-14 05:01:11 +02:00
|
|
|
cb(fullText, { pos: pos, end: end, kind: kind });
|
2017-05-28 00:38:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.forEachComment = forEachComment;
|
|
|
|
function canHaveLeadingTrivia(_a) {
|
|
|
|
var kind = _a.kind, parent = _a.parent;
|
|
|
|
if (kind === ts.SyntaxKind.OpenBraceToken)
|
|
|
|
return parent.kind !== ts.SyntaxKind.JsxExpression || parent.parent.kind !== ts.SyntaxKind.JsxElement;
|
|
|
|
if (kind === ts.SyntaxKind.LessThanToken) {
|
|
|
|
if (parent.kind === ts.SyntaxKind.JsxClosingElement)
|
|
|
|
return false;
|
|
|
|
if (parent.kind === ts.SyntaxKind.JsxOpeningElement || parent.kind === ts.SyntaxKind.JsxSelfClosingElement)
|
|
|
|
return parent.parent.parent.kind !== ts.SyntaxKind.JsxElement;
|
|
|
|
}
|
|
|
|
return kind !== ts.SyntaxKind.JsxText;
|
|
|
|
}
|
|
|
|
function canHaveTrailingTrivia(_a) {
|
|
|
|
var kind = _a.kind, parent = _a.parent;
|
|
|
|
if (kind === ts.SyntaxKind.CloseBraceToken)
|
|
|
|
return parent.kind !== ts.SyntaxKind.JsxExpression || parent.parent.kind !== ts.SyntaxKind.JsxElement;
|
|
|
|
if (kind === ts.SyntaxKind.GreaterThanToken) {
|
|
|
|
if (parent.kind === ts.SyntaxKind.JsxOpeningElement)
|
|
|
|
return false;
|
|
|
|
if (parent.kind === ts.SyntaxKind.JsxClosingElement || parent.kind === ts.SyntaxKind.JsxSelfClosingElement)
|
|
|
|
return parent.parent.parent.kind !== ts.SyntaxKind.JsxElement;
|
|
|
|
}
|
|
|
|
return kind !== ts.SyntaxKind.JsxText;
|
|
|
|
}
|
|
|
|
function endsControlFlow(statement) {
|
|
|
|
return getControlFlowEnd(statement) !== 0;
|
|
|
|
}
|
|
|
|
exports.endsControlFlow = endsControlFlow;
|
|
|
|
var StatementType;
|
|
|
|
(function (StatementType) {
|
|
|
|
StatementType[StatementType["None"] = 0] = "None";
|
|
|
|
StatementType[StatementType["Break"] = 1] = "Break";
|
|
|
|
StatementType[StatementType["Other"] = 2] = "Other";
|
|
|
|
})(StatementType || (StatementType = {}));
|
|
|
|
function getControlFlowEnd(statement) {
|
|
|
|
while (node_1.isBlockLike(statement)) {
|
|
|
|
if (statement.statements.length === 0)
|
|
|
|
return 0;
|
|
|
|
statement = statement.statements[statement.statements.length - 1];
|
|
|
|
}
|
|
|
|
return hasReturnBreakContinueThrow(statement);
|
|
|
|
}
|
|
|
|
function hasReturnBreakContinueThrow(statement) {
|
|
|
|
switch (statement.kind) {
|
|
|
|
case ts.SyntaxKind.ReturnStatement:
|
|
|
|
case ts.SyntaxKind.ContinueStatement:
|
|
|
|
case ts.SyntaxKind.ThrowStatement:
|
|
|
|
return 2;
|
|
|
|
case ts.SyntaxKind.BreakStatement:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (node_1.isIfStatement(statement)) {
|
|
|
|
if (statement.elseStatement === undefined)
|
|
|
|
return 0;
|
|
|
|
var then = getControlFlowEnd(statement.thenStatement);
|
|
|
|
if (!then)
|
|
|
|
return then;
|
|
|
|
return Math.min(then, getControlFlowEnd(statement.elseStatement));
|
|
|
|
}
|
|
|
|
if (node_1.isSwitchStatement(statement)) {
|
|
|
|
var hasDefault = false;
|
|
|
|
var type = 0;
|
|
|
|
for (var _i = 0, _a = statement.caseBlock.clauses; _i < _a.length; _i++) {
|
|
|
|
var clause = _a[_i];
|
|
|
|
type = getControlFlowEnd(clause);
|
|
|
|
if (type === 1)
|
|
|
|
return 0;
|
|
|
|
if (clause.kind === ts.SyntaxKind.DefaultClause)
|
|
|
|
hasDefault = true;
|
|
|
|
}
|
|
|
|
return hasDefault && type !== 0 ? 2 : 0;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
function getLineRanges(sourceFile) {
|
|
|
|
var lineStarts = sourceFile.getLineStarts();
|
|
|
|
var result = [];
|
|
|
|
var length = lineStarts.length;
|
|
|
|
var sourceText = sourceFile.text;
|
|
|
|
var pos = 0;
|
|
|
|
for (var i = 1; i < length; ++i) {
|
|
|
|
var end = lineStarts[i];
|
2017-08-14 05:01:11 +02:00
|
|
|
var lineEnd = end;
|
|
|
|
for (; lineEnd > pos; --lineEnd)
|
|
|
|
if (!ts.isLineBreak(sourceText.charCodeAt(lineEnd - 1)))
|
|
|
|
break;
|
2017-05-28 00:38:50 +02:00
|
|
|
result.push({
|
|
|
|
pos: pos,
|
|
|
|
end: end,
|
2017-08-14 05:01:11 +02:00
|
|
|
contentLength: lineEnd - pos,
|
2017-05-28 00:38:50 +02:00
|
|
|
});
|
|
|
|
pos = end;
|
|
|
|
}
|
|
|
|
result.push({
|
|
|
|
pos: pos,
|
|
|
|
end: sourceFile.end,
|
|
|
|
contentLength: sourceFile.end - pos,
|
|
|
|
});
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
exports.getLineRanges = getLineRanges;
|
2017-08-14 05:01:11 +02:00
|
|
|
var cachedScanner;
|
2017-05-28 00:38:50 +02:00
|
|
|
function scanToken(text) {
|
2017-08-14 05:01:11 +02:00
|
|
|
if (cachedScanner === undefined)
|
|
|
|
cachedScanner = ts.createScanner(ts.ScriptTarget.Latest, false);
|
|
|
|
cachedScanner.setText(text);
|
|
|
|
cachedScanner.scan();
|
|
|
|
return cachedScanner;
|
2017-05-28 00:38:50 +02:00
|
|
|
}
|
|
|
|
function isValidIdentifier(text) {
|
|
|
|
var scan = scanToken(text);
|
|
|
|
return scan.isIdentifier() && scan.getTextPos() === text.length;
|
|
|
|
}
|
|
|
|
exports.isValidIdentifier = isValidIdentifier;
|
|
|
|
function isValidPropertyAccess(text) {
|
|
|
|
if (!ts.isIdentifierStart(text.charCodeAt(0), ts.ScriptTarget.Latest))
|
|
|
|
return false;
|
2017-08-14 05:01:11 +02:00
|
|
|
for (var i = 1; i < text.length; ++i)
|
2017-05-28 00:38:50 +02:00
|
|
|
if (!ts.isIdentifierPart(text.charCodeAt(i), ts.ScriptTarget.Latest))
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
exports.isValidPropertyAccess = isValidPropertyAccess;
|
|
|
|
function isValidPropertyName(text) {
|
2017-08-14 05:01:11 +02:00
|
|
|
if (isValidPropertyAccess(text))
|
2017-05-28 00:38:50 +02:00
|
|
|
return true;
|
|
|
|
var scan = scanToken(text);
|
|
|
|
return scan.getTextPos() === text.length &&
|
|
|
|
scan.getToken() === ts.SyntaxKind.NumericLiteral && scan.getTokenValue() === text;
|
|
|
|
}
|
|
|
|
exports.isValidPropertyName = isValidPropertyName;
|
|
|
|
function isValidNumericLiteral(text) {
|
|
|
|
var scan = scanToken(text);
|
|
|
|
return scan.getToken() === ts.SyntaxKind.NumericLiteral && scan.getTextPos() === text.length;
|
|
|
|
}
|
|
|
|
exports.isValidNumericLiteral = isValidNumericLiteral;
|
|
|
|
function isSameLine(sourceFile, pos1, pos2) {
|
2017-08-14 05:01:11 +02:00
|
|
|
return ts.getLineAndCharacterOfPosition(sourceFile, pos1).line === ts.getLineAndCharacterOfPosition(sourceFile, pos2).line;
|
2017-05-28 00:38:50 +02:00
|
|
|
}
|
|
|
|
exports.isSameLine = isSameLine;
|
|
|
|
var SideEffectOptions;
|
|
|
|
(function (SideEffectOptions) {
|
|
|
|
SideEffectOptions[SideEffectOptions["None"] = 0] = "None";
|
|
|
|
SideEffectOptions[SideEffectOptions["TaggedTemplate"] = 1] = "TaggedTemplate";
|
|
|
|
SideEffectOptions[SideEffectOptions["Constructor"] = 2] = "Constructor";
|
|
|
|
SideEffectOptions[SideEffectOptions["JsxElement"] = 4] = "JsxElement";
|
|
|
|
})(SideEffectOptions = exports.SideEffectOptions || (exports.SideEffectOptions = {}));
|
|
|
|
function hasSideEffects(node, options) {
|
|
|
|
switch (node.kind) {
|
|
|
|
case ts.SyntaxKind.CallExpression:
|
|
|
|
case ts.SyntaxKind.PostfixUnaryExpression:
|
|
|
|
case ts.SyntaxKind.AwaitExpression:
|
|
|
|
case ts.SyntaxKind.YieldExpression:
|
|
|
|
case ts.SyntaxKind.DeleteExpression:
|
|
|
|
return true;
|
|
|
|
case ts.SyntaxKind.TypeAssertionExpression:
|
|
|
|
case ts.SyntaxKind.AsExpression:
|
|
|
|
case ts.SyntaxKind.ParenthesizedExpression:
|
|
|
|
case ts.SyntaxKind.NonNullExpression:
|
|
|
|
case ts.SyntaxKind.VoidExpression:
|
|
|
|
case ts.SyntaxKind.TypeOfExpression:
|
|
|
|
case ts.SyntaxKind.PropertyAccessExpression:
|
|
|
|
case ts.SyntaxKind.SpreadElement:
|
|
|
|
case ts.SyntaxKind.PartiallyEmittedExpression:
|
|
|
|
return hasSideEffects(node.expression, options);
|
|
|
|
case ts.SyntaxKind.BinaryExpression:
|
|
|
|
return isAssignmentKind(node.operatorToken.kind) ||
|
|
|
|
hasSideEffects(node.left, options) ||
|
|
|
|
hasSideEffects(node.right, options);
|
|
|
|
case ts.SyntaxKind.PrefixUnaryExpression:
|
|
|
|
switch (node.operator) {
|
|
|
|
case ts.SyntaxKind.PlusPlusToken:
|
|
|
|
case ts.SyntaxKind.MinusMinusToken:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return hasSideEffects(node.operand, options);
|
|
|
|
}
|
|
|
|
case ts.SyntaxKind.ElementAccessExpression:
|
|
|
|
return hasSideEffects(node.expression, options) ||
|
|
|
|
node.argumentExpression !== undefined &&
|
|
|
|
hasSideEffects(node.argumentExpression, options);
|
|
|
|
case ts.SyntaxKind.ConditionalExpression:
|
|
|
|
return hasSideEffects(node.condition, options) ||
|
|
|
|
hasSideEffects(node.whenTrue, options) ||
|
|
|
|
hasSideEffects(node.whenFalse, options);
|
|
|
|
case ts.SyntaxKind.NewExpression:
|
|
|
|
if (options & 2 || hasSideEffects(node.expression, options))
|
|
|
|
return true;
|
|
|
|
if (node.arguments !== undefined)
|
|
|
|
for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) {
|
|
|
|
var child = _a[_i];
|
|
|
|
if (hasSideEffects(child, options))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
case ts.SyntaxKind.TaggedTemplateExpression:
|
|
|
|
if (options & 1 || hasSideEffects(node.tag, options))
|
|
|
|
return true;
|
|
|
|
node = node.template;
|
|
|
|
case ts.SyntaxKind.TemplateExpression:
|
|
|
|
for (var _b = 0, _c = node.templateSpans; _b < _c.length; _b++) {
|
|
|
|
var child = _c[_b];
|
|
|
|
if (hasSideEffects(child.expression, options))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
case ts.SyntaxKind.ClassExpression:
|
|
|
|
return classExpressionHasSideEffects(node, options);
|
|
|
|
case ts.SyntaxKind.ArrayLiteralExpression:
|
|
|
|
for (var _d = 0, _e = node.elements; _d < _e.length; _d++) {
|
|
|
|
var child = _e[_d];
|
|
|
|
if (hasSideEffects(child, options))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
case ts.SyntaxKind.ObjectLiteralExpression:
|
|
|
|
for (var _f = 0, _g = node.properties; _f < _g.length; _f++) {
|
|
|
|
var child = _g[_f];
|
|
|
|
if (child.name !== undefined && child.name.kind === ts.SyntaxKind.ComputedPropertyName &&
|
|
|
|
hasSideEffects(child.name.expression, options))
|
|
|
|
return true;
|
|
|
|
switch (child.kind) {
|
|
|
|
case ts.SyntaxKind.PropertyAssignment:
|
|
|
|
if (hasSideEffects(child.initializer, options))
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case ts.SyntaxKind.SpreadAssignment:
|
|
|
|
if (hasSideEffects(child.expression, options))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
case ts.SyntaxKind.JsxExpression:
|
|
|
|
return node.expression !== undefined && hasSideEffects(node.expression, options);
|
|
|
|
case ts.SyntaxKind.JsxElement:
|
|
|
|
for (var _h = 0, _j = node.children; _h < _j.length; _h++) {
|
|
|
|
var child = _j[_h];
|
|
|
|
if (child.kind !== ts.SyntaxKind.JsxText && hasSideEffects(child, options))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
node = node.openingElement;
|
|
|
|
case ts.SyntaxKind.JsxSelfClosingElement:
|
|
|
|
case ts.SyntaxKind.JsxOpeningElement:
|
|
|
|
if (options & 4)
|
|
|
|
return true;
|
|
|
|
for (var _k = 0, _l = getJsxAttributes(node); _k < _l.length; _k++) {
|
|
|
|
var child = _l[_k];
|
|
|
|
if (child.kind === ts.SyntaxKind.JsxSpreadAttribute) {
|
|
|
|
if (hasSideEffects(child.expression, options))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (child.initializer !== undefined && hasSideEffects(child.initializer, options)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2017-08-14 05:01:11 +02:00
|
|
|
case ts.SyntaxKind.CommaListExpression:
|
|
|
|
for (var _m = 0, _o = node.elements; _m < _o.length; _m++) {
|
|
|
|
var child = _o[_m];
|
|
|
|
if (hasSideEffects(child, options))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2017-05-28 00:38:50 +02:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.hasSideEffects = hasSideEffects;
|
|
|
|
function getJsxAttributes(openElement) {
|
|
|
|
var attributes = openElement.attributes;
|
|
|
|
return Array.isArray(attributes) ? attributes : attributes.properties;
|
|
|
|
}
|
|
|
|
function classExpressionHasSideEffects(node, options) {
|
|
|
|
if (node.heritageClauses !== undefined && node.heritageClauses[0].token === ts.SyntaxKind.ExtendsKeyword)
|
|
|
|
for (var _i = 0, _a = node.heritageClauses[0].types; _i < _a.length; _i++) {
|
|
|
|
var base = _a[_i];
|
|
|
|
if (hasSideEffects(base.expression, options))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
for (var _b = 0, _c = node.members; _b < _c.length; _b++) {
|
|
|
|
var child = _c[_b];
|
|
|
|
if (child.name !== undefined && child.name.kind === ts.SyntaxKind.ComputedPropertyName &&
|
|
|
|
hasSideEffects(child.name.expression, options) ||
|
|
|
|
node_1.isPropertyDeclaration(child) && child.initializer !== undefined &&
|
|
|
|
hasSideEffects(child.initializer, options))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
function getDeclarationOfBindingElement(node) {
|
|
|
|
var parent = node.parent.parent;
|
|
|
|
while (parent.kind === ts.SyntaxKind.BindingElement)
|
|
|
|
parent = parent.parent.parent;
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
exports.getDeclarationOfBindingElement = getDeclarationOfBindingElement;
|
2017-08-14 05:01:11 +02:00
|
|
|
function isExpressionValueUsed(node) {
|
|
|
|
while (true) {
|
|
|
|
var parent = node.parent;
|
|
|
|
switch (parent.kind) {
|
|
|
|
case ts.SyntaxKind.CallExpression:
|
|
|
|
case ts.SyntaxKind.NewExpression:
|
|
|
|
case ts.SyntaxKind.ElementAccessExpression:
|
|
|
|
case ts.SyntaxKind.WhileStatement:
|
|
|
|
case ts.SyntaxKind.DoStatement:
|
|
|
|
case ts.SyntaxKind.WithStatement:
|
|
|
|
case ts.SyntaxKind.ThrowStatement:
|
|
|
|
case ts.SyntaxKind.ReturnStatement:
|
|
|
|
case ts.SyntaxKind.JsxExpression:
|
|
|
|
case ts.SyntaxKind.JsxSpreadAttribute:
|
|
|
|
case ts.SyntaxKind.JsxElement:
|
|
|
|
case ts.SyntaxKind.JsxSelfClosingElement:
|
|
|
|
case ts.SyntaxKind.ComputedPropertyName:
|
|
|
|
case ts.SyntaxKind.ArrowFunction:
|
|
|
|
case ts.SyntaxKind.ExportSpecifier:
|
|
|
|
case ts.SyntaxKind.ExportAssignment:
|
|
|
|
case ts.SyntaxKind.ImportDeclaration:
|
|
|
|
case ts.SyntaxKind.ExternalModuleReference:
|
|
|
|
case ts.SyntaxKind.Decorator:
|
|
|
|
case ts.SyntaxKind.TaggedTemplateExpression:
|
|
|
|
case ts.SyntaxKind.TemplateSpan:
|
|
|
|
case ts.SyntaxKind.ExpressionWithTypeArguments:
|
|
|
|
case ts.SyntaxKind.TypeOfExpression:
|
|
|
|
case ts.SyntaxKind.AwaitExpression:
|
|
|
|
case ts.SyntaxKind.YieldExpression:
|
|
|
|
case ts.SyntaxKind.LiteralType:
|
|
|
|
case ts.SyntaxKind.JsxAttributes:
|
|
|
|
case ts.SyntaxKind.JsxOpeningElement:
|
|
|
|
case ts.SyntaxKind.JsxClosingElement:
|
|
|
|
case ts.SyntaxKind.IfStatement:
|
|
|
|
case ts.SyntaxKind.CaseClause:
|
|
|
|
case ts.SyntaxKind.SwitchStatement:
|
|
|
|
return true;
|
|
|
|
case ts.SyntaxKind.PropertyAccessExpression:
|
|
|
|
return parent.expression === node;
|
|
|
|
case ts.SyntaxKind.QualifiedName:
|
|
|
|
return parent.left === node;
|
|
|
|
case ts.SyntaxKind.ShorthandPropertyAssignment:
|
|
|
|
return parent.objectAssignmentInitializer === node ||
|
|
|
|
!isInDestructuringAssignment(parent);
|
|
|
|
case ts.SyntaxKind.PropertyAssignment:
|
|
|
|
return parent.initializer === node && !isInDestructuringAssignment(parent);
|
|
|
|
case ts.SyntaxKind.SpreadAssignment:
|
|
|
|
case ts.SyntaxKind.SpreadElement:
|
|
|
|
case ts.SyntaxKind.ArrayLiteralExpression:
|
|
|
|
return !isInDestructuringAssignment(parent);
|
|
|
|
case ts.SyntaxKind.ParenthesizedExpression:
|
|
|
|
case ts.SyntaxKind.AsExpression:
|
|
|
|
case ts.SyntaxKind.TypeAssertionExpression:
|
|
|
|
case ts.SyntaxKind.PostfixUnaryExpression:
|
|
|
|
case ts.SyntaxKind.PrefixUnaryExpression:
|
|
|
|
case ts.SyntaxKind.NonNullExpression:
|
|
|
|
node = parent;
|
|
|
|
break;
|
|
|
|
case ts.SyntaxKind.ForStatement:
|
|
|
|
return parent.condition === node;
|
|
|
|
case ts.SyntaxKind.ForInStatement:
|
|
|
|
case ts.SyntaxKind.ForOfStatement:
|
|
|
|
return parent.expression === node;
|
|
|
|
case ts.SyntaxKind.ConditionalExpression:
|
|
|
|
if (parent.condition === node)
|
|
|
|
return true;
|
|
|
|
node = parent;
|
|
|
|
break;
|
|
|
|
case ts.SyntaxKind.PropertyDeclaration:
|
|
|
|
case ts.SyntaxKind.BindingElement:
|
|
|
|
case ts.SyntaxKind.VariableDeclaration:
|
|
|
|
case ts.SyntaxKind.Parameter:
|
|
|
|
case ts.SyntaxKind.EnumMember:
|
|
|
|
return parent.initializer === node;
|
|
|
|
case ts.SyntaxKind.ImportEqualsDeclaration:
|
|
|
|
return parent.moduleReference === node;
|
|
|
|
case ts.SyntaxKind.CommaListExpression:
|
|
|
|
if (parent.elements[parent.elements.length - 1] !== node)
|
|
|
|
return false;
|
|
|
|
node = parent;
|
|
|
|
break;
|
|
|
|
case ts.SyntaxKind.BinaryExpression:
|
|
|
|
if (parent.right === node) {
|
|
|
|
if (parent.operatorToken.kind === ts.SyntaxKind.CommaToken) {
|
|
|
|
node = parent;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
switch (parent.operatorToken.kind) {
|
|
|
|
case ts.SyntaxKind.CommaToken:
|
|
|
|
case ts.SyntaxKind.EqualsToken:
|
|
|
|
return false;
|
|
|
|
case ts.SyntaxKind.EqualsEqualsEqualsToken:
|
|
|
|
case ts.SyntaxKind.EqualsEqualsToken:
|
|
|
|
case ts.SyntaxKind.ExclamationEqualsEqualsToken:
|
|
|
|
case ts.SyntaxKind.ExclamationEqualsToken:
|
|
|
|
case ts.SyntaxKind.InstanceOfKeyword:
|
|
|
|
case ts.SyntaxKind.PlusToken:
|
|
|
|
case ts.SyntaxKind.MinusToken:
|
|
|
|
case ts.SyntaxKind.AsteriskToken:
|
|
|
|
case ts.SyntaxKind.SlashToken:
|
|
|
|
case ts.SyntaxKind.PercentToken:
|
|
|
|
case ts.SyntaxKind.AsteriskAsteriskToken:
|
|
|
|
case ts.SyntaxKind.GreaterThanToken:
|
|
|
|
case ts.SyntaxKind.GreaterThanGreaterThanToken:
|
|
|
|
case ts.SyntaxKind.GreaterThanGreaterThanGreaterThanToken:
|
|
|
|
case ts.SyntaxKind.GreaterThanEqualsToken:
|
|
|
|
case ts.SyntaxKind.LessThanToken:
|
|
|
|
case ts.SyntaxKind.LessThanLessThanToken:
|
|
|
|
case ts.SyntaxKind.LessThanEqualsToken:
|
|
|
|
case ts.SyntaxKind.AmpersandToken:
|
|
|
|
case ts.SyntaxKind.BarToken:
|
|
|
|
case ts.SyntaxKind.CaretToken:
|
|
|
|
case ts.SyntaxKind.BarBarToken:
|
|
|
|
case ts.SyntaxKind.AmpersandAmpersandToken:
|
|
|
|
case ts.SyntaxKind.InKeyword:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
node = parent;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.isExpressionValueUsed = isExpressionValueUsed;
|
|
|
|
function isInDestructuringAssignment(node) {
|
|
|
|
switch (node.kind) {
|
|
|
|
case ts.SyntaxKind.ShorthandPropertyAssignment:
|
|
|
|
if (node.objectAssignmentInitializer !== undefined)
|
|
|
|
return true;
|
|
|
|
case ts.SyntaxKind.PropertyAssignment:
|
|
|
|
case ts.SyntaxKind.SpreadAssignment:
|
|
|
|
node = node.parent;
|
|
|
|
break;
|
|
|
|
case ts.SyntaxKind.SpreadElement:
|
|
|
|
if (node.parent.kind !== ts.SyntaxKind.ArrayLiteralExpression)
|
|
|
|
return false;
|
|
|
|
node = node.parent;
|
|
|
|
}
|
|
|
|
while (true) {
|
|
|
|
switch (node.parent.kind) {
|
|
|
|
case ts.SyntaxKind.BinaryExpression:
|
|
|
|
return node.parent.left === node &&
|
|
|
|
node.parent.operatorToken.kind === ts.SyntaxKind.EqualsToken;
|
|
|
|
case ts.SyntaxKind.ForOfStatement:
|
|
|
|
return node.parent.initializer === node;
|
|
|
|
case ts.SyntaxKind.ArrayLiteralExpression:
|
|
|
|
case ts.SyntaxKind.ObjectLiteralExpression:
|
|
|
|
node = node.parent;
|
|
|
|
break;
|
|
|
|
case ts.SyntaxKind.SpreadAssignment:
|
|
|
|
case ts.SyntaxKind.PropertyAssignment:
|
|
|
|
node = node.parent.parent;
|
|
|
|
break;
|
|
|
|
case ts.SyntaxKind.SpreadElement:
|
|
|
|
if (node.parent.parent.kind !== ts.SyntaxKind.ArrayLiteralExpression)
|
|
|
|
return false;
|
|
|
|
node = node.parent.parent;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function isReassignmentTarget(node) {
|
|
|
|
var parent = node.parent;
|
|
|
|
switch (parent.kind) {
|
|
|
|
case ts.SyntaxKind.PostfixUnaryExpression:
|
|
|
|
case ts.SyntaxKind.DeleteExpression:
|
|
|
|
return true;
|
|
|
|
case ts.SyntaxKind.PrefixUnaryExpression:
|
|
|
|
return parent.operator === ts.SyntaxKind.PlusPlusToken ||
|
|
|
|
parent.operator === ts.SyntaxKind.MinusMinusToken;
|
|
|
|
case ts.SyntaxKind.BinaryExpression:
|
|
|
|
return parent.left === node &&
|
|
|
|
isAssignmentKind(parent.operatorToken.kind);
|
|
|
|
case ts.SyntaxKind.ShorthandPropertyAssignment:
|
|
|
|
return parent.name === node &&
|
|
|
|
isInDestructuringAssignment(parent);
|
|
|
|
case ts.SyntaxKind.PropertyAssignment:
|
|
|
|
return parent.initializer === node &&
|
|
|
|
isInDestructuringAssignment(parent);
|
|
|
|
case ts.SyntaxKind.ObjectLiteralExpression:
|
|
|
|
case ts.SyntaxKind.ArrayLiteralExpression:
|
|
|
|
case ts.SyntaxKind.SpreadElement:
|
|
|
|
case ts.SyntaxKind.SpreadAssignment:
|
|
|
|
return isInDestructuringAssignment(parent);
|
|
|
|
case ts.SyntaxKind.ParenthesizedExpression:
|
|
|
|
return isReassignmentTarget(parent);
|
|
|
|
case ts.SyntaxKind.ForOfStatement:
|
|
|
|
case ts.SyntaxKind.ForInStatement:
|
|
|
|
return parent.initializer === node;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
exports.isReassignmentTarget = isReassignmentTarget;
|
|
|
|
function getIdentifierText(node) {
|
|
|
|
return ts.unescapeIdentifier(node.text);
|
|
|
|
}
|
|
|
|
exports.getIdentifierText = getIdentifierText;
|
2017-10-14 18:40:54 +02:00
|
|
|
function canHaveJsDoc(node) {
|
|
|
|
switch (node.kind) {
|
|
|
|
case ts.SyntaxKind.Parameter:
|
|
|
|
case ts.SyntaxKind.CallSignature:
|
|
|
|
case ts.SyntaxKind.ConstructSignature:
|
|
|
|
case ts.SyntaxKind.MethodSignature:
|
|
|
|
case ts.SyntaxKind.PropertySignature:
|
|
|
|
case ts.SyntaxKind.ArrowFunction:
|
|
|
|
case ts.SyntaxKind.ParenthesizedExpression:
|
|
|
|
case ts.SyntaxKind.SpreadAssignment:
|
|
|
|
case ts.SyntaxKind.ShorthandPropertyAssignment:
|
|
|
|
case ts.SyntaxKind.PropertyAssignment:
|
|
|
|
case ts.SyntaxKind.FunctionExpression:
|
|
|
|
case ts.SyntaxKind.FunctionDeclaration:
|
|
|
|
case ts.SyntaxKind.LabeledStatement:
|
|
|
|
case ts.SyntaxKind.ExpressionStatement:
|
|
|
|
case ts.SyntaxKind.VariableStatement:
|
|
|
|
case ts.SyntaxKind.Constructor:
|
|
|
|
case ts.SyntaxKind.MethodDeclaration:
|
|
|
|
case ts.SyntaxKind.PropertyDeclaration:
|
|
|
|
case ts.SyntaxKind.GetAccessor:
|
|
|
|
case ts.SyntaxKind.SetAccessor:
|
|
|
|
case ts.SyntaxKind.ClassDeclaration:
|
|
|
|
case ts.SyntaxKind.ClassExpression:
|
|
|
|
case ts.SyntaxKind.InterfaceDeclaration:
|
|
|
|
case ts.SyntaxKind.TypeAliasDeclaration:
|
|
|
|
case ts.SyntaxKind.EnumMember:
|
|
|
|
case ts.SyntaxKind.EnumDeclaration:
|
|
|
|
case ts.SyntaxKind.ModuleDeclaration:
|
|
|
|
case ts.SyntaxKind.ImportEqualsDeclaration:
|
|
|
|
case ts.SyntaxKind.IndexSignature:
|
|
|
|
case ts.SyntaxKind.FunctionType:
|
|
|
|
case ts.SyntaxKind.ConstructorType:
|
|
|
|
case ts.SyntaxKind.JSDocFunctionType:
|
|
|
|
case ts.SyntaxKind.EndOfFileToken:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.canHaveJsDoc = canHaveJsDoc;
|
|
|
|
function getJsDoc(node, sourceFile) {
|
|
|
|
if (node.kind === ts.SyntaxKind.EndOfFileToken)
|
|
|
|
return parseJsDocWorker(node, sourceFile || node.parent);
|
|
|
|
var result = [];
|
|
|
|
for (var _i = 0, _a = node.getChildren(sourceFile); _i < _a.length; _i++) {
|
|
|
|
var child = _a[_i];
|
|
|
|
if (!node_1.isJsDoc(child))
|
|
|
|
break;
|
|
|
|
result.push(child);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
exports.getJsDoc = getJsDoc;
|
|
|
|
function parseJsDocOfNode(node, considerTrailingComments, sourceFile) {
|
|
|
|
if (sourceFile === void 0) { sourceFile = node.getSourceFile(); }
|
|
|
|
if (canHaveJsDoc(node) && node.kind !== ts.SyntaxKind.EndOfFileToken) {
|
|
|
|
var result = getJsDoc(node, sourceFile);
|
|
|
|
if (result.length !== 0 || !considerTrailingComments)
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
return parseJsDocWorker(node, sourceFile, considerTrailingComments);
|
|
|
|
}
|
|
|
|
exports.parseJsDocOfNode = parseJsDocOfNode;
|
|
|
|
function parseJsDocWorker(node, sourceFile, considerTrailingComments) {
|
|
|
|
var nodeStart = node.getStart(sourceFile);
|
|
|
|
var start = ts[considerTrailingComments && isSameLine(sourceFile, node.pos, nodeStart)
|
|
|
|
? 'forEachTrailingCommentRange'
|
|
|
|
: 'forEachLeadingCommentRange'](sourceFile.text, node.pos, function (pos, _end, kind) { return kind === ts.SyntaxKind.MultiLineCommentTrivia && sourceFile.text[pos + 2] === '*' ? { pos: pos } : undefined; });
|
|
|
|
if (start === undefined)
|
|
|
|
return [];
|
|
|
|
var startPos = start.pos;
|
|
|
|
var text = sourceFile.text.slice(startPos, nodeStart);
|
|
|
|
var newSourceFile = ts.createSourceFile('jsdoc.ts', text + "var a;", sourceFile.languageVersion);
|
|
|
|
var result = getJsDoc(newSourceFile.statements[0], newSourceFile);
|
|
|
|
for (var _i = 0, result_1 = result; _i < result_1.length; _i++) {
|
|
|
|
var doc = result_1[_i];
|
|
|
|
updateNode(doc, node);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
function updateNode(n, parent) {
|
|
|
|
n.pos += startPos;
|
|
|
|
n.end += startPos;
|
|
|
|
n.parent = parent;
|
|
|
|
return ts.forEachChild(n, function (child) { return updateNode(child, n); }, function (children) {
|
|
|
|
children.pos += startPos;
|
|
|
|
children.end += startPos;
|
|
|
|
for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
|
|
|
|
var child = children_1[_i];
|
|
|
|
updateNode(child, n);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var ImportKind;
|
|
|
|
(function (ImportKind) {
|
|
|
|
ImportKind[ImportKind["ImportDeclaration"] = 1] = "ImportDeclaration";
|
|
|
|
ImportKind[ImportKind["ImportEquals"] = 2] = "ImportEquals";
|
|
|
|
ImportKind[ImportKind["ExportFrom"] = 4] = "ExportFrom";
|
|
|
|
ImportKind[ImportKind["DynamicImport"] = 8] = "DynamicImport";
|
|
|
|
ImportKind[ImportKind["Require"] = 16] = "Require";
|
|
|
|
ImportKind[ImportKind["All"] = 31] = "All";
|
|
|
|
ImportKind[ImportKind["AllImports"] = 27] = "AllImports";
|
|
|
|
ImportKind[ImportKind["AllStaticImports"] = 3] = "AllStaticImports";
|
|
|
|
ImportKind[ImportKind["AllImportExpressions"] = 24] = "AllImportExpressions";
|
|
|
|
ImportKind[ImportKind["AllRequireLike"] = 18] = "AllRequireLike";
|
|
|
|
})(ImportKind = exports.ImportKind || (exports.ImportKind = {}));
|
|
|
|
var ImportOptions;
|
|
|
|
(function (ImportOptions) {
|
|
|
|
ImportOptions[ImportOptions["ImportDeclaration"] = 1] = "ImportDeclaration";
|
|
|
|
ImportOptions[ImportOptions["ImportEquals"] = 2] = "ImportEquals";
|
|
|
|
ImportOptions[ImportOptions["ExportFrom"] = 4] = "ExportFrom";
|
|
|
|
ImportOptions[ImportOptions["DynamicImport"] = 8] = "DynamicImport";
|
|
|
|
ImportOptions[ImportOptions["Require"] = 16] = "Require";
|
|
|
|
ImportOptions[ImportOptions["All"] = 31] = "All";
|
|
|
|
ImportOptions[ImportOptions["AllImports"] = 27] = "AllImports";
|
|
|
|
ImportOptions[ImportOptions["AllStaticImports"] = 3] = "AllStaticImports";
|
|
|
|
ImportOptions[ImportOptions["AllDynamic"] = 24] = "AllDynamic";
|
|
|
|
ImportOptions[ImportOptions["AllRequireLike"] = 18] = "AllRequireLike";
|
|
|
|
})(ImportOptions = exports.ImportOptions || (exports.ImportOptions = {}));
|
|
|
|
function findImports(sourceFile, options) {
|
|
|
|
return new ImportFinder(sourceFile, options).find();
|
|
|
|
}
|
|
|
|
exports.findImports = findImports;
|
|
|
|
var ImportFinder = (function () {
|
|
|
|
function ImportFinder(_sourceFile, _options) {
|
|
|
|
var _this = this;
|
|
|
|
this._sourceFile = _sourceFile;
|
|
|
|
this._options = _options;
|
|
|
|
this._result = [];
|
|
|
|
this._findDynamic = function (node) {
|
|
|
|
if (node_1.isCallExpression(node) && node.arguments.length === 1 &&
|
|
|
|
(node.expression.kind === ts.SyntaxKind.ImportKeyword && _this._options & 8 ||
|
|
|
|
_this._options & 16 && node.expression.kind === ts.SyntaxKind.Identifier &&
|
|
|
|
node.expression.text === 'require'))
|
|
|
|
_this._addImport(node.arguments[0]);
|
|
|
|
ts.forEachChild(node, _this._findDynamic);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
ImportFinder.prototype.find = function () {
|
|
|
|
this._findImports(this._sourceFile.statements);
|
|
|
|
return this._result;
|
|
|
|
};
|
|
|
|
ImportFinder.prototype._findImports = function (statements) {
|
|
|
|
for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) {
|
|
|
|
var statement = statements_1[_i];
|
|
|
|
if (node_1.isImportDeclaration(statement)) {
|
|
|
|
if (this._options & 1)
|
|
|
|
this._addImport(statement.moduleSpecifier);
|
|
|
|
}
|
|
|
|
else if (node_1.isImportEqualsDeclaration(statement)) {
|
|
|
|
if (this._options & 2 &&
|
|
|
|
statement.moduleReference.kind === ts.SyntaxKind.ExternalModuleReference &&
|
|
|
|
statement.moduleReference.expression !== undefined)
|
|
|
|
this._addImport(statement.moduleReference.expression);
|
|
|
|
}
|
|
|
|
else if (node_1.isExportDeclaration(statement)) {
|
|
|
|
if (statement.moduleSpecifier !== undefined && this._options & 4)
|
|
|
|
this._addImport(statement.moduleSpecifier);
|
|
|
|
}
|
|
|
|
else if (node_1.isModuleDeclaration(statement) && statement.body !== undefined && this._sourceFile.isDeclarationFile) {
|
|
|
|
this._findImportsInModule(statement.body);
|
|
|
|
}
|
|
|
|
else if (this._options & 24 && !this._sourceFile.isDeclarationFile) {
|
|
|
|
ts.forEachChild(statement, this._findDynamic);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
ImportFinder.prototype._findImportsInModule = function (body) {
|
|
|
|
if (body.kind === ts.SyntaxKind.ModuleBlock)
|
|
|
|
return this._findImports(body.statements);
|
|
|
|
if (body.kind === ts.SyntaxKind.ModuleDeclaration && body.body !== undefined)
|
|
|
|
return this._findImportsInModule(body.body);
|
|
|
|
};
|
|
|
|
ImportFinder.prototype._addImport = function (expression) {
|
|
|
|
if (node_1.isTextualLiteral(expression))
|
|
|
|
this._result.push(expression);
|
|
|
|
};
|
|
|
|
return ImportFinder;
|
|
|
|
}());
|
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInV0aWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSwrQkFBaUM7QUFDakMsMENBRzJCO0FBRTNCLHdCQUF3RCxJQUFhLEVBQUUsSUFBTyxFQUFFLFVBQTBCO0lBQ3RHLEdBQUcsQ0FBQyxDQUFnQixVQUE0QixFQUE1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