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AAC;IArED;QAVC,kBAAM,CAAC;YACJ,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,wFAAwF;YAC9F,IAAI,EAAE,2BAAa,CAAC,GAAG;YACvB,GAAG,EAAE;gBACD,MAAM,EAAE,cAAc,CAAC,IAAI;gBAC3B,SAAS,EAAE,cAAc,CAAC,OAAO;aACpC;YACD,YAAY,EAAE,cAAc,CAAC,OAAO;SACvC,CAAC;gDACW;IAXJ,cAAc;QAD1B,sBAAS,CAAC,EAAC,IAAI,EAAE,YAAY,EAAC,CAAC;OACnB,cAAc,CAiF1B;IAAD,qBAAC;CAAA,AAjFD,CAAoC,mCAAsB,GAiFzD;AAjFY,wCAAc","sourcesContent":["import * as ts from 'typescript';\n\nimport { Reflection, ReflectionKind, ReflectionFlag } from '../../models/index';\nimport { createDeclaration } from '../factories/index';\nimport { Context } from '../context';\nimport { Component, ConverterNodeComponent } from '../components';\nimport { Option } from '../../utils/component';\nimport { ParameterType } from '../../utils/options/declaration';\n\nconst prefered: ts.SyntaxKind[] = [\n ts.SyntaxKind.ClassDeclaration,\n ts.SyntaxKind.InterfaceDeclaration,\n ts.SyntaxKind.EnumDeclaration\n];\n\nexport enum SourceFileMode {\n File, Modules\n}\n\n@Component({name: 'node:block'})\nexport class BlockConverter extends ConverterNodeComponent<ts.SourceFile|ts.Block|ts.ModuleBlock> {\n @Option({\n name: 'mode',\n help: \"Specifies the output mode the project is used to be compiled with: 'file' or 'modules'\",\n type: ParameterType.Map,\n map: {\n 'file': SourceFileMode.File,\n 'modules': SourceFileMode.Modules\n },\n defaultValue: SourceFileMode.Modules\n })\n mode: number;\n\n /**\n * List of supported TypeScript syntax kinds.\n */\n supports: ts.SyntaxKind[] = [\n ts.SyntaxKind.Block,\n ts.SyntaxKind.ModuleBlock,\n ts.SyntaxKind.SourceFile\n ];\n\n /**\n * Analyze the given class declaration node and create a suitable reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The class declaration node that should be analyzed.\n * @return The resulting reflection or NULL.\n */\n convert(context: Context, node: ts.SourceFile|ts.Block|ts.ModuleBlock): Reflection {\n if (node.kind === ts.SyntaxKind.SourceFile) {\n this.convertSourceFile(context, <ts.SourceFile> node);\n } else {\n this.convertStatements(context, node);\n }\n\n return context.scope;\n }\n\n /**\n * Analyze the given source file node and create a suitable reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The source file node that should be analyzed.\n * @return The resulting reflection or NULL.\n */\n private convertSourceFile(context: Context, node: ts.SourceFile): Reflection {\n let result = context.scope;\n\n context.withSourceFile(node, () => {\n if (this.mode === SourceFileMode.Modules) {\n result = createDeclaration(context, node, ReflectionKind.ExternalModule, node.fileName);\n context.withScope(result, () => {\n this.convertStatements(context, node);\n result.setFlag(ReflectionFlag.Exported);\n });\n } else {\n this.convertStatements(context, node);\n }\n });\n\n return result;\n }\n\n private convertStatements(context: Context, node: ts.SourceFile|ts.Block|ts.ModuleBlock) {\n if (node.statements) {\n const statements: ts.Statement[] = [];\n\n node.statements.forEach((statement) => {\n if (prefered.indexOf(statement.kind) !== -1) {\n this.owner.convertNode(context, statement);\n } else {\n statements.push(statement);\n }\n });\n\n statements.forEach((statement) => {\n this.owner.convertNode(context, statement);\n });\n }\n }\n}\n"]}
|