UNPKG

2.4 kBTypeScriptView Raw
1import * as ts from 'typescript';
2import { DependencyResolver, DependencyResolverFactory, DependencyResolverHost } from './dependency-resolver';
3import { ContentId, Finding, StatePersistence } from '@fimbul/ymir';
4export interface ProgramState {
5 update(program: ts.Program, updatedFile: string): void;
6 getUpToDateResult(fileName: string, configHash: string): readonly Finding[] | undefined;
7 setFileResult(fileName: string, configHash: string, result: readonly Finding[]): void;
8 save(): void;
9}
10export declare class ProgramStateFactory {
11 private resolverFactory;
12 private statePersistence;
13 private contentId;
14 constructor(resolverFactory: DependencyResolverFactory, statePersistence: StatePersistence, contentId: ContentId);
15 create(program: ts.Program, host: ProgramStateHost & DependencyResolverHost, tsconfigPath: string): ProgramStateImpl;
16}
17export declare type ProgramStateHost = Pick<ts.CompilerHost, 'useCaseSensitiveFileNames'>;
18declare const oldStateSymbol: unique symbol;
19declare class ProgramStateImpl implements ProgramState {
20 private host;
21 private program;
22 private resolver;
23 private statePersistence;
24 private contentId;
25 private project;
26 private projectDirectory;
27 private caseSensitive;
28 private canonicalProjectDirectory;
29 private optionsHash;
30 private assumeChangesOnlyAffectDirectDependencies;
31 private contentIds;
32 private fileResults;
33 private relativePathNames;
34 private [oldStateSymbol];
35 private recheckOldState;
36 private dependenciesUpToDate;
37 private contentIdHost;
38 constructor(host: ProgramStateHost, program: ts.Program, resolver: DependencyResolver, statePersistence: StatePersistence, contentId: ContentId, project: string);
39 /** get old state if global files didn't change */
40 private tryReuseOldState;
41 update(program: ts.Program, updatedFile: string): void;
42 private getContentId;
43 private computeContentId;
44 private getRelativePath;
45 private makeRelativePath;
46 getUpToDateResult(fileName: string, configHash: string): readonly Finding[] | undefined;
47 setFileResult(fileName: string, configHash: string, result: ReadonlyArray<Finding>): void;
48 private isFileUpToDate;
49 private fileDependenciesUpToDate;
50 save(): void;
51 private aggregate;
52 private sortById;
53 private lookupFileIndex;
54 private remapFileNames;
55}
56export {};