It is a shared responsibility. The language must allow you to create a sane in-memory representation of code, including partial code, and an autocomplete engine has to be created, taking advantage of that.