Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static getContainerBodyPos(container: ContainerNodes, sourceFile: ts.SourceFile) {
if (ts.isSourceFile(container))
return 0;
if (ts.isClassDeclaration(container)
|| ts.isEnumDeclaration(container)
|| ts.isInterfaceDeclaration(container)
|| ts.isTypeLiteralNode(container)
|| ts.isClassExpression(container)
|| ts.isBlock(container)
|| ts.isModuleBlock(container)
|| ts.isObjectLiteralExpression(container))
{
// this function is only used when there are no statements or members, so only do this
return getTokenEnd(container, SyntaxKind.OpenBraceToken);
}
if (ts.isCaseClause(container) || ts.isDefaultClause(container))
return getTokenEnd(container, SyntaxKind.ColonToken);
return errors.throwNotImplementedForNeverValueError(container);
function getTokenEnd(node: ts.Node, kind: SyntaxKind.OpenBraceToken | SyntaxKind.ColonToken) {
function getContainerChildren() {
if (ts.isSourceFile(container) || ts.isBlock(container) || ts.isModuleBlock(container) || ts.isCaseClause(container) || ts.isDefaultClause(container))
return container.statements;
if (ts.isClassDeclaration(container)
|| ts.isClassExpression(container)
|| ts.isEnumDeclaration(container)
|| ts.isInterfaceDeclaration(container)
|| ts.isTypeLiteralNode(container)
|| ts.isClassExpression(container))
{
return container.members;
}
if (ts.isObjectLiteralExpression(container))
return container.properties;
return errors.throwNotImplementedForNeverValueError(container);
}