Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript: Angular decorators in class causes u-ctags not to index its methods #3827

Open
nkahe opened this issue Oct 5, 2023 · 1 comment
Assignees

Comments

@nkahe
Copy link

nkahe commented Oct 5, 2023

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
@nkahe nkahe changed the title Angular decorators in class causes u-ctags not to index it's methods Angular decorators in class causes u-ctags not to index its methods Oct 5, 2023
@nkahe nkahe changed the title Angular decorators in class causes u-ctags not to index its methods Angular decorators in Typescript class causes u-ctags not to index its methods Oct 5, 2023
@masatake masatake changed the title Angular decorators in Typescript class causes u-ctags not to index its methods Typescript: Angular decorators in class causes u-ctags not to index its methods Dec 18, 2023
@FrankL-git
Copy link

FrankL-git commented Nov 10, 2024

@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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants