Fix AIOOBE in ScalaWordFinder

Reimplementation of #773 without the AspectJ code removal.