Robin Smith Robin Smith - 1 month ago 12
Ruby Question

IntelliJ Idea Ultimate red-underlines Ruby shorthand hash literal

Anybody know why IntelliJ Idea Ultimate doesn't like Ruby hash literals in the newer syntax? Refer to the red underlines in my screenshot from the IDE below. Syntax:

{key1: "value", key2: 123}


Really annoying as it means my entire project has a red underline all the way up the directory tree.

I have setup a Ruby SDK version greater than 1.9 (which is when i think the new hash literal syntax was introduced) in the IDE preferences, so there is no excuse!

Thanks.

Screenshot from IntelliJ Ultimate

Answer

Answer is to replace every usage of the horrible new hash syntax with the old one using a regex (not perfect yet but works ~95% of the time).

files=gfind . -iregex '.*\(rb\|haml\)' -printf '%p\n' for file in $files do gsed -i "s/([a-z_]+):{1}\s+(('\|"'"'")\?[-a-zA-Z0-9{}:@]+('\|"'"'")\?)/:\1 => \2/g" $file done

Comments