mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 01:49:57 -05:00
Merge pull request #24206 from Microsoft/documentRegistery
Cache the latest source file from document registery in script info so that we do not have to reparse orphan script info
This commit is contained in:
@@ -339,7 +339,8 @@ namespace ts.server {
|
||||
/*@internal*/
|
||||
readonly typingsCache: TypingsCache;
|
||||
|
||||
private readonly documentRegistry: DocumentRegistry;
|
||||
/*@internal*/
|
||||
readonly documentRegistry: DocumentRegistry;
|
||||
|
||||
/**
|
||||
* Container of all known scripts
|
||||
@@ -474,7 +475,7 @@ namespace ts.server {
|
||||
extraFileExtensions: []
|
||||
};
|
||||
|
||||
this.documentRegistry = createDocumentRegistry(this.host.useCaseSensitiveFileNames, this.currentDirectory);
|
||||
this.documentRegistry = createDocumentRegistryInternal(this.host.useCaseSensitiveFileNames, this.currentDirectory, this);
|
||||
const watchLogLevel = this.logger.hasLevel(LogLevel.verbose) ? WatchLogLevel.Verbose :
|
||||
this.logger.loggingEnabled() ? WatchLogLevel.TriggerOnly : WatchLogLevel.None;
|
||||
const log: (s: string) => void = watchLogLevel !== WatchLogLevel.None ? (s => this.logger.info(s)) : noop;
|
||||
@@ -495,6 +496,19 @@ namespace ts.server {
|
||||
return getNormalizedAbsolutePath(fileName, this.host.getCurrentDirectory());
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
setDocument(key: DocumentRegistryBucketKey, path: Path, sourceFile: SourceFile) {
|
||||
const info = this.getScriptInfoForPath(path);
|
||||
Debug.assert(!!info);
|
||||
info.cacheSourceFile = { key, sourceFile };
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
getDocument(key: DocumentRegistryBucketKey, path: Path) {
|
||||
const info = this.getScriptInfoForPath(path);
|
||||
return info && info.cacheSourceFile && info.cacheSourceFile.key === key && info.cacheSourceFile.sourceFile;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
ensureInferredProjectsUpToDate_TestOnly() {
|
||||
this.ensureProjectStructuresUptoDate();
|
||||
|
||||
@@ -202,6 +202,12 @@ namespace ts.server {
|
||||
return fileName[0] === "^" || getBaseFileName(fileName)[0] === "^";
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
export interface DocumentRegistrySourceFileCache {
|
||||
key: DocumentRegistryBucketKey;
|
||||
sourceFile: SourceFile;
|
||||
}
|
||||
|
||||
export class ScriptInfo {
|
||||
/**
|
||||
* All projects that include this file
|
||||
@@ -221,6 +227,9 @@ namespace ts.server {
|
||||
/** Set to real path if path is different from info.path */
|
||||
private realpath: Path | undefined;
|
||||
|
||||
/*@internal*/
|
||||
cacheSourceFile: DocumentRegistrySourceFileCache;
|
||||
|
||||
constructor(
|
||||
private readonly host: ServerHost,
|
||||
readonly fileName: NormalizedPath,
|
||||
|
||||
Reference in New Issue
Block a user