mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-13 22:00:59 -05:00
* Prototype resolving to JS when go-to-def aliases all resolve to ambient declarations * Add test infrastructure * Start fleshing out test coverage * Fix some go-to-def stuff * Finish lodash test case * Make go-to-implementation never return ambient results * Build new functionality into go-to-implementation * Update baselines * Two more test cases * Refine definition searches for unresolved imports * Revert "Build new functionality into go-to-implementation" This reverts commit381799d0f1. * Fix tests * Revert go-to-implementation changes * Wow a bunch of code was unnecessary * Update baselines and go-to-def test * Fix navigation on symbols that are not aliases but resolve through aliases in chain * Temporarily replace go-to-def with new command implementation * Revert "Temporarily replace go-to-def with new command implementation" This reverts commit34c6cfdebb. * Revert "Wow a bunch of code was unnecessary" This reverts commit1cb2ba646c. * Bring back some deleted code needed for a new test case * Clean up a little * Rename more stuff * Update test * Update API baseline * Temporarily replace go-to-def with new command implementation * PR review fixes * Fix getTopMostDeclarationNamesInFile * Rename local * Use hash set * Remove option from commandLineParser * Keep noDtsResolution project around * Handle AuxiliaryProject kind in ScriptInfo getDefaultProject etc. * Do not run updateGraph in the background for AuxiliaryProject * Don’t create auxiliary project outside of semantic mode * No-op on scheduled invalidation * Add comments to unit test * Sync compiler options to auxiliary project * Fix case sensitivity * Update extensionIsOk with new file extensions * PR feedback * Update API baseline * Mark scheduleInvalidateResolutionsOfFailedLookupLocations internal * Use same heuristics on property accesses of loosely-resolvable aliases as unresolvable named imports * Rename command, and no need to return the bound span * Update API baseline
134 lines
4.7 KiB
TypeScript
134 lines
4.7 KiB
TypeScript
namespace ts.server {
|
|
export enum LogLevel {
|
|
terse,
|
|
normal,
|
|
requestTime,
|
|
verbose
|
|
}
|
|
|
|
export const emptyArray: SortedReadonlyArray<never> = createSortedArray<never>();
|
|
|
|
export interface Logger {
|
|
close(): void;
|
|
hasLevel(level: LogLevel): boolean;
|
|
loggingEnabled(): boolean;
|
|
perftrc(s: string): void;
|
|
info(s: string): void;
|
|
startGroup(): void;
|
|
endGroup(): void;
|
|
msg(s: string, type?: Msg): void;
|
|
getLogFileName(): string | undefined;
|
|
}
|
|
|
|
// TODO: Use a const enum (https://github.com/Microsoft/TypeScript/issues/16804)
|
|
export enum Msg {
|
|
Err = "Err",
|
|
Info = "Info",
|
|
Perf = "Perf",
|
|
}
|
|
export namespace Msg {
|
|
/** @deprecated Only here for backwards-compatibility. Prefer just `Msg`. */
|
|
export type Types = Msg;
|
|
}
|
|
|
|
export function createInstallTypingsRequest(project: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray<string>, cachePath?: string): DiscoverTypings {
|
|
return {
|
|
projectName: project.getProjectName(),
|
|
fileNames: project.getFileNames(/*excludeFilesFromExternalLibraries*/ true, /*excludeConfigFiles*/ true).concat(project.getExcludedFiles() as NormalizedPath[]),
|
|
compilerOptions: project.getCompilationSettings(),
|
|
watchOptions: project.projectService.getWatchOptions(project),
|
|
typeAcquisition,
|
|
unresolvedImports,
|
|
projectRootPath: project.getCurrentDirectory() as Path,
|
|
cachePath,
|
|
kind: "discover"
|
|
};
|
|
}
|
|
|
|
export namespace Errors {
|
|
export function ThrowNoProject(): never {
|
|
throw new Error("No Project.");
|
|
}
|
|
export function ThrowProjectLanguageServiceDisabled(): never {
|
|
throw new Error("The project's language service is disabled.");
|
|
}
|
|
export function ThrowProjectDoesNotContainDocument(fileName: string, project: Project): never {
|
|
throw new Error(`Project '${project.getProjectName()}' does not contain document '${fileName}'`);
|
|
}
|
|
}
|
|
|
|
export type NormalizedPath = string & { __normalizedPathTag: any };
|
|
|
|
export function toNormalizedPath(fileName: string): NormalizedPath {
|
|
return normalizePath(fileName) as NormalizedPath;
|
|
}
|
|
|
|
export function normalizedPathToPath(normalizedPath: NormalizedPath, currentDirectory: string, getCanonicalFileName: (f: string) => string): Path {
|
|
const f = isRootedDiskPath(normalizedPath) ? normalizedPath : getNormalizedAbsolutePath(normalizedPath, currentDirectory);
|
|
return getCanonicalFileName(f) as Path;
|
|
}
|
|
|
|
export function asNormalizedPath(fileName: string): NormalizedPath {
|
|
return fileName as NormalizedPath;
|
|
}
|
|
|
|
export interface NormalizedPathMap<T> {
|
|
get(path: NormalizedPath): T | undefined;
|
|
set(path: NormalizedPath, value: T): void;
|
|
contains(path: NormalizedPath): boolean;
|
|
remove(path: NormalizedPath): void;
|
|
}
|
|
|
|
export function createNormalizedPathMap<T>(): NormalizedPathMap<T> {
|
|
const map = new Map<string, T>();
|
|
return {
|
|
get(path) {
|
|
return map.get(path);
|
|
},
|
|
set(path, value) {
|
|
map.set(path, value);
|
|
},
|
|
contains(path) {
|
|
return map.has(path);
|
|
},
|
|
remove(path) {
|
|
map.delete(path);
|
|
}
|
|
};
|
|
}
|
|
|
|
/*@internal*/
|
|
export interface ProjectOptions {
|
|
configHasExtendsProperty: boolean;
|
|
/**
|
|
* true if config file explicitly listed files
|
|
*/
|
|
configHasFilesProperty: boolean;
|
|
configHasIncludeProperty: boolean;
|
|
configHasExcludeProperty: boolean;
|
|
}
|
|
|
|
export function isInferredProjectName(name: string) {
|
|
// POSIX defines /dev/null as a device - there should be no file with this prefix
|
|
return /dev\/null\/inferredProject\d+\*/.test(name);
|
|
}
|
|
|
|
export function makeInferredProjectName(counter: number): string {
|
|
return `/dev/null/inferredProject${counter}*`;
|
|
}
|
|
|
|
/*@internal*/
|
|
export function makeAutoImportProviderProjectName(counter: number): string {
|
|
return `/dev/null/autoImportProviderProject${counter}*`;
|
|
}
|
|
|
|
/*@internal*/
|
|
export function makeAuxiliaryProjectName(counter: number): string {
|
|
return `/dev/null/auxiliaryProject${counter}*`;
|
|
}
|
|
|
|
export function createSortedArray<T>(): SortedArray<T> {
|
|
return [] as any as SortedArray<T>; // TODO: GH#19873
|
|
}
|
|
}
|