Refactor IdeCodeListener to do minimal job in UI threads