IDEA shows the method as in use when it is not

Why IDEA shows this SimpleClass.start method as used:

enter image description here

Even if it is not. Changing the method name to something else then strips it out if it is not used:

enter image description here

It seems to be happening not only with start , but also init and stop for the ones I tried. I am using version 13.1.4 on Windows.

+1
source share
1 answer

This is a performance optimization.

  • Basically IntelliJ IDEA first checks its index for a method name .
  • He then checks each event in the file to see if this is actually a use for this method.
  • If the method name is used in many places , many files must be analyzed and verified. To avoid taking too much time and the processor for this, the check is skipped if the index has more than a certain number of entries, and suggests that the method is used (since the probability is very high).
  • Performing a check for an unused ad in batch mode ( Analyze > Run Inspection by Name... ) will still report the method as not being used .
+3
source

Source: https://habr.com/ru/post/1273512/


All Articles