Backport changes from intellij-plugins

Backport a bunch of great changes from [intellij-plugins](https://github.com/JetBrains/intellij-plugins/tree/master/handlebars) so we can make them compatible with earlier IDE versions.