mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
Add way to exclude files and directories to watch (#39243)
* Parse excludeDirectories and excludeFiles * Use watch factory in typings installer * Some refactoring for watchFactory * Create Noop watcher if file or directory being watched is excluded * Baselines without using exclude watch options * Baselines including exclude option * Handle exclude options in the system watches * Add test without exclude option for recursive directory watching * Test baselines with exclude option * Always set sysLog * Test for exclude option in server * Add exclude options in the config file and fix the test * Fix host configuration for server * Handle host configuration for watch options * Fix sysLog time log so baselines can be clean * Handle reloadProjects to reload the project from scratch * Ensure that file updates are reflected * Feedback * Feedback
This commit is contained in:
1 parent
6c6315db58
commit
76cf8fd78b
29 files changed
+1912
-275
No files matched your search
+13
-11
@@ -189,6 +189,8 @@ namespace ts.server {
|
||||
*/
|
||||
private projectStateVersion = 0;
|
||||
|
||||
protected projectErrors: Diagnostic[] | undefined;
|
||||
|
||||
protected isInitialLoadPending: () => boolean = returnFalse;
|
||||
|
||||
/*@internal*/
|
||||
@@ -489,7 +491,6 @@ namespace ts.server {
|
||||
/*@internal*/
|
||||
watchDirectoryOfFailedLookupLocation(directory: string, cb: DirectoryWatcherCallback, flags: WatchDirectoryFlags) {
|
||||
return this.projectService.watchFactory.watchDirectory(
|
||||
this.projectService.host,
|
||||
directory,
|
||||
cb,
|
||||
flags,
|
||||
@@ -530,7 +531,6 @@ namespace ts.server {
|
||||
/*@internal*/
|
||||
watchTypeRootsDirectory(directory: string, cb: DirectoryWatcherCallback, flags: WatchDirectoryFlags) {
|
||||
return this.projectService.watchFactory.watchDirectory(
|
||||
this.projectService.host,
|
||||
directory,
|
||||
cb,
|
||||
flags,
|
||||
@@ -586,11 +586,18 @@ namespace ts.server {
|
||||
* Get the errors that dont have any file name associated
|
||||
*/
|
||||
getGlobalProjectErrors(): readonly Diagnostic[] {
|
||||
return emptyArray;
|
||||
return filter(this.projectErrors, diagnostic => !diagnostic.file) || emptyArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the project errors
|
||||
*/
|
||||
getAllProjectErrors(): readonly Diagnostic[] {
|
||||
return emptyArray;
|
||||
return this.projectErrors || emptyArray;
|
||||
}
|
||||
|
||||
setProjectErrors(projectErrors: Diagnostic[] | undefined) {
|
||||
this.projectErrors = projectErrors;
|
||||
}
|
||||
|
||||
getLanguageService(ensureSynchronized = true): LanguageService {
|
||||
@@ -771,6 +778,7 @@ namespace ts.server {
|
||||
this.resolutionCache = undefined!;
|
||||
this.cachedUnresolvedImportsPerFile = undefined!;
|
||||
this.directoryStructureHost = undefined!;
|
||||
this.projectErrors = undefined;
|
||||
|
||||
// Clean up file watchers waiting for missing files
|
||||
if (this.missingFilesMap) {
|
||||
@@ -1262,7 +1270,6 @@ namespace ts.server {
|
||||
|
||||
private addMissingFileWatcher(missingFilePath: Path) {
|
||||
const fileWatcher = this.projectService.watchFactory.watchFile(
|
||||
this.projectService.host,
|
||||
missingFilePath,
|
||||
(fileName, eventKind) => {
|
||||
if (isConfiguredProject(this)) {
|
||||
@@ -1318,7 +1325,6 @@ namespace ts.server {
|
||||
return {
|
||||
generatedFilePath: this.toPath(generatedFile),
|
||||
watcher: this.projectService.watchFactory.watchFile(
|
||||
this.projectService.host,
|
||||
generatedFile,
|
||||
() => {
|
||||
this.clearSourceMapperCache();
|
||||
@@ -2060,8 +2066,6 @@ namespace ts.server {
|
||||
/** Ref count to the project when opened from external project */
|
||||
private externalProjectRefCount = 0;
|
||||
|
||||
private projectErrors: Diagnostic[] | undefined;
|
||||
|
||||
private projectReferences: readonly ProjectReference[] | undefined;
|
||||
|
||||
/** Potential project references before the project is actually loaded (read config file) */
|
||||
@@ -2131,7 +2135,6 @@ namespace ts.server {
|
||||
/* @internal */
|
||||
createConfigFileWatcher() {
|
||||
this.configFileWatcher = this.projectService.watchFactory.watchFile(
|
||||
this.projectService.host,
|
||||
this.getConfigFilePath(),
|
||||
(_fileName, eventKind) => this.projectService.onConfigChangedForConfiguredProject(this, eventKind),
|
||||
PollingInterval.High,
|
||||
@@ -2160,7 +2163,7 @@ namespace ts.server {
|
||||
this.openFileWatchTriggered.clear();
|
||||
const reason = Debug.checkDefined(this.pendingReloadReason);
|
||||
this.pendingReloadReason = undefined;
|
||||
this.projectService.reloadConfiguredProject(this, reason, isInitialLoad);
|
||||
this.projectService.reloadConfiguredProject(this, reason, isInitialLoad, /*clearSemanticCache*/ false);
|
||||
result = true;
|
||||
break;
|
||||
default:
|
||||
@@ -2281,7 +2284,6 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
this.stopWatchingWildCards();
|
||||
this.projectErrors = undefined;
|
||||
this.configFileSpecs = undefined;
|
||||
this.openFileWatchTriggered.clear();
|
||||
this.compilerHost = undefined;
|
||||
|
||||
Reference in new issue
Block a user