fix(language-service): Diagnostic span should point to class name (#34932)

Right now, if an Angular diagnostic is generated for a TypeScript node,
the span points to the decorator Identifier, i.e. the Identifier node
like `@NgModule`, `@Component`, etc.
This is weird. It should point to the class name instead.
Note, we do not have a more fine-grained breakdown of the span when
diagnostics are emitted, this work remains to be done.

PR Close #34932
This commit is contained in:
Keen Yee Liau
2020-01-23 12:02:47 -08:00
committed by Andrew Kushnir
parent 37727ce898
commit c9db7bdb8a
4 changed files with 18 additions and 24 deletions

View File

@ -28,10 +28,10 @@ describe('getDirectiveClassLike()', () => {
}
});
expect(result).toBeTruthy();
const {decoratorId, classDecl} = result !;
const {decoratorId, classId} = result !;
expect(decoratorId.kind).toBe(ts.SyntaxKind.Identifier);
expect((decoratorId as ts.Identifier).text).toBe('NgModule');
expect(classDecl.name !.text).toBe('AppModule');
expect(decoratorId.text).toBe('NgModule');
expect(classId.text).toBe('AppModule');
});
});