Project

General

Profile

1
{"version":3,"file":"check_types.js","sourceRoot":"","sources":["../../../../../packages/compiler-cli/src/diagnostics/check_types.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAEH,8CAA+N;AAC/N,+BAAiC;AAWjC,IAAM,qBAAqB,GAAyB;IAClD,uBAAuB,EAAvB,cAAmC,MAAM,CAAC,KAAK,CAAC,CAAA,CAAC;IACjD,4BAA4B,EAA5B,cAAqC,CAAC;CACvC,CAAC;AAEF;IAUE,qBACY,OAAmB,EAAU,SAA6B,EAC1D,YAA6B,EAAU,eAAgC,EACvE,UAA8B,EAAU,gBAAoC,EAC5E,eAAiC;QAHjC,YAAO,GAAP,OAAO,CAAY;QAAU,cAAS,GAAT,SAAS,CAAoB;QAC1D,iBAAY,GAAZ,YAAY,CAAiB;QAAU,oBAAe,GAAf,eAAe,CAAiB;QACvE,eAAU,GAAV,UAAU,CAAoB;QAAU,qBAAgB,GAAhB,gBAAgB,CAAoB;QAC5E,oBAAe,GAAf,eAAe,CAAkB;QAPrC,8BAAyB,GAAyB,qBAAqB,CAAC;QACxE,aAAQ,GAAY,KAAK,CAAC;IAMc,CAAC;IAEjD,oCAAc,GAAd,UAAe,QAAiB,EAAE,iBAAwC;QACxE,IAAI,CAAC,yBAAyB,GAAG,iBAAiB,IAAI,qBAAqB,CAAC;QAC5E,IAAI,CAAC;YACH,MAAM,CAAC,QAAQ;gBACX,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,GAC9C,CAAA,KAAC,EAAmB,CAAA,CAAC,MAAM,WAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QACtF,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,yBAAyB,GAAG,qBAAqB,CAAC;QACzD,CAAC;;IACH,CAAC;IAED,sBAAI,uCAAc;aAAlB,cAAgC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CA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IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC;IACzC,CAAC;IAED,yCAAc,GAAd,UAAe,IAAY,IAAc,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAEjF,+CAAoB,GAApB,UAAqB,QAAgB;QACnC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAClD,CAAC;IAED,oDAAyB,GAAzB,cAAuC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,CAAC,CAAC,CAAC;IAEtF,qCAAU,GAAV,cAAuB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IAEvD,qCAAU,GAAV,UAAW,QAAgB;QACzB,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACxE,CAAC;IAED,mCAAQ,GAAR,UAAS,QAAgB;QACvB,IAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACjD,MAAM,CAAC,CAAC,WAAW,IAAI,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAClF,CAAC;IACH,uBAAC;AAAD,CAAC,AAhDD,IAgDC","sourcesContent":["/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {AotCompiler, AotCompilerHost, AotCompilerOptions, EmitterVisitorContext, GeneratedFile, NgAnalyzedModules, ParseSourceSpan, Statement, StaticReflector, TypeScriptEmitter, createAotCompiler} from '@angular/compiler';\nimport * as ts from 'typescript';\n\nimport {Diagnostic, DiagnosticCategory} from '../transformers/api';\n\ninterface FactoryInfo {\n  source: ts.SourceFile;\n  context: EmitterVisitorContext;\n}\n\ntype FactoryInfoMap = Map<string, FactoryInfo>;\n\nconst stubCancellationToken: ts.CancellationToken = {\n  isCancellationRequested(): boolean{return false;},\n  throwIfCancellationRequested(): void{}\n};\n\nexport class TypeChecker {\n  private _aotCompiler: AotCompiler|undefined;\n  private _reflector: StaticReflector|undefined;\n  private _factories: Map<string, FactoryInfo>|undefined;\n  private _factoryNames: string[]|undefined;\n  private _diagnosticProgram: ts.Program|undefined;\n  private _diagnosticsByFile: Map<string, Diagnostic[]>|undefined;\n  private _currentCancellationToken: ts.CancellationToken = stubCancellationToken;\n  private _partial: boolean = false;\n\n  constructor(\n      private program: ts.Program, private tsOptions: ts.CompilerOptions,\n      private compilerHost: ts.CompilerHost, private aotCompilerHost: AotCompilerHost,\n      private aotOptions: AotCompilerOptions, private _analyzedModules?: NgAnalyzedModules,\n      private _generatedFiles?: GeneratedFile[]) {}\n\n  getDiagnostics(fileName?: string, cancellationToken?: ts.CancellationToken): Diagnostic[] {\n    this._currentCancellationToken = cancellationToken || stubCancellationToken;\n    try {\n      return fileName ?\n          this.diagnosticsByFileName.get(fileName) || [] :\n          ([] as Diagnostic[]).concat(...Array.from(this.diagnosticsByFileName.values()));\n    } finally {\n      this._currentCancellationToken = stubCancellationToken;\n    }\n  }\n\n  get partialResults(): boolean { return this._partial; }\n\n  private get analyzedModules(): NgAnalyzedModules {\n    return this._analyzedModules || (this._analyzedModules = this.aotCompiler.analyzeModulesSync(\n                                         this.program.getSourceFiles().map(sf => sf.fileName)));\n  }\n\n  private get diagnosticsByFileName(): Map<string, Diagnostic[]> {\n    return this._diagnosticsByFile || this.createDiagnosticsByFile();\n  }\n\n  private get diagnosticProgram(): ts.Program {\n    return this._diagnosticProgram || this.createDiagnosticProgram();\n  }\n\n  private get generatedFiles(): GeneratedFile[] {\n    let result = this._generatedFiles;\n    if (!result) {\n      this._generatedFiles = result = this.aotCompiler.emitAllImpls(this.analyzedModules);\n    }\n    return result;\n  }\n\n  private get aotCompiler(): AotCompiler {\n    return this._aotCompiler || this.createCompilerAndReflector();\n  }\n\n  private get reflector(): StaticReflector {\n    let result = this._reflector;\n    if (!result) {\n      this.createCompilerAndReflector();\n      result = this._reflector !;\n    }\n    return result;\n  }\n\n  private get factories(): Map<string, FactoryInfo> {\n    return this._factories || this.createFactories();\n  }\n\n  private get factoryNames(): string[] {\n    return this._factoryNames || (this.createFactories() && this._factoryNames !);\n  }\n\n  private createCompilerAndReflector() {\n    const {compiler, reflector} = createAotCompiler(this.aotCompilerHost, this.aotOptions);\n    this._reflector = reflector;\n    return this._aotCompiler = compiler;\n  }\n\n  private createDiagnosticProgram() {\n    // Create a program that is all the files from the original program plus the factories.\n    const existingFiles = this.program.getSourceFiles().map(source => source.fileName);\n    const host = new TypeCheckingHost(this.compilerHost, this.program, this.factories);\n    return this._diagnosticProgram =\n               ts.createProgram([...existingFiles, ...this.factoryNames], this.tsOptions, host);\n  }\n\n  private createFactories() {\n    // Create all the factory files with enough information to map the diagnostics reported for the\n    // created file back to the original source.\n    const emitter = new TypeScriptEmitter();\n    const factorySources =\n        this.generatedFiles.filter(file => file.stmts != null && file.stmts.length)\n            .map<[string, FactoryInfo]>(\n                file => [file.genFileUrl, createFactoryInfo(emitter, file)]);\n    this._factories = new Map(factorySources);\n    this._factoryNames = Array.from(this._factories.keys());\n    return this._factories;\n  }\n\n  private createDiagnosticsByFile() {\n    // Collect all the diagnostics binned by original source file name.\n    const result = new Map<string, Diagnostic[]>();\n    const diagnosticsFor = (fileName: string) => {\n      let r = result.get(fileName);\n      if (!r) {\n        r = [];\n        result.set(fileName, r);\n      }\n      return r;\n    };\n    const program = this.diagnosticProgram;\n    for (const factoryName of this.factoryNames) {\n      if (this._currentCancellationToken.isCancellationRequested()) return result;\n      const sourceFile = program.getSourceFile(factoryName);\n      for (const diagnostic of this.diagnosticProgram.getSemanticDiagnostics(sourceFile)) {\n        const span = this.sourceSpanOf(diagnostic.file, diagnostic.start, diagnostic.length);\n        if (span) {\n          const fileName = span.start.file.url;\n          const diagnosticsList = diagnosticsFor(fileName);\n          diagnosticsList.push({\n            message: diagnosticMessageToString(diagnostic.messageText),\n            category: diagnosticCategoryConverter(diagnostic.category), span\n          });\n        }\n      }\n    }\n    return result;\n  }\n\n  private sourceSpanOf(source: ts.SourceFile, start: number, length: number): ParseSourceSpan|null {\n    // Find the corresponding TypeScript node\n    const info = this.factories.get(source.fileName);\n    if (info) {\n      const {line, character} = ts.getLineAndCharacterOfPosition(source, start);\n      return info.context.spanOf(line, character);\n    }\n    return null;\n  }\n}\n\nfunction diagnosticMessageToString(message: ts.DiagnosticMessageChain | string): string {\n  return ts.flattenDiagnosticMessageText(message, '\\n');\n}\n\nfunction diagnosticCategoryConverter(kind: ts.DiagnosticCategory) {\n  // The diagnostics kind matches ts.DiagnosticCategory. Review this code if this changes.\n  return kind as any as DiagnosticCategory;\n}\n\nfunction createFactoryInfo(emitter: TypeScriptEmitter, file: GeneratedFile): FactoryInfo {\n  const {sourceText, context} =\n      emitter.emitStatementsAndContext(file.srcFileUrl, file.genFileUrl, file.stmts !);\n  const source = ts.createSourceFile(\n      file.genFileUrl, sourceText, ts.ScriptTarget.Latest, /* setParentNodes */ true);\n  return {source, context};\n}\n\nclass TypeCheckingHost implements ts.CompilerHost {\n  constructor(\n      private host: ts.CompilerHost, private originalProgram: ts.Program,\n      private factories: Map<string, FactoryInfo>) {}\n\n  getSourceFile(\n      fileName: string, languageVersion: ts.ScriptTarget,\n      onError?: ((message: string) => void)): ts.SourceFile {\n    const originalSource = this.originalProgram.getSourceFile(fileName);\n    if (originalSource) {\n      return originalSource;\n    }\n    const factoryInfo = this.factories.get(fileName);\n    if (factoryInfo) {\n      return factoryInfo.source;\n    }\n    return this.host.getSourceFile(fileName, languageVersion, onError);\n  }\n\n  getDefaultLibFileName(options: ts.CompilerOptions): string {\n    return this.host.getDefaultLibFileName(options);\n  }\n\n  writeFile: ts.WriteFileCallback =\n      () => { throw new Error('Unexpected write in diagnostic program'); }\n\n  getCurrentDirectory(): string {\n    return this.host.getCurrentDirectory();\n  }\n\n  getDirectories(path: string): string[] { return this.host.getDirectories(path); }\n\n  getCanonicalFileName(fileName: string): string {\n    return this.host.getCanonicalFileName(fileName);\n  }\n\n  useCaseSensitiveFileNames(): boolean { return this.host.useCaseSensitiveFileNames(); }\n\n  getNewLine(): string { return this.host.getNewLine(); }\n\n  fileExists(fileName: string): boolean {\n    return this.factories.has(fileName) || this.host.fileExists(fileName);\n  }\n\n  readFile(fileName: string): string {\n    const factoryInfo = this.factories.get(fileName);\n    return (factoryInfo && factoryInfo.source.text) || this.host.readFile(fileName);\n  }\n}\n"]}
(3-3/15)