migrate populate-env and ns parsing from tools.analyzer