當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript source_map_util.originalPositionFor函數代碼示例

本文整理匯總了TypeScript中@angular/compiler/testing/src/output/source_map_util.originalPositionFor函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript originalPositionFor函數的具體用法?TypeScript originalPositionFor怎麽用?TypeScript originalPositionFor使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了originalPositionFor函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

      it('should map non template parts to the factory file', () => {
        appDir['app.component.ts'] = createComponentSource(templateDecorator('Hello World!'));

        const genFile = compileApp();
        const genSource = toTypeScript(genFile);
        const sourceMap = extractSourceMap(genSource) !;
        expect(originalPositionFor(sourceMap, {line: 1, column: 0}))
            .toEqual({line: 1, column: 0, source: ngFactoryPath});
      });
開發者ID:DeepanParikh,項目名稱:angular,代碼行數:9,代碼來源:compiler_spec.ts

示例2: expectMap

// All lines / columns indexes are 0-based
// Note: source-map line indexes are 1-based, column 0-based
function expectMap(
    ctx: EmitterVisitorContext, genLine: number, genCol: number, source: string | null = null,
    srcLine: number | null = null, srcCol: number | null = null) {
  const sm = ctx.toSourceMapGenerator('o.ts').toJSON() !;
  const genPosition = {line: genLine + 1, column: genCol};
  const origPosition = originalPositionFor(sm, genPosition);
  expect(origPosition.source).toEqual(source);
  expect(origPosition.line).toEqual(srcLine === null ? null : srcLine + 1);
  expect(origPosition.column).toEqual(srcCol);
}
開發者ID:IdeaBlade,項目名稱:angular,代碼行數:12,代碼來源:abstract_emitter_node_only_spec.ts

示例3: it

      it('should be able to shift the content', () => {
        ctx.print(createSourceSpan(fileA, 0), 'fileA-0');

        const sm = ctx.toSourceMapGenerator('o.ts', 10).toJSON() !;
        expect(originalPositionFor(sm, {line: 11, column: 0})).toEqual({
          line: 1,
          column: 0,
          source: 'a.js',
        });
      });
開發者ID:IdeaBlade,項目名稱:angular,代碼行數:10,代碼來源:abstract_emitter_node_only_spec.ts

示例4: it

      it('should emit an inline source map', () => {
        const source = new ParseSourceFile(';;;var', 'in.js');
        const startLocation = new ParseLocation(source, 0, 0, 3);
        const endLocation = new ParseLocation(source, 7, 0, 6);
        const sourceSpan = new ParseSourceSpan(startLocation, endLocation);
        const someVar = o.variable('someVar', null, sourceSpan);
        const sm = emitSourceMap(someVar.toStmt(), '/* MyPreamble \n */');

        expect(sm.sources).toEqual([someGenFilePath, 'in.js']);
        expect(sm.sourcesContent).toEqual([' ', ';;;var']);
        expect(originalPositionFor(sm, {line: 3, column: 0}))
            .toEqual({line: 1, column: 3, source: 'in.js'});
      });
開發者ID:Cammisuli,項目名稱:angular,代碼行數:13,代碼來源:ts_emitter_node_only_spec.ts


注:本文中的@angular/compiler/testing/src/output/source_map_util.originalPositionFor函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。