Typescript: Angular decorators in class causes u-ctags not to index its methods
If TypeScript class has Angular dedocators like: @Input(), @Output() and @ViewChild() u-ctags won't index its methods. If in below example those three decorators are removed, u-tags produces correct result which is in expected results. List of Angular decorators.
The name of the parser: TypeScript
The command line you used to run ctags:
$ ctags --options=NONE example.ts
The content of input file:
export class exampleClass implements OnInit, AfterViewInit {
@Input() public id: string = '';
@Output() eventEmitter = new EventEmitter<string>();
@ViewChild('sortArchived', { static: false }) sortArchived = new MatSort();
constructor(
) {
}
ngOnInit() {
}
ngAfterViewInit(): void {
}
public method1(filterValue: string) {
}
testMethod(testparameter: number): Promise<Object> {
}
private static method3(data: ObjectType, filter: string): boolean {
}
private method4() {
}
}
The tags output you are not satisfied with:
I don't see any method lines.
The tags output you expect:
constructor example.ts /^ constructor($/;" m class:exampleClass
exampleClass example.ts /^export class exampleClass implements OnInit, AfterViewInit {$/;" c
method1 example.ts /^ public method1(filterValue: string) {$/;" m class:exampleClass
method3 example.ts /^ private static method3(data: ObjectType, filter: string): boolean {$/;" m class:exampleClass
method4 example.ts /^ private method4() {$/;" m class:exampleClass
ngAfterViewInit example.ts /^ ngAfterViewInit(): void {$/;" m class:exampleClass
ngOnInit example.ts /^ ngOnInit() {$/;" m class:exampleClass
testMethod example.ts /^ testMethod(testparameter: number): Promise<Object> {$/;" m class:exampleClass
The version of ctags:
$ ctags --version
Universal Ctags 6.0.0, Copyright (C) 2015-2022 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
Compiled: Feb 1 2023, 00:00:00
URL: https://ctags.io/
Output version: 0.0
Optional compiled features: +wildcards, +regex, +iconv, +option-directory, +xpath, +json, +interactive, +sandbox, +yaml, +packcc, +optscript
How do you get ctags binary:
binary from official Fedora 38 system repository
@ksamborski, @masatake: As far as I see the issue is a special case of https://stackoverflow.com/questions/79173092/ctags-ignores-typescript-class-members-after-class-member-inline-initialization and is not caused by the decorators but by the inline initializations with function calls. The tags file produced by "ctags --languages=typescript example.ts" (I've ommited the comments at the beginning of the tags file):
eventEmitter example.ts /^ @Output() eventEmitter = new EventEmitter<string>();$/;" p class:exampleClass exampleClass example.ts /^export class exampleClass implements OnInit, AfterViewInit {$/;" c id example.ts /^ @Input() public id: string = '';$/;" p class:exampleClass
This means that all class members after the first inline intialized member (in this case eventEmitter) are not taged.
If you omit the trailing () in the two inline intializations, i.e.
@Output() eventEmitter = new EventEmitter<string>; @ViewChild('sortArchived', { static: false }) sortArchived = new MatSort;
all tags will be generated.
Perhaps the title of this issue should be changed to somewhat like in the stackoverflow question mentioned above, i.e. "ctags ignores typescript class members after class member inline initialization with function call"