refactor(language-service): ensure compatibility with noImplicitOverride (#42512)
Adds the `override` keyword to the `language-service` sources to ensure compatibility with `noImplicitOverride`. PR Close #42512
This commit is contained in:
parent
388496c17d
commit
368576b045
|
@ -142,11 +142,22 @@ export interface TwoWayBindingContext {
|
||||||
nodes: [t.BoundAttribute, t.BoundEvent];
|
nodes: [t.BoundAttribute, t.BoundEvent];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Special marker AST that can be used when the cursor is within the `sourceSpan` but not
|
||||||
|
* the key or value span of a node with key/value spans.
|
||||||
|
*/
|
||||||
|
class OutsideKeyValueMarkerAst extends e.AST {
|
||||||
|
visit(): null {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This special marker is added to the path when the cursor is within the sourceSpan but not the key
|
* This special marker is added to the path when the cursor is within the sourceSpan but not the key
|
||||||
* or value span of a node with key/value spans.
|
* or value span of a node with key/value spans.
|
||||||
*/
|
*/
|
||||||
const OUTSIDE_K_V_MARKER = new e.AST(new ParseSpan(-1, -1), new e.AbsoluteSourceSpan(-1, -1));
|
const OUTSIDE_K_V_MARKER =
|
||||||
|
new OutsideKeyValueMarkerAst(new ParseSpan(-1, -1), new e.AbsoluteSourceSpan(-1, -1));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the template AST node or expression AST node that most accurately
|
* Return the template AST node or expression AST node that most accurately
|
||||||
|
@ -415,7 +426,7 @@ class ExpressionVisitor extends e.RecursiveAstVisitor {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
visit(node: e.AST, path: Array<t.Node|e.AST>) {
|
override visit(node: e.AST, path: Array<t.Node|e.AST>) {
|
||||||
if (node instanceof e.ASTWithSource) {
|
if (node instanceof e.ASTWithSource) {
|
||||||
// In order to reduce noise, do not include `ASTWithSource` in the path.
|
// In order to reduce noise, do not include `ASTWithSource` in the path.
|
||||||
// For the purpose of source spans, there is no difference between
|
// For the purpose of source spans, there is no difference between
|
||||||
|
|
|
@ -408,23 +408,23 @@ class ExpressionVisitor extends NullTemplateVisitor {
|
||||||
return Array.from(this.completions.values());
|
return Array.from(this.completions.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
visitDirectiveProperty(ast: BoundDirectivePropertyAst): void {
|
override visitDirectiveProperty(ast: BoundDirectivePropertyAst): void {
|
||||||
this.processExpressionCompletions(ast.value);
|
this.processExpressionCompletions(ast.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
visitElementProperty(ast: BoundElementPropertyAst): void {
|
override visitElementProperty(ast: BoundElementPropertyAst): void {
|
||||||
this.processExpressionCompletions(ast.value);
|
this.processExpressionCompletions(ast.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
visitEvent(ast: BoundEventAst): void {
|
override visitEvent(ast: BoundEventAst): void {
|
||||||
this.processExpressionCompletions(ast.handler);
|
this.processExpressionCompletions(ast.handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
visitElement(): void {
|
override visitElement(): void {
|
||||||
// no-op for now
|
// no-op for now
|
||||||
}
|
}
|
||||||
|
|
||||||
visitAttr(ast: AttrAst) {
|
override visitAttr(ast: AttrAst) {
|
||||||
const binding = getBindingDescriptor(ast.name);
|
const binding = getBindingDescriptor(ast.name);
|
||||||
if (binding && binding.kind === ATTR.KW_MICROSYNTAX) {
|
if (binding && binding.kind === ATTR.KW_MICROSYNTAX) {
|
||||||
// This a template binding given by micro syntax expression.
|
// This a template binding given by micro syntax expression.
|
||||||
|
@ -459,7 +459,7 @@ class ExpressionVisitor extends NullTemplateVisitor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
visitReference(_ast: ReferenceAst, context: ElementAst) {
|
override visitReference(_ast: ReferenceAst, context: ElementAst) {
|
||||||
context.directives.forEach(dir => {
|
context.directives.forEach(dir => {
|
||||||
const {exportAs} = dir.directive;
|
const {exportAs} = dir.directive;
|
||||||
if (exportAs) {
|
if (exportAs) {
|
||||||
|
@ -469,7 +469,7 @@ class ExpressionVisitor extends NullTemplateVisitor {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
visitBoundText(ast: BoundTextAst) {
|
override visitBoundText(ast: BoundTextAst) {
|
||||||
if (inSpan(this.position, ast.value.sourceSpan)) {
|
if (inSpan(this.position, ast.value.sourceSpan)) {
|
||||||
const completions = getExpressionCompletions(
|
const completions = getExpressionCompletions(
|
||||||
this.getExpressionScope(), ast.value, this.position, this.info.template);
|
this.getExpressionScope(), ast.value, this.position, this.info.template);
|
||||||
|
|
|
@ -42,11 +42,11 @@ function getReferences(info: ng.DiagnosticTemplateInfo): SymbolDeclaration[] {
|
||||||
}
|
}
|
||||||
|
|
||||||
const visitor = new class extends RecursiveTemplateAstVisitor {
|
const visitor = new class extends RecursiveTemplateAstVisitor {
|
||||||
visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any): any {
|
override visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any): any {
|
||||||
super.visitEmbeddedTemplate(ast, context);
|
super.visitEmbeddedTemplate(ast, context);
|
||||||
processReferences(ast.references);
|
processReferences(ast.references);
|
||||||
}
|
}
|
||||||
visitElement(ast: ElementAst, context: any): any {
|
override visitElement(ast: ElementAst, context: any): any {
|
||||||
super.visitElement(ast, context);
|
super.visitElement(ast, context);
|
||||||
processReferences(ast.references);
|
processReferences(ast.references);
|
||||||
}
|
}
|
||||||
|
@ -257,38 +257,38 @@ class ExpressionDiagnosticsVisitor extends RecursiveTemplateAstVisitor {
|
||||||
this.path = new AstPath<TemplateAst>([]);
|
this.path = new AstPath<TemplateAst>([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
visitDirective(ast: DirectiveAst, context: any): any {
|
override visitDirective(ast: DirectiveAst, context: any): any {
|
||||||
// Override the default child visitor to ignore the host properties of a directive.
|
// Override the default child visitor to ignore the host properties of a directive.
|
||||||
if (ast.inputs && ast.inputs.length) {
|
if (ast.inputs && ast.inputs.length) {
|
||||||
templateVisitAll(this, ast.inputs, context);
|
templateVisitAll(this, ast.inputs, context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
visitBoundText(ast: BoundTextAst): void {
|
override visitBoundText(ast: BoundTextAst): void {
|
||||||
this.push(ast);
|
this.push(ast);
|
||||||
this.diagnoseExpression(ast.value, ast.sourceSpan.start.offset, false);
|
this.diagnoseExpression(ast.value, ast.sourceSpan.start.offset, false);
|
||||||
this.pop();
|
this.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
visitDirectiveProperty(ast: BoundDirectivePropertyAst): void {
|
override visitDirectiveProperty(ast: BoundDirectivePropertyAst): void {
|
||||||
this.push(ast);
|
this.push(ast);
|
||||||
this.diagnoseExpression(ast.value, this.attributeValueLocation(ast), false);
|
this.diagnoseExpression(ast.value, this.attributeValueLocation(ast), false);
|
||||||
this.pop();
|
this.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
visitElementProperty(ast: BoundElementPropertyAst): void {
|
override visitElementProperty(ast: BoundElementPropertyAst): void {
|
||||||
this.push(ast);
|
this.push(ast);
|
||||||
this.diagnoseExpression(ast.value, this.attributeValueLocation(ast), false);
|
this.diagnoseExpression(ast.value, this.attributeValueLocation(ast), false);
|
||||||
this.pop();
|
this.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
visitEvent(ast: BoundEventAst): void {
|
override visitEvent(ast: BoundEventAst): void {
|
||||||
this.push(ast);
|
this.push(ast);
|
||||||
this.diagnoseExpression(ast.handler, this.attributeValueLocation(ast), true);
|
this.diagnoseExpression(ast.handler, this.attributeValueLocation(ast), true);
|
||||||
this.pop();
|
this.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
visitVariable(ast: VariableAst): void {
|
override visitVariable(ast: VariableAst): void {
|
||||||
const directive = this.directiveSummary;
|
const directive = this.directiveSummary;
|
||||||
if (directive && ast.value) {
|
if (directive && ast.value) {
|
||||||
const context = this.info.query.getTemplateContext(directive.type.reference)!;
|
const context = this.info.query.getTemplateContext(directive.type.reference)!;
|
||||||
|
@ -304,13 +304,13 @@ class ExpressionDiagnosticsVisitor extends RecursiveTemplateAstVisitor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
visitElement(ast: ElementAst, context: any): void {
|
override visitElement(ast: ElementAst, context: any): void {
|
||||||
this.push(ast);
|
this.push(ast);
|
||||||
super.visitElement(ast, context);
|
super.visitElement(ast, context);
|
||||||
this.pop();
|
this.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any): any {
|
override visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any): any {
|
||||||
const previousDirectiveSummary = this.directiveSummary;
|
const previousDirectiveSummary = this.directiveSummary;
|
||||||
|
|
||||||
this.push(ast);
|
this.push(ast);
|
||||||
|
|
|
@ -17,7 +17,7 @@ type AstPath = AstPathBase<AST>;
|
||||||
function findAstAt(ast: AST, position: number, excludeEmpty: boolean = false): AstPath {
|
function findAstAt(ast: AST, position: number, excludeEmpty: boolean = false): AstPath {
|
||||||
const path: AST[] = [];
|
const path: AST[] = [];
|
||||||
const visitor = new class extends RecursiveAstVisitor {
|
const visitor = new class extends RecursiveAstVisitor {
|
||||||
visit(ast: AST) {
|
override visit(ast: AST) {
|
||||||
if ((!excludeEmpty || ast.sourceSpan.start < ast.sourceSpan.end) &&
|
if ((!excludeEmpty || ast.sourceSpan.start < ast.sourceSpan.end) &&
|
||||||
inSpan(position, ast.sourceSpan)) {
|
inSpan(position, ast.sourceSpan)) {
|
||||||
const isNotNarrower = path.length && !isNarrower(ast.span, path[path.length - 1].span);
|
const isNotNarrower = path.length && !isNarrower(ast.span, path[path.length - 1].span);
|
||||||
|
|
|
@ -258,28 +258,28 @@ function findParentOfBinding(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any): any {
|
override visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any): any {
|
||||||
return this.visitChildren(context, visit => {
|
return this.visitChildren(context, visit => {
|
||||||
visit(ast.directives);
|
visit(ast.directives);
|
||||||
visit(ast.children);
|
visit(ast.children);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
visitElement(ast: ElementAst, context: any): any {
|
override visitElement(ast: ElementAst, context: any): any {
|
||||||
return this.visitChildren(context, visit => {
|
return this.visitChildren(context, visit => {
|
||||||
visit(ast.directives);
|
visit(ast.directives);
|
||||||
visit(ast.children);
|
visit(ast.children);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
visitDirective(ast: DirectiveAst) {
|
override visitDirective(ast: DirectiveAst) {
|
||||||
const result = this.visitChildren(ast, visit => {
|
const result = this.visitChildren(ast, visit => {
|
||||||
visit(ast.inputs);
|
visit(ast.inputs);
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
visitDirectiveProperty(ast: BoundDirectivePropertyAst, context: DirectiveAst) {
|
override visitDirectiveProperty(ast: BoundDirectivePropertyAst, context: DirectiveAst) {
|
||||||
if (ast === binding) {
|
if (ast === binding) {
|
||||||
res = context;
|
res = context;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ import {AstResult, Declaration, DeclarationError, DiagnosticMessageChain, Langua
|
||||||
* syntactically incorrect templates.
|
* syntactically incorrect templates.
|
||||||
*/
|
*/
|
||||||
export class DummyHtmlParser extends HtmlParser {
|
export class DummyHtmlParser extends HtmlParser {
|
||||||
parse(): ParseTreeResult {
|
override parse(): ParseTreeResult {
|
||||||
return new ParseTreeResult([], []);
|
return new ParseTreeResult([], []);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -351,7 +351,7 @@ class TypeWrapper implements Symbol {
|
||||||
// If stringIndexType a primitive type(e.g. 'string'), the Symbol is undefined;
|
// If stringIndexType a primitive type(e.g. 'string'), the Symbol is undefined;
|
||||||
// and in AstType.resolvePropertyRead method, the Symbol.type should get the right type.
|
// and in AstType.resolvePropertyRead method, the Symbol.type should get the right type.
|
||||||
class StringIndexTypeWrapper extends TypeWrapper {
|
class StringIndexTypeWrapper extends TypeWrapper {
|
||||||
public readonly type = new TypeWrapper(this.tsType, this.context);
|
public override readonly type = new TypeWrapper(this.tsType, this.context);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SymbolWrapper implements Symbol {
|
class SymbolWrapper implements Symbol {
|
||||||
|
|
|
@ -107,7 +107,7 @@ export function findTemplateAstAt(ast: TemplateAst[], position: number): Templat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any): any {
|
override visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any): any {
|
||||||
return this.visitChildren(context, visit => {
|
return this.visitChildren(context, visit => {
|
||||||
// Ignore reference, variable and providers
|
// Ignore reference, variable and providers
|
||||||
visit(ast.attrs);
|
visit(ast.attrs);
|
||||||
|
@ -116,7 +116,7 @@ export function findTemplateAstAt(ast: TemplateAst[], position: number): Templat
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
visitElement(ast: ElementAst, context: any): any {
|
override visitElement(ast: ElementAst, context: any): any {
|
||||||
return this.visitChildren(context, visit => {
|
return this.visitChildren(context, visit => {
|
||||||
// Ingnore providers
|
// Ingnore providers
|
||||||
visit(ast.attrs);
|
visit(ast.attrs);
|
||||||
|
@ -128,7 +128,7 @@ export function findTemplateAstAt(ast: TemplateAst[], position: number): Templat
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
visitDirective(ast: DirectiveAst, context: any): any {
|
override visitDirective(ast: DirectiveAst, context: any): any {
|
||||||
// Ignore the host properties of a directive
|
// Ignore the host properties of a directive
|
||||||
const result = this.visitChildren(context, visit => {
|
const result = this.visitChildren(context, visit => {
|
||||||
visit(ast.inputs);
|
visit(ast.inputs);
|
||||||
|
|
|
@ -180,7 +180,7 @@ export class DiagnosticContext {
|
||||||
};
|
};
|
||||||
const urlResolver = createOfflineCompileUrlResolver();
|
const urlResolver = createOfflineCompileUrlResolver();
|
||||||
const htmlParser = new class extends HtmlParser {
|
const htmlParser = new class extends HtmlParser {
|
||||||
parse(): ParseTreeResult {
|
override parse(): ParseTreeResult {
|
||||||
return new ParseTreeResult([], []);
|
return new ParseTreeResult([], []);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue