You can reuse some functionality for type inference from the [type aware completion branch](https://github.com/ignatov/intellij-erlang/tree/type-aware-completion).