Fix text decoration bug in applicable declarations cache

Fixes #2498.  Also includes a reftest, and some related code cleanup (in separate commits).

Note: The fix in `properties.rs.mako` is much more readable with `git diff -w`.