intellij-idea

Is there a way to show all usage of a specific method (CTRL + Click) including those that are commented out?


If the simple CTRL + Click (Windows) or any other short key configuration is not possible, how else can I see all usage of a specific method including those in commented out blocks?

I could not find anything related to above post. The closest thing I found was a generic commented code search: Edit > Find > Search Structurally... or another generic analysis of: Code -> Analyze Code -> Run Inspection by Name.


Solution

  • This is not possible due to the nature of find usages. It works by resolving references to PSI (Program Structure Interface) elements, which are elements generated by the parser. Usually, a comment in its entirety is a PSI element so resolving references (and thus find usages) is generally not available on a part of a comment. Resolving a WebReference (Ctrl + Click on a url) in a comment is a special case.

    This seems fairly reasonable given that including comments in the PSI structure is almost nearly impossible, as comments can contain anything and its contents don't have to follow the syntax of the language outside the comments. It probably can be done, but it is definitely not worth the hassle since commented out code is considered to be bad practice anyway.