Update comments

This commit is contained in:
zhengbli 2015-10-05 14:31:43 -07:00
parent 7741ec0999
commit 17f0cce772
2 changed files with 11 additions and 8 deletions

View file

@ -398,8 +398,8 @@ namespace ts {
// and https://github.com/Microsoft/TypeScript/issues/4643), therefore
// if the current node.js version is newer than 4, use `fs.watch` instead.
if (isNode4OrLater()) {
// Note: in node the callback of fs.watch is given only the base file name as a parameter
return _fs.watch(fileName, (eventName: string, baseFileName: string) => callback(fileName));
// Note: in node the callback of fs.watch is given only the relative file name as a parameter
return _fs.watch(fileName, (eventName: string, relativeFileName: string) => callback(fileName));
}
var watchedFile = watchedFileSet.addFile(fileName, callback);

View file

@ -543,7 +543,7 @@ namespace ts.server {
}
/**
* This is the callback function when a watched directory has added or removed files.
* This is the callback function when a watched directory has added or removed source code files.
* @param project the project that associates with this directory watcher
* @param fileName the absolute file name that changed in watched directory
*/
@ -567,12 +567,15 @@ namespace ts.server {
// just update the current project.
this.updateConfiguredProject(project);
// Call updateProjectStructure to clean up inferred projects we may have created for the
// new files
// Call updateProjectStructure to clean up inferred projects we may have
// created for the new files
this.updateProjectStructure();
}
}
/**
* This is the callback function when a watched directory has an added tsconfig file.
*/
directoryWatchedForTsconfigChanged(fileName: string) {
if (ts.getBaseFileName(fileName) != "tsconfig.json") {
this.log(fileName + " is not tsconfig.json");
@ -585,6 +588,8 @@ namespace ts.server {
let rootFilesInTsconfig = projectOptions.files.map(f => this.getCanonicalFileName(f));
let openFileRoots = this.openFileRoots.map(s => this.getCanonicalFileName(s.fileName));
// We should only care about the new tsconfig file if it contains any
// opened root files of existing inferred projects
for (let openFileRoot of openFileRoots) {
if (rootFilesInTsconfig.indexOf(openFileRoot) >= 0) {
this.reloadProjects();
@ -708,6 +713,7 @@ namespace ts.server {
}
else {
for (let directory of project.directoriesWatchedForTsconfig) {
// if the ref count for this directory watcher drops to 0, it's time to close it
if (!(--project.projectService.directoryWatchersRefCount[directory])) {
this.log("Close directory watcher for: " + directory);
project.projectService.directoryWatchersForTsconfig[directory].close();
@ -956,9 +962,6 @@ namespace ts.server {
this.addOpenFile(unattachedOpenFiles[i]);
}
this.printProjects();
this.log("Current openFileRoots: " + this.openFileRoots.map(s => s.fileName).toString());
this.log("Current openFileRootsConfigured: " + this.openFileRootsConfigured.map(s => s.fileName).toString());
}
getScriptInfo(filename: string) {