refactor(language-service): find expression ASTs using absolute spans (#33387)
Moves to using the absolute span of an expression AST (relative to an entire template) rather than a relative span (relative to the start of the expression) to find an expression AST given a position in a template. This is part of the changes needed to support text replacement in templates (#33091). PR Close #33387
This commit is contained in:

committed by
Andrew Kushnir

parent
3f195fefa9
commit
ee4fc12e42
@ -39,11 +39,10 @@ export function locateSymbol(info: AstResult, position: number): SymbolInfo|unde
|
||||
const dinfo = diagnosticInfoFromTemplateInfo(info);
|
||||
const scope = getExpressionScope(dinfo, path, inEvent);
|
||||
if (attribute.valueSpan) {
|
||||
const expressionOffset = attribute.valueSpan.start.offset;
|
||||
const result = getExpressionSymbol(
|
||||
scope, ast, templatePosition - expressionOffset, info.template.query);
|
||||
const result = getExpressionSymbol(scope, ast, templatePosition, info.template.query);
|
||||
if (result) {
|
||||
symbol = result.symbol;
|
||||
const expressionOffset = attribute.valueSpan.start.offset;
|
||||
span = offsetSpan(result.span, expressionOffset);
|
||||
}
|
||||
}
|
||||
@ -116,7 +115,7 @@ export function locateSymbol(info: AstResult, position: number): SymbolInfo|unde
|
||||
const dinfo = diagnosticInfoFromTemplateInfo(info);
|
||||
const scope = getExpressionScope(dinfo, path, /* includeEvent */ false);
|
||||
const result =
|
||||
getExpressionSymbol(scope, ast.value, expressionPosition, info.template.query);
|
||||
getExpressionSymbol(scope, ast.value, templatePosition, info.template.query);
|
||||
if (result) {
|
||||
symbol = result.symbol;
|
||||
span = offsetSpan(result.span, ast.sourceSpan.start.offset);
|
||||
|
Reference in New Issue
Block a user