Wednesday, June 27, 2018

Noise comments in Android Studio with Flutter

Flutter sounds neat, doesn't it? I decided to take a look yesterday, and it distracted me quite a bit from my course revision work. With my course revision and reflective blog post done, I decided to get into the Flutter codelab and see what I could do.

Step one is basically to copy and paste this code into Android Studio:
OK, copy, paste, and I get this abomination:
What the...?!

Those end-of-line comments are clearly not in the code. I do not want them. They are concretely, undeniably, irrevocably bad.

My first thought was, "I need to get Android Studio not to add those comments when I paste in code." I tried Googling for variations on this, but to no avail. Maybe I was calling it the wrong thing? I searched the preferences in Android Studio but couldn't find a good match either. Not wanting to waste more time, I decided I'd just go in and manually eliminate them for now.

I cannot.

They are not actually content in the editor! Those characters are not in the file. The view of the file is showing me data that do not exist. OK, stop and think about that, think about that for a long time if you have to. If you added this feature to Android Studio in particular, think about this for a long, long, long time. This is the worst idea.

But it's not the first time I've seen it. A few versions ago, IntelliJ IDEA added a "feature" in which it would show formal parameter names at the site of the actual parameter. It looks like this:

The text "bar:" is what they call a "parameter hint." It is not selectable or erasable. It's not really there in the data—once again, the view of the file is showing something that's not in the file. When I first saw this, I was aghast, and I could feel it in my bones that bad things were coming. I make all my students turn this abomination of a feature off.

Now, we see that my intuition was right. It's getting worse. Now, the view of my Dart source code file isn't just showing data that's not there: it's rendering that data as if it were. It's not using a different font or size, as in the parameter hints.

The good news is that this helped me consider where I might turn this off, and sharing this knowledge is the primary reason for this post. If you understand a modicum of what it means to write clean and maintainable code, then go to the File Menu, open the Settings dialog, and go to the Appearance section (with the Flutter Plug-in enabled, of course).


There it is. Untick that box and accept the changes, and your source code editor will be purified.

You're welcome.

No comments:

Post a Comment