SI-7364 Allow raw types in parent position in Java sources

To make this work, this commit simply restricts parent
type argument inference to Scala source files.

The surrounding code has also been refactored to avoid a var.

Review by @xeno-by (last seen in this area in 40063b00)