perf(language-service): Skip Angular analysis when quick info requested outside a template (#40956)
The Angular LS does not provide quick info when the given position is not inside a template. As an optimization, we can quickly look at the file and determine if we are at a position that is part of an Angular template. If not, we bail before asking the compiler for any more information. Note that the Angular LS _already_ provides no quick info when outside a template file, but currently asks the compiler to analyze the program before it determines that information. PR Close #40956
This commit is contained in:
parent
49e02ca7d6
commit
ad38cbbe09
|
@ -96,7 +96,11 @@ export class LanguageService {
|
|||
}
|
||||
|
||||
getQuickInfoAtPosition(fileName: string, position: number): ts.QuickInfo|undefined {
|
||||
const compiler = this.compilerFactory.getOrCreate();
|
||||
return this.withCompiler((compiler) => {
|
||||
if (!isTemplateContext(compiler.getNextProgram(), fileName, position)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const templateInfo = getTemplateInfoAtPosition(fileName, position, compiler);
|
||||
if (templateInfo === undefined) {
|
||||
return undefined;
|
||||
|
@ -112,9 +116,8 @@ export class LanguageService {
|
|||
const node = positionDetails.context.kind === TargetNodeKind.TwoWayBindingContext ?
|
||||
positionDetails.context.nodes[0] :
|
||||
positionDetails.context.node;
|
||||
const results = new QuickInfoBuilder(this.tsLS, compiler, templateInfo.component, node).get();
|
||||
this.compilerFactory.registerLastKnownProgram();
|
||||
return results;
|
||||
return new QuickInfoBuilder(this.tsLS, compiler, templateInfo.component, node).get();
|
||||
});
|
||||
}
|
||||
|
||||
getReferencesAtPosition(fileName: string, position: number): ts.ReferenceEntry[]|undefined {
|
||||
|
|
Loading…
Reference in New Issue