本文整理汇总了TypeScript中@angular/compiler/src/output/abstract_emitter.EmitterVisitorContext类的典型用法代码示例。如果您正苦于以下问题:TypeScript EmitterVisitorContext类的具体用法?TypeScript EmitterVisitorContext怎么用?TypeScript EmitterVisitorContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EmitterVisitorContext类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: nbSegmentsPerLine
// returns the number of segments per line
function nbSegmentsPerLine(ctx: EmitterVisitorContext) {
const sm = ctx.toSourceMapGenerator('o.ts').toJSON() !;
const lines = sm.mappings.split(';');
return lines.map(l => {
const m = l.match(/,/g);
return m === null ? 1 : m.length + 1;
});
}
开发者ID:IdeaBlade,项目名称:angular,代码行数:9,代码来源:abstract_emitter_node_only_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 generate unique argument names', () => {
const externalIds = new Array(10).fill(1).map(
(_, index) =>
new o.ExternalReference(anotherModuleUrl, `id_${index}_`, {name: `id_${index}_`}));
const externalIds1 = new Array(10).fill(1).map(
(_, index) => new o.ExternalReference(
anotherModuleUrl, `id_${index}_1`, {name: `id_${index}_1`}));
const ctx = EmitterVisitorContext.createRoot();
const converter = new JitEmitterVisitor(new JitReflector());
converter.visitAllStatements(
[o.literalArr([...externalIds1, ...externalIds].map(id => o.importExpr(id))).toStmt()],
ctx);
const args = converter.getArgs();
expect(Object.keys(args).length).toBe(20);
});
开发者ID:AnthonyPAlicea,项目名称:angular,代码行数:15,代码来源:output_jit_spec.ts
示例4: it
it('should map leading segment without span', () => {
ctx.print(null, '....');
ctx.print(createSourceSpan(fileA, 0), 'fileA-0');
expectMap(ctx, 0, 0, 'o.ts', 0, 0);
expectMap(ctx, 0, 4, 'a.js', 0, 0);
expect(nbSegmentsPerLine(ctx)).toEqual([2]);
});
开发者ID:IdeaBlade,项目名称:angular,代码行数:8,代码来源:abstract_emitter_node_only_spec.ts
示例5: it
it('should be able to shift the content', () => {
ctx.print(createSourceSpan(fileA, 0), 'fileA-0');
const sm = ctx.toSourceMapGenerator(null, 10).toJSON();
const smc = new SourceMapConsumer(sm);
expect(smc.originalPositionFor({line: 11, column: 0})).toEqual({
line: 1,
column: 0,
source: 'a.js',
name: null,
});
});
开发者ID:manekinekko,项目名称:angular,代码行数:12,代码来源:abstract_emitter_node_only_spec.ts
注:本文中的@angular/compiler/src/output/abstract_emitter.EmitterVisitorContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论