-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add caching based on file content and external references (#752)
- Loading branch information
Showing
46 changed files
with
3,035 additions
and
65 deletions.
There are no files selected for viewing
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
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
7 changes: 7 additions & 0 deletions
7
baselines/packages/wotan/api/src/services/default/state-persistence.d.ts
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,7 @@ | ||
import { CachedFileSystem } from '../cached-file-system'; | ||
import { StatePersistence, StaticProgramState } from '@fimbul/ymir'; | ||
export declare class DefaultStatePersistence implements StatePersistence { | ||
constructor(fs: CachedFileSystem); | ||
loadState(project: string): StaticProgramState | undefined; | ||
saveState(project: string, state: StaticProgramState): void; | ||
} |
12 changes: 12 additions & 0 deletions
12
baselines/packages/wotan/api/src/services/dependency-resolver.d.ts
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 * as ts from 'typescript'; | ||
export interface DependencyResolver { | ||
update(program: ts.Program, updatedFile: string): void; | ||
getDependencies(fileName: string): ReadonlyMap<string, null | readonly string[]>; | ||
getFilesAffectingGlobalScope(): readonly string[]; | ||
} | ||
export declare type DependencyResolverHost = Required<Pick<ts.CompilerHost, 'resolveModuleNames'>> & { | ||
useSourceOfProjectReferenceRedirect?(): boolean; | ||
}; | ||
export declare class DependencyResolverFactory { | ||
create(host: DependencyResolverHost, program: ts.Program): DependencyResolver; | ||
} |
23 changes: 23 additions & 0 deletions
23
baselines/packages/wotan/api/src/services/program-state.d.ts
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,23 @@ | ||
import * as ts from 'typescript'; | ||
import { DependencyResolver, DependencyResolverFactory, DependencyResolverHost } from './dependency-resolver'; | ||
import { Finding, StatePersistence } from '@fimbul/ymir'; | ||
export interface ProgramState { | ||
update(program: ts.Program, updatedFile: string): void; | ||
getUpToDateResult(fileName: string, configHash: string): readonly Finding[] | undefined; | ||
setFileResult(fileName: string, configHash: string, result: readonly Finding[]): void; | ||
save(): void; | ||
} | ||
export declare class ProgramStateFactory { | ||
constructor(resolverFactory: DependencyResolverFactory, statePersistence: StatePersistence); | ||
create(program: ts.Program, host: ProgramStateHost & DependencyResolverHost, tsconfigPath: string): ProgramStateImpl; | ||
} | ||
export declare type ProgramStateHost = Pick<ts.CompilerHost, 'getCanonicalFileName' | 'useCaseSensitiveFileNames'>; | ||
declare const oldStateSymbol: unique symbol; | ||
declare class ProgramStateImpl implements ProgramState { | ||
constructor(host: ProgramStateHost, program: ts.Program, resolver: DependencyResolver, statePersistence: StatePersistence, project: string); | ||
update(program: ts.Program, updatedFile: string): void; | ||
getUpToDateResult(fileName: string, configHash: string): readonly Finding[] | undefined; | ||
setFileResult(fileName: string, configHash: string, result: ReadonlyArray<Finding>): void; | ||
save(): void; | ||
} | ||
export {}; |
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,215 @@ | ||
# Snapshot report for `packages/wotan/test/program-state.spec.ts` | ||
|
||
The actual snapshot is saved in `program-state.spec.ts.snap`. | ||
|
||
Generated by [AVA](https://avajs.dev). | ||
|
||
## saves old state | ||
|
||
> Snapshot 1 | ||
`cs: false␊ | ||
files:␊ | ||
- config: '1234'␊ | ||
hash: '-2704852577'␊ | ||
result: []␊ | ||
- config: '1234'␊ | ||
dependencies:␊ | ||
./c:␊ | ||
- 0␊ | ||
hash: '-5185547329'␊ | ||
result: []␊ | ||
- dependencies:␊ | ||
./c:␊ | ||
- 0␊ | ||
hash: '-5185547329'␊ | ||
- dependencies:␊ | ||
./b:␊ | ||
- 1␊ | ||
./d:␊ | ||
- 2␊ | ||
hash: '-2126001415'␊ | ||
global: []␊ | ||
lookup:␊ | ||
a.ts: 3␊ | ||
b.ts: 1␊ | ||
c.ts: 0␊ | ||
d.ts: 2␊ | ||
options: '-1350339532'␊ | ||
v: 1␊ | ||
` | ||
|
||
> Snapshot 2 | ||
`cs: false␊ | ||
files:␊ | ||
- config: '1234'␊ | ||
hash: '-2704852577'␊ | ||
result: []␊ | ||
- config: '1234'␊ | ||
dependencies:␊ | ||
./c:␊ | ||
- 0␊ | ||
hash: '-5185547329'␊ | ||
result: []␊ | ||
- dependencies:␊ | ||
"\\0":␊ | ||
- 3␊ | ||
hash: '5381'␊ | ||
- dependencies:␊ | ||
./e:␊ | ||
- 2␊ | ||
- 3␊ | ||
hash: '910822549'␊ | ||
- dependencies:␊ | ||
./b:␊ | ||
- 1␊ | ||
./d:␊ | ||
- 3␊ | ||
hash: '-2126001415'␊ | ||
global: []␊ | ||
lookup:␊ | ||
a.ts: 4␊ | ||
b.ts: 1␊ | ||
c.ts: 0␊ | ||
d.ts: 3␊ | ||
e.ts: 2␊ | ||
options: '-1350339532'␊ | ||
v: 1␊ | ||
` | ||
|
||
> Snapshot 3 | ||
`cs: false␊ | ||
files:␊ | ||
- hash: '-2704852577'␊ | ||
- dependencies:␊ | ||
./c:␊ | ||
- 0␊ | ||
hash: '-5185547329'␊ | ||
- dependencies:␊ | ||
"\\0":␊ | ||
- 3␊ | ||
e: null␊ | ||
hash: '8844149038'␊ | ||
- dependencies:␊ | ||
./e:␊ | ||
- 2␊ | ||
- 3␊ | ||
hash: '910822549'␊ | ||
- dependencies:␊ | ||
./b:␊ | ||
- 1␊ | ||
./d:␊ | ||
- 3␊ | ||
hash: '-2126001415'␊ | ||
global:␊ | ||
- 2␊ | ||
lookup:␊ | ||
a.ts: 4␊ | ||
b.ts: 1␊ | ||
c.ts: 0␊ | ||
d.ts: 3␊ | ||
e.ts: 2␊ | ||
options: '-1350339532'␊ | ||
v: 1␊ | ||
` | ||
|
||
## doesn't discard results from old state | ||
|
||
> Snapshot 1 | ||
`cs: false␊ | ||
files:␊ | ||
- config: '1234'␊ | ||
hash: '-3360789062'␊ | ||
result: []␊ | ||
- config: '1234'␊ | ||
hash: '574235295'␊ | ||
result: []␊ | ||
- dependencies:␊ | ||
./c:␊ | ||
- 1␊ | ||
hash: '-5185547329'␊ | ||
global:␊ | ||
- 1␊ | ||
lookup:␊ | ||
a.ts: 0␊ | ||
b.ts: 2␊ | ||
c.ts: 1␊ | ||
options: '5864093'␊ | ||
v: 1␊ | ||
` | ||
|
||
> Snapshot 2 | ||
`cs: false␊ | ||
files:␊ | ||
- hash: '-3360789062'␊ | ||
- hash: '4830905933'␊ | ||
- dependencies:␊ | ||
./c:␊ | ||
- 1␊ | ||
hash: '-5185547329'␊ | ||
global:␊ | ||
- 1␊ | ||
lookup:␊ | ||
a.ts: 0␊ | ||
b.ts: 2␊ | ||
c.ts: 1␊ | ||
options: '5864093'␊ | ||
v: 1␊ | ||
` | ||
|
||
## handles circular dependencies | ||
|
||
> Snapshot 1 | ||
`cs: false␊ | ||
files:␊ | ||
- config: '1234'␊ | ||
hash: '-3360789062'␊ | ||
result: []␊ | ||
- dependencies:␊ | ||
./d:␊ | ||
- 3␊ | ||
hash: '-2335134369'␊ | ||
- dependencies:␊ | ||
./a:␊ | ||
- 4␊ | ||
./c:␊ | ||
- 1␊ | ||
./d:␊ | ||
- 3␊ | ||
hash: '-10011708814'␊ | ||
- dependencies:␊ | ||
./b:␊ | ||
- 2␊ | ||
./e:␊ | ||
- 0␊ | ||
hash: '970287226'␊ | ||
- dependencies:␊ | ||
./b:␊ | ||
- 2␊ | ||
./c:␊ | ||
- 1␊ | ||
./d:␊ | ||
- 3␊ | ||
./e:␊ | ||
- 0␊ | ||
hash: '3028017583'␊ | ||
- dependencies:␊ | ||
./a:␊ | ||
- 4␊ | ||
hash: '-5185549507'␊ | ||
global: []␊ | ||
lookup:␊ | ||
a.ts: 4␊ | ||
b.ts: 2␊ | ||
c.ts: 1␊ | ||
d.ts: 3␊ | ||
e.ts: 0␊ | ||
root.ts: 5␊ | ||
options: '5864093'␊ | ||
v: 1␊ | ||
` |
Binary file not shown.
Oops, something went wrong.