I have a similar problem I'm trying to work with.
I discovered two situations where I know this is happening, and found a way around one of them.
Scenario 1) The class refers to the class in the path to the chain further down the chain than the one also found in the bank, however, in the import statement, the import statement has the form
import com.company.classes.to.use.*
By combining them, the IDE seems to take all the classes in this package from the same jar location. By dividing them into separate import class instructions, the IDE will select them separately.
Scenario 2). You are cool chaining methods for an overridden class.
something.getSomethingElse().getAnotherThing().getYetAnotherThing();
if getSomethingElse () returns an object that is not different in the class (so you do not need to import it), you will still get an error. (When adding imports, the line is grayed out because it recognizes that it is not in use, so it does not help). In any case, I would not indulge in this method.
edit: An obvious alternative to this is code refactoring for line breaks to
ObjectToImport obj = something.getSomethingElse(); result = obj.getAnotherThing.getYetAnotherThing();
And then import the temporary variable ...
Obviously, this is not ideal, and you should not reorganize your code for the sake of your development environment, but you need to, these red lines annoy me.
I hope this helps. If you have found the best solution, please share!
Regards, M