Check for reference changes in a TypeScriptDocument and attach/detach referenced documents accordingly