Moved GetCompilationContext into a shared helper