Narrow the return types to API types in tests.

This should drastically reduce the number of internal “hits” in plugins.
Don’t call `openWhenClosed` if the compilation unit is consistent.

`openWhenClosed` is expensive: it requires a partial type-check and forcing all
symbols in order to build the structure of the file. It seems to be called
on the UI thread, on every save, twice. This makes the second call a no-op,
and is exactly what the method we’re overriding is doing. This makes it more
responsive, and seems and sane.
Merge pull request #830 from dragos/api/narrow-return-types-in-tests

Narrow the return types to API types in tests.
Merge pull request #831 from dragos/issue/double-make-consistent-calls

Don’t call `openWhenClosed` if the compilation unit is consistent.
Fix thread check failure in reporting string of Implicit Highlighter

Fixes #1002295.