T1002281 class cast ex

Instead of doing an unsafe cast, an exception is thrown directly (or a conversion if possible).

Second commit contains cleanups.
What could go wrong if `OffsetPosition` is treated as `RangePosition`? This way we need to ensure that no `OffsetPosition` is passed into scala-refactoring otherwise it blows up. Maybe that is the right thing to do, then I just need to fix the ticket on the IDE side.