Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getTokenEnd(node: ts.Node, kind: SyntaxKind.OpenBraceToken | SyntaxKind.ColonToken) {
// @code-fence-allow(getChildren): Ok, not searching for comments.
const token = node.getChildren(sourceFile).find(c => c.kind === kind);
if (token == null)
throw new errors.NotImplementedError(`Unexpected scenario where a(n) ${getSyntaxKindName(kind)} was not found.`);
return token.end;
}
}
function getCtor() {
if (isStatementContainerNode(container))
return CompilerCommentStatement;
if (ts.isClassLike(container))
return CompilerCommentClassElement;
if (ts.isInterfaceDeclaration(container) || ts.isTypeLiteralNode(container))
return CompilerCommentTypeElement;
if (ts.isObjectLiteralExpression(container))
return CompilerCommentObjectLiteralElement;
if (ts.isEnumDeclaration(container))
return CompilerCommentEnumMember;
throw new errors.NotImplementedError(`Not implemented comment node container type: ${getSyntaxKindName(container.kind)}`);
}
}
getHeritageClauseByKindOrThrow(kind: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword) {
return errors.throwIfNullOrUndefined(this.getHeritageClauseByKind(kind), `Expected to have heritage clause of kind ${getSyntaxKindName(kind)}.`);
}
getInitializerIfKindOrThrow(kind: TKind) {
return errors.throwIfNullOrUndefined(this.getInitializerIfKind(kind), `Expected to find an initializer of kind '${getSyntaxKindName(kind)}'.`);
}
getExpressionIfKindOrThrow(kind: TKind): KindToExpressionMappings[TKind] {
return errors.throwIfNullOrUndefined(this.getExpressionIfKind(kind), `An expression of the kind ${getSyntaxKindName(kind)} was expected.`);
}