43 lines
2.1 KiB
Plaintext
43 lines
2.1 KiB
Plaintext
|
import type { ModeAwareCache, Path, ResolvedTypeReferenceDirectiveWithFailedLookupLocations, SourceFile } from "typescript/lib/tsserverlibrary";
|
||
|
export interface MultiMap<K, V> extends Map<K, V[]> {
|
||
|
/**
|
||
|
* Adds the value to an array of values associated with the key, and returns the array.
|
||
|
* Creates the array if it does not already exist.
|
||
|
*/
|
||
|
add(key: K, value: V): V[];
|
||
|
/**
|
||
|
* Removes a value from an array of values associated with the key.
|
||
|
* Does not preserve the order of those values.
|
||
|
* Does nothing if `key` is not in `map`, or `value` is not in `map[key]`.
|
||
|
*/
|
||
|
remove(key: K, value: V): void;
|
||
|
}
|
||
|
export interface SymlinkedDirectory {
|
||
|
/** Matches the casing returned by `realpath`. Used to compute the `realpath` of children. */
|
||
|
real: string;
|
||
|
/** toPath(real). Stored to avoid repeated recomputation. */
|
||
|
realPath: Path;
|
||
|
}
|
||
|
export interface SymlinkCache {
|
||
|
/** Gets a map from symlink to realpath. Keys have trailing directory separators. */
|
||
|
getSymlinkedDirectories(): ReadonlyMap<Path, SymlinkedDirectory | false> | undefined;
|
||
|
/** Gets a map from realpath to symlinks. Keys have trailing directory separators. */
|
||
|
getSymlinkedDirectoriesByRealpath(): MultiMap<Path, string> | undefined;
|
||
|
/** Gets a map from symlink to realpath */
|
||
|
getSymlinkedFiles(): ReadonlyMap<Path, string> | undefined;
|
||
|
setSymlinkedDirectory(symlink: string, real: SymlinkedDirectory | false): void;
|
||
|
setSymlinkedFile(symlinkPath: Path, real: string): void;
|
||
|
/**
|
||
|
* @internal
|
||
|
* Uses resolvedTypeReferenceDirectives from program instead of from files, since files
|
||
|
* don't include automatic type reference directives. Must be called only when
|
||
|
* `hasProcessedResolutions` returns false (once per cache instance).
|
||
|
*/
|
||
|
setSymlinksFromResolutions(files: readonly SourceFile[], typeReferenceDirectives: ModeAwareCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>): void;
|
||
|
/**
|
||
|
* @internal
|
||
|
* Whether `setSymlinksFromResolutions` has already been called.
|
||
|
*/
|
||
|
hasProcessedResolutions(): boolean;
|
||
|
}
|