refactor(ivy): use absolute source spans in type checker (#34417)
Previously, the type checker would compute an absolute source span by combining an expression AST node's `ParseSpan` (relative to the start of the expression) together with the absolute offset of the expression as represented in a `ParseSourceSpan`, to arrive at a span relative to the start of the file. This information is now directly available on an expression AST node in the `AST.sourceSpan` property, which can be used instead. PR Close #34417
This commit is contained in:
@ -30,7 +30,7 @@ export class AST {
|
||||
/**
|
||||
* Absolute location of the expression AST in a source code file.
|
||||
*/
|
||||
public sourceSpan: Readonly<AbsoluteSourceSpan>) {}
|
||||
public sourceSpan: AbsoluteSourceSpan) {}
|
||||
visit(visitor: AstVisitor, context: any = null): any { return null; }
|
||||
toString(): string { return 'AST'; }
|
||||
}
|
||||
@ -145,7 +145,7 @@ export class KeyedWrite extends AST {
|
||||
export class BindingPipe extends AST {
|
||||
constructor(
|
||||
span: ParseSpan, sourceSpan: AbsoluteSourceSpan, public exp: AST, public name: string,
|
||||
public args: any[], public nameSpan: ParseSpan) {
|
||||
public args: any[], public nameSpan: AbsoluteSourceSpan) {
|
||||
super(span, sourceSpan);
|
||||
}
|
||||
visit(visitor: AstVisitor, context: any = null): any { return visitor.visitPipe(this, context); }
|
||||
|
@ -359,7 +359,7 @@ export class _ParseAST {
|
||||
do {
|
||||
const nameStart = this.inputIndex;
|
||||
const name = this.expectIdentifierOrKeyword();
|
||||
const nameSpan = this.span(nameStart);
|
||||
const nameSpan = this.sourceSpan(nameStart);
|
||||
const args: AST[] = [];
|
||||
while (this.optionalCharacter(chars.$COLON)) {
|
||||
args.push(this.parseExpression());
|
||||
|
Reference in New Issue
Block a user