FIRST-Tech-Challenge / SkyStone

FTC SDK
https://www.firstinspires.org/robotics/ftc/what-is-first-tech-challenge
275 stars 1.04k forks source link

Continually expanding import duplication when error is above first import line #172

Open lilyinstarlight opened 4 years ago

lilyinstarlight commented 4 years ago

In the current version of the RobotController application (5.3), a bug can be encountered when using the OnBotJava IDE and having a compiler error above all import lines. Depending on the error (seems to require passing the parser but not the compiler by my 5 second analysis -- i.e. proper grammar but doesn't otherwise make sense triggers it) then it will continually add detected imports at the first import and therefore below the error. The next time it analyzes imports, it will fail to see the current imports (since they are below the error) and add them again, once more below the error. The loops into infinity (unless autoimport is turned off in the settings) causing the file to grow every second or so.

I happened to notice this last Saturday helping a team and thinking the phone was actually haunted when restarting both the computer and phone did not help until I noticed the error above the imports. (They had accidentally pasted some random thing from the clipboard that looked like it could possibly be Java and not noticed.)

It can be quickly reproduced by loading up some sample code and typing error; above the first import. Let me know if you need more info but that seemed to cause the issue for me and the team I was working with.

Hopefully this is a simple fix even though I'm not sure you can just disable autoimport on errors since autoimport resolves undefined token errors. Perhaps if the line of the first error and the last import can be easily found, do not autoimport if the last import exists (implies any imports exist at all) and is at or below the error. Adding the error after the first import does not seem to trigger the infinite bug although it does duplicate the following imports above the error when that happens.

Thanks for all you do!

lilyinstarlight commented 3 years ago

I can confirm this is still an issue in the 6.0 release. I'm happy to close the issue here and reopen it in the new repository if you want but I also understand the fix is probably low priority.

Here is a GIF that demonstrates the issue to clarify what happens (don't worry about the test code where I was playing around with the ExportToBlocks stuff -- it happens for any code I tried):

import-duplication

Again, disabling auto imports prevents the issue from occurring.