Factored out useful Codex bits into shared base.

This will make life easier for CodexJavaMode, CodexScalaMode, &c.