flutter-intellij icon indicating copy to clipboard operation
flutter-intellij copied to clipboard

[Enhancement] Display color icon for variables that can be dereferenced to known colors

Open AlexV525 opened this issue 3 years ago • 5 comments

Currently, the color selector can be parsed and displayed only when the value of the variable explicit starts with "Color" or "Colors", or "CupertinoColors".

Found a related code at https://github.com/flutter/flutter-intellij/blob/28aaecc3078f0f5d065194d64292e920941640d2/src/io/flutter/editor/FlutterColorProvider.java#L41 which abandoned all values other than these patterns.

Steps to Reproduce

image

Version info

Flutter 2.0.5.

AlexV525 avatar Apr 25 '21 05:04 AlexV525

That's a good idea. It may have performance issues, though.

stevemessick avatar Apr 26 '21 15:04 stevemessick

Not sure how much performance regression will raise if we look up it's superclass to see whether it's a Color or CupertinoColor, but at least this is a proper way I think.

AlexV525 avatar Apr 26 '21 15:04 AlexV525

I agree. My concern is that we have to start looking at RHS expressions of assignments and dereferencing field references, and possibly more. The implementation will have to carefully code that because this detector gets called a lot. Fortunately, we already have the PSI model to use.

stevemessick avatar Apr 26 '21 16:04 stevemessick

Any plans to implement this recently?

AlexV525 avatar Nov 10 '21 13:11 AlexV525

Maybe we can benefit from this: https://github.com/dart-lang/sdk/commit/3238b2c09c1e2fc023363ea33902d93bcc8b3d79

AlexV525 avatar Feb 02 '22 15:02 AlexV525