@glimmer/syntax
Version:
45 lines (44 loc) • 1.92 kB
TypeScript
import type { PrecompileOptions, PrecompileOptionsWithLexicalScope } from '../parser/tokenizer-event-handlers';
import type { SourceLocation } from '../source/location';
import type { Source } from '../source/source';
import type { SourceSpan } from '../source/span';
import type { BlockSymbolTable } from '../symbol-table';
import type * as ASTv1 from '../v1/api';
import type { Resolution } from './loose-resolution';
import { SymbolTable } from '../symbol-table';
import * as ASTv2 from './api';
import { Builder } from './builders';
export declare function normalize(source: Source, options?: PrecompileOptionsWithLexicalScope): [ast: ASTv2.Template, locals: string[]];
/**
* A `BlockContext` represents the block that a particular AST node is contained inside of.
*
* `BlockContext` is aware of template-wide options (such as strict mode), as well as the bindings
* that are in-scope within that block.
*
* Concretely, it has the `PrecompileOptions` and current `SymbolTable`, and provides
* facilities for working with those options.
*
* `BlockContext` is stateless.
*/
export declare class BlockContext<Table extends SymbolTable = SymbolTable> {
readonly source: Source;
private readonly options;
readonly table: Table;
readonly builder: Builder;
constructor(source: Source, options: PrecompileOptions, table: Table);
get strict(): boolean;
loc(loc: SourceLocation): SourceSpan;
resolutionFor<N extends ASTv1.CallNode | ASTv1.PathExpression>(node: N, resolution: Resolution<N>): {
result: ASTv2.FreeVarResolution;
} | {
result: 'error';
path: string;
head: string;
};
isLexicalVar(variable: string): boolean;
isKeyword(name: string): boolean;
private isFreeVar;
hasBinding(name: string): boolean;
child(blockParams: string[]): BlockContext<BlockSymbolTable>;
customizeComponentName(input: string): string;
}