-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
97fe7d5
commit bd79362
Showing
7 changed files
with
106 additions
and
21 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type { LanguageService, LanguageServiceHost } from 'typescript/lib/tsserverlibrary'; | ||
import _50 from '../5_0'; | ||
import { createProject } from './project'; | ||
|
||
export default function ( | ||
ts: typeof import('typescript/lib/tsserverlibrary'), | ||
sys: import('typescript/lib/tsserverlibrary').System, | ||
host: LanguageServiceHost, | ||
createLanguageService: (host: LanguageServiceHost) => LanguageService | ||
) { | ||
return _50(ts, sys, host, createLanguageService, createProject); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import type { LanguageService, LanguageServiceHost } from 'typescript/lib/tsserverlibrary'; | ||
import { ProjectOptions, createProject as _createProject } from '../5_0/project'; | ||
import { SymlinkCache } from './symlinkCache'; | ||
|
||
export function createProject( | ||
ts: typeof import('typescript/lib/tsserverlibrary'), | ||
host: LanguageServiceHost, | ||
createLanguageService: (host: LanguageServiceHost) => LanguageService, | ||
options: ProjectOptions | ||
) { | ||
const { createSymlinkCache } = ts as any; | ||
const project = _createProject(ts, host, createLanguageService, options); | ||
project.getSymlinkCache = () => { | ||
if (!project.symlinks) { | ||
project.symlinks = createSymlinkCache(project.getCurrentDirectory(), project.getCanonicalFileName); | ||
} | ||
if (project.program && !(project.symlinks as unknown as SymlinkCache).hasProcessedResolutions()) { | ||
(project.symlinks as unknown as SymlinkCache).setSymlinksFromResolutions( | ||
// @ts-expect-error | ||
project.program.forEachResolvedModule, | ||
// @ts-expect-error | ||
project.program.forEachResolvedTypeReferenceDirective, | ||
// @ts-expect-error | ||
project.program.getAutomaticTypeDirectiveResolutions(), | ||
); | ||
} | ||
return project.symlinks!; | ||
}; | ||
return project; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { MultiMap, SymlinkedDirectory } from "../5_0/symlinkCache"; | ||
import type { ModeAwareCache, Path, ResolutionMode, ResolvedModuleWithFailedLookupLocations, ResolvedTypeReferenceDirectiveWithFailedLookupLocations } from "typescript/lib/tsserverlibrary"; | ||
|
||
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( | ||
forEachResolvedModule: ( | ||
callback: (resolution: ResolvedModuleWithFailedLookupLocations, moduleName: string, mode: ResolutionMode, filePath: Path) => void, | ||
) => void, | ||
forEachResolvedTypeReferenceDirective: ( | ||
callback: (resolution: ResolvedTypeReferenceDirectiveWithFailedLookupLocations, moduleName: string, mode: ResolutionMode, filePath: Path) => void, | ||
) => void, | ||
typeReferenceDirectives: ModeAwareCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>, | ||
): void; | ||
/** | ||
* @internal | ||
* Whether `setSymlinksFromResolutions` has already been called. | ||
*/ | ||
hasProcessedResolutions(): boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters