<commit_before>import { Node, SyntaxKind, SourceFile } from 'typescript';
import { emitImportDeclaration } from './imports';
import { emitFunctionLikeDeclaration } from './functions';
import { emitExpressionStatement, emitCallExpressionStatement } from './expressions';
import { emitIdentifier, emitType } from './identifiers';
import { emitSourceFile } from './source';
import { Context } from '../contexts';

export interface EmitResult {
  context: Context;
  emitted_string: string;
}

export const emit = (node: Node, context: Context): EmitResult => {
  switch (node.kind) {
    case SyntaxKind.SourceFile: return emitSourceFile(<any>node, context);
    case SyntaxKind.ImportDeclaration: return emitImportDeclaration(<any>node, context);
    case SyntaxKind.FunctionDeclaration: return emitFunctionLikeDeclaration(<any>node, context);
    case SyntaxKind.ExpressionStatement: return emitExpressionStatement(<any>node, context);
    case SyntaxKind.CallExpression: return emitCallExpressionStatement(<any>node, context);
    case SyntaxKind.Identifier: return emitIdentifier(<any>node, context);
    case SyntaxKind.TypeReference: return emitType(<any>node, context);
    case SyntaxKind.EndOfFileToken: return { context, emitted_string: 'end' };
    default: throw new Error(`unknown syntax kind ${SyntaxKind[node.kind]}`);
  }
};<commit_msg>Add ability to blissfully ignore certain nodes<commit_after>import { Node, SyntaxKind, SourceFile } from 'typescript';
import { emitImportDeclaration } from './imports';
import { emitFunctionLikeDeclaration } from './functions';
import { emitExpressionStatement, emitCallExpressionStatement } from './expressions';
import { emitIdentifier, emitType } from './identifiers';
import { emitBlock } from './blocks';
import { emitSourceFile } from './source';
import { emitReturnStatement } from './statements';
import { Context } from '../contexts';

export interface EmitResult {
  context: Context;
  emitted_string: string;
}

const ignore = (node: Node, context: Context): EmitResult => ({
  context,
  emitted_string: `ignored ${SyntaxKind[node.kind]}`
})

export const emit = (node: Node, context: Context): EmitResult => {
  switch (node.kind) {
    case SyntaxKind.SourceFile: return emitSourceFile(<any>node, context);
    case SyntaxKind.ImportDeclaration: return emitImportDeclaration(<any>node, context);
    case SyntaxKind.FunctionDeclaration: return emitFunctionLikeDeclaration(<any>node, context);
    case SyntaxKind.ExpressionStatement: return emitExpressionStatement(<any>node, context);
    case SyntaxKind.CallExpression: return emitCallExpressionStatement(<any>node, context);
    case SyntaxKind.Identifier: return emitIdentifier(<any>node, context);
    case SyntaxKind.TypeReference: return emitType(<any>node, context);
    case SyntaxKind.Block: return emitBlock(<any>node, context);
    case SyntaxKind.ReturnStatement: return emitReturnStatement(<any>node, context);
    case SyntaxKind.EndOfFileToken: return { context, emitted_string: 'end' };
    case SyntaxKind.ConditionalExpression: return ignore(node, context);
    case SyntaxKind.VariableStatement: return ignore(node, context);
    case SyntaxKind.BinaryExpression: return ignore(node, context);  
    default: throw new Error(`unknown syntax kind ${SyntaxKind[node.kind]}`);
  }
};
{'fraction_non_alphanumeric': 0.11493212669683257, 'fraction_numerical': 0.0, 'mean_word_length': 5.9957805907173, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '103279', 'n_tokens_mistral': 884, 'n_tokens_neox': 865, 'n_words': 244}