UNPKG

4.76 kBSource Map (JSON)View Raw
1{"version":3,"file":"project.js","sourceRoot":"","sources":["../../../../src/lib/models/reflections/project.ts"],"names":[],"mappings":";;AAAA,4CAA+D;AAC/D,yCAAwD;AACxD,2CAAkD;AAQlD,MAAa,iBAAkB,SAAQ,+BAAmB;IAyCtD,YAAY,IAAY;QACpB,KAAK,CAAC,IAAI,EAAE,yBAAc,CAAC,MAAM,CAAC,CAAC;QAtCvC,gBAAW,GAA+B,EAAE,CAAC;QAE7C,kBAAa,GAAiC,EAAE,CAAC;QAKjD,cAAS,GAAoB,IAAI,uBAAe,EAAE,CAAC;QAKnD,UAAK,GAAiB,EAAE,CAAC;IA2BzB,CAAC;IAKD,SAAS;QACL,OAAO,IAAI,CAAC;IAChB,CAAC;IAQD,oBAAoB,CAAC,IAAoB;QACrC,MAAM,MAAM,GAAiB,EAAE,CAAC;QAChC,KAAK,IAAI,EAAE,IAAI,IAAI,CAAC,WAAW,EAAE;YAC7B,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YACxC,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;gBACzB,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;aAC3B;SACJ;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IAQD,oBAAoB,CAAC,GAAsB;QACvC,MAAM,KAAK,GAAa,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAClE,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC;QAEzB,MAAM,EAAE,KAAK,IAAI,GAAG,IAAI,IAAI,CAAC,WAAW,EAAE;YACtC,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;YACzC,IAAI,UAAU,CAAC,IAAI,KAAK,IAAI,EAAE;gBAC1B,SAAS;aACZ;YAED,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;YAC7B,IAAI,MAAM,GAA2B,UAAU,CAAC;YAChD,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE;gBAC3C,IAAI,MAAM,CAAC,IAAI,KAAK,KAAK,CAAC,KAAK,CAAC,EAAE;oBAC9B,SAAS,MAAM,CAAC;iBACnB;gBACD,KAAK,IAAI,CAAC,CAAC;aACd;YAED,OAAO,UAAU,CAAC;SACrB;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ;AApGD,8CAoGC","sourcesContent":["import { SourceFile, SourceDirectory } from '../sources/index';\nimport { Reflection, ReflectionKind } from './abstract';\nimport { ContainerReflection } from './container';\n\n/**\n * A reflection that represents the root of the project.\n *\n * The project reflection acts as a global index, one may receive all reflections\n * and source files of the processed project through this reflection.\n */\nexport class ProjectReflection extends ContainerReflection {\n /**\n * A list of all reflections within the project.\n */\n reflections: {[id: number]: Reflection} = {};\n\n symbolMapping: {[symbolId: number]: number} = {};\n\n /**\n * The root directory of the project.\n */\n directory: SourceDirectory = new SourceDirectory();\n\n /**\n * A list of all source files within the project.\n */\n files: SourceFile[] = [];\n\n /**\n * The name of the project.\n *\n * The name can be passed as a command line argument or it is read from the package info.\n * this.name is assigned in the Reflection class.\n */\n name!: string;\n\n /**\n * The contents of the readme.md file of the project when found.\n */\n readme?: string;\n\n /**\n * The parsed data of the package.json file of the project when found.\n */\n packageInfo: any;\n\n /**\n * Create a new ProjectReflection instance.\n *\n * @param name The name of the project.\n */\n constructor(name: string) {\n super(name, ReflectionKind.Global);\n }\n\n /**\n * Return whether this reflection is the root / project reflection.\n */\n isProject(): boolean {\n return true;\n }\n\n /**\n * Return a list of all reflections in this project of a certain kind.\n *\n * @param kind The desired kind of reflection.\n * @returns An array containing all reflections with the desired kind.\n */\n getReflectionsByKind(kind: ReflectionKind): Reflection[] {\n const values: Reflection[] = [];\n for (let id in this.reflections) {\n const reflection = this.reflections[id];\n if (reflection.kindOf(kind)) {\n values.push(reflection);\n }\n }\n\n return values;\n }\n\n /**\n * Try to find a reflection by its name.\n *\n * @param names The name hierarchy to look for, if a string, the name will be split on \".\"\n * @return The found reflection or undefined.\n */\n findReflectionByName(arg: string | string[]): Reflection | undefined {\n const names: string[] = Array.isArray(arg) ? arg : arg.split('.');\n const name = names.pop();\n\n search: for (let key in this.reflections) {\n const reflection = this.reflections[key];\n if (reflection.name !== name) {\n continue;\n }\n\n let depth = names.length - 1;\n let target: Reflection | undefined = reflection;\n while ((target = target.parent) && depth >= 0) {\n if (target.name !== names[depth]) {\n continue search;\n }\n depth -= 1;\n }\n\n return reflection;\n }\n\n return undefined;\n }\n}\n"]}
\No newline at end of file