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];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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
|
||||
|
@ -415,7 +426,7 @@ class ExpressionVisitor extends e.RecursiveAstVisitor {
|
|||
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) {
|
||||
// In order to reduce noise, do not include `ASTWithSource` in the path.
|
||||
// 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());
|
||||
}
|
||||
|
||||
visitDirectiveProperty(ast: BoundDirectivePropertyAst): void {
|
||||
override visitDirectiveProperty(ast: BoundDirectivePropertyAst): void {
|
||||
this.processExpressionCompletions(ast.value);
|
||||
}
|
||||
|
||||
visitElementProperty(ast: BoundElementPropertyAst): void {
|
||||
override visitElementProperty(ast: BoundElementPropertyAst): void {
|
||||
this.processExpressionCompletions(ast.value);
|
||||
}
|
||||
|
||||
visitEvent(ast: BoundEventAst): void {
|
||||
override visitEvent(ast: BoundEventAst): void {
|
||||
this.processExpressionCompletions(ast.handler);
|
||||
}
|
||||
|
||||
visitElement(): void {
|
||||
override visitElement(): void {
|
||||
// no-op for now
|
||||
}
|
||||
|
||||
visitAttr(ast: AttrAst) {
|
||||
override visitAttr(ast: AttrAst) {
|
||||
const binding = getBindingDescriptor(ast.name);
|
||||
if (binding && binding.kind === ATTR.KW_MICROSYNTAX) {
|
||||
// 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 => {
|
||||
const {exportAs} = dir.directive;
|
||||
if (exportAs) {
|
||||
|
@ -469,7 +469,7 @@ class ExpressionVisitor extends NullTemplateVisitor {
|
|||
});
|
||||
}
|
||||
|
||||
visitBoundText(ast: BoundTextAst) {
|
||||
override visitBoundText(ast: BoundTextAst) {
|
||||
if (inSpan(this.position, ast.value.sourceSpan)) {
|
||||
const completions = getExpressionCompletions(
|
||||
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 {
|
||||
visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any): any {
|
||||
override visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any): any {
|
||||
super.visitEmbeddedTemplate(ast, context);
|
||||
processReferences(ast.references);
|
||||
}
|
||||
visitElement(ast: ElementAst, context: any): any {
|
||||
override visitElement(ast: ElementAst, context: any): any {
|
||||
super.visitElement(ast, context);
|
||||
processReferences(ast.references);
|
||||
}
|
||||
|
@ -257,38 +257,38 @@ class ExpressionDiagnosticsVisitor extends RecursiveTemplateAstVisitor {
|
|||
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.
|
||||
if (ast.inputs && ast.inputs.length) {
|
||||
templateVisitAll(this, ast.inputs, context);
|
||||
}
|
||||
}
|
||||
|
||||
visitBoundText(ast: BoundTextAst): void {
|
||||
override visitBoundText(ast: BoundTextAst): void {
|
||||
this.push(ast);
|
||||
this.diagnoseExpression(ast.value, ast.sourceSpan.start.offset, false);
|
||||
this.pop();
|
||||
}
|
||||
|
||||
visitDirectiveProperty(ast: BoundDirectivePropertyAst): void {
|
||||
override visitDirectiveProperty(ast: BoundDirectivePropertyAst): void {
|
||||
this.push(ast);
|
||||
this.diagnoseExpression(ast.value, this.attributeValueLocation(ast), false);
|
||||
this.pop();
|
||||
}
|
||||
|
||||
visitElementProperty(ast: BoundElementPropertyAst): void {
|
||||
override visitElementProperty(ast: BoundElementPropertyAst): void {
|
||||
this.push(ast);
|
||||
this.diagnoseExpression(ast.value, this.attributeValueLocation(ast), false);
|
||||
this.pop();
|
||||
}
|
||||
|
||||
visitEvent(ast: BoundEventAst): void {
|
||||
override visitEvent(ast: BoundEventAst): void {
|
||||
this.push(ast);
|
||||
this.diagnoseExpression(ast.handler, this.attributeValueLocation(ast), true);
|
||||
this.pop();
|
||||
}
|
||||
|
||||
visitVariable(ast: VariableAst): void {
|
||||
override visitVariable(ast: VariableAst): void {
|
||||
const directive = this.directiveSummary;
|
||||
if (directive && ast.value) {
|
||||
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);
|
||||
super.visitElement(ast, context);
|
||||
this.pop();
|
||||
}
|
||||
|
||||
visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any): any {
|
||||
override visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any): any {
|
||||
const previousDirectiveSummary = this.directiveSummary;
|
||||
|
||||
this.push(ast);
|
||||
|
|
|
@ -17,7 +17,7 @@ type AstPath = AstPathBase<AST>;
|
|||
function findAstAt(ast: AST, position: number, excludeEmpty: boolean = false): AstPath {
|
||||
const path: AST[] = [];
|
||||
const visitor = new class extends RecursiveAstVisitor {
|
||||
visit(ast: AST) {
|
||||
override visit(ast: AST) {
|
||||
if ((!excludeEmpty || ast.sourceSpan.start < ast.sourceSpan.end) &&
|
||||
inSpan(position, ast.sourceSpan)) {
|
||||
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 => {
|
||||
visit(ast.directives);
|
||||
visit(ast.children);
|
||||
});
|
||||
}
|
||||
|
||||
visitElement(ast: ElementAst, context: any): any {
|
||||
override visitElement(ast: ElementAst, context: any): any {
|
||||
return this.visitChildren(context, visit => {
|
||||
visit(ast.directives);
|
||||
visit(ast.children);
|
||||
});
|
||||
}
|
||||
|
||||
visitDirective(ast: DirectiveAst) {
|
||||
override visitDirective(ast: DirectiveAst) {
|
||||
const result = this.visitChildren(ast, visit => {
|
||||
visit(ast.inputs);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
visitDirectiveProperty(ast: BoundDirectivePropertyAst, context: DirectiveAst) {
|
||||
override visitDirectiveProperty(ast: BoundDirectivePropertyAst, context: DirectiveAst) {
|
||||
if (ast === binding) {
|
||||
res = context;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import {AstResult, Declaration, DeclarationError, DiagnosticMessageChain, Langua
|
|||
* syntactically incorrect templates.
|
||||
*/
|
||||
export class DummyHtmlParser extends HtmlParser {
|
||||
parse(): ParseTreeResult {
|
||||
override parse(): ParseTreeResult {
|
||||
return new ParseTreeResult([], []);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -351,7 +351,7 @@ class TypeWrapper implements Symbol {
|
|||
// 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.
|
||||
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 {
|
||||
|
|
|
@ -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 => {
|
||||
// Ignore reference, variable and providers
|
||||
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 => {
|
||||
// Ingnore providers
|
||||
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
|
||||
const result = this.visitChildren(context, visit => {
|
||||
visit(ast.inputs);
|
||||
|
|
|
@ -180,7 +180,7 @@ export class DiagnosticContext {
|
|||
};
|
||||
const urlResolver = createOfflineCompileUrlResolver();
|
||||
const htmlParser = new class extends HtmlParser {
|
||||
parse(): ParseTreeResult {
|
||||
override parse(): ParseTreeResult {
|
||||
return new ParseTreeResult([], []);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue