antlr / intellij-plugin-v4

An IntelliJ plugin for ANTLR v4
https://plugins.jetbrains.com/plugin/7358-antlr-v4
BSD 3-Clause "New" or "Revised" License
462 stars 103 forks source link

Go To -> Declaration or Usages from declaration should not include the declaration #629

Closed TysonMN closed 12 months ago

TysonMN commented 1 year ago

This behavior is for version 1.20, which is currently the latest.

Summary

A rule declaration is included in the results when selecting Go To -> Declaration or Usages from the context-sensitive menu of a rule declaration. This behavior prevents IntelliJ from navigating from a declaration to a usage when there is only one usage.

Steps to reproduce

  1. Find or create a rule with only a single usage.
  2. Select Go To -> Declaration or Usages from the context-sensitive menu of the declaration.
Screenshot 2023-04-16 at 8 53 58 AM

Actual behavior

A popup containing two search results is displayed. The two search results are the declaration and the usage.

Screenshot 2023-04-16 at 8 54 14 AM

Expected behavior

Contrast this behavior with the behavior when performing the same steps on Java code.

Screenshot 2023-04-16 at 8 31 05 AM

The behavior on Java code is that IntelliJ navigates from the declaration to the usage.

Screenshot 2023-04-16 at 8 31 22 AM

Intended behavior?

The heading "Expected behavior" is referring to the behavior that I expected. I wonder though if the actual behavior is the behavior intended by the ANTLR plugin maintainers. In the jetbrains-plugin-sample repository, this javadoc comment says

we want defs to be included in "find usages."

I don't think definitions/declarations should be included in the list of usages, but I can understand if others think they should be included.