typir
Version:
General purpose type checking library
63 lines • 3.51 kB
TypeScript
/******************************************************************************
* Copyright 2024 TypeFox GmbH
* This program and the accompanying materials are made available under the
* terms of the MIT License, which is available in the project root.
******************************************************************************/
import { TypeEdge } from '../graph/type-edge.js';
import { TypeGraph } from '../graph/type-graph.js';
import { Type } from '../graph/type-node.js';
import { TypirSpecifics, TypirServices } from '../typir.js';
/**
* Caches relationships between types.
*/
export interface TypeRelationshipCaching {
getRelationshipUnidirectional<T extends TypeEdge>(from: Type, to: Type, $relation: T['$relation']): T | undefined;
getRelationshipBidirectional<T extends TypeEdge>(from: Type, to: Type, $relation: T['$relation']): T | undefined;
setOrUpdateUnidirectionalRelationship<T extends TypeEdge>(edgeToCache: T, edgeCaching: EdgeCachingInformation): T | undefined;
setOrUpdateBidirectionalRelationship<T extends TypeEdge>(edgeToCache: T, edgeCaching: EdgeCachingInformation): T | undefined;
}
export type EdgeCachingInformation =
/** The analysis, whether the current relationship holds, is still ongoing. */
'PENDING' |
/** It is unknown, whether the current relationship holds */
'UNKNOWN' |
/** The current relationship exists. */
'LINK_EXISTS' |
/** The current relationship does not exist. */
'NO_LINK';
export declare class DefaultTypeRelationshipCaching<Specifics extends TypirSpecifics> implements TypeRelationshipCaching {
protected readonly graph: TypeGraph;
constructor(services: TypirServices<Specifics>);
getRelationshipUnidirectional<T extends TypeEdge>(from: Type, to: Type, $relation: T['$relation']): T | undefined;
getRelationshipBidirectional<T extends TypeEdge>(from: Type, to: Type, $relation: T['$relation']): T | undefined;
setOrUpdateUnidirectionalRelationship<T extends TypeEdge>(edgeToCache: T, edgeCaching: EdgeCachingInformation): T | undefined;
setOrUpdateBidirectionalRelationship<T extends TypeEdge>(edgeToCache: T, edgeCaching: EdgeCachingInformation): T | undefined;
protected setOrUpdateRelationship<T extends TypeEdge>(edgeToCache: T, edgeCaching: EdgeCachingInformation, bidirectional: boolean): T | undefined;
/** Override this function to store more or less relationships in the type graph. */
protected storeCachingInformation(value: EdgeCachingInformation | undefined): boolean;
}
/**
* Language node-to-Type caching for type inference.
*/
export interface LanguageNodeInferenceCaching {
cacheSet(languageNode: unknown, type: Type): void;
cacheGet(languageNode: unknown): Type | undefined;
cacheClear(): void;
pendingSet(languageNode: unknown): void;
pendingClear(languageNode: unknown): void;
pendingGet(languageNode: unknown): boolean;
}
export type CachePending = 'CACHE_PENDING';
export declare const CachePending = "CACHE_PENDING";
export declare class DefaultLanguageNodeInferenceCaching implements LanguageNodeInferenceCaching {
protected cache: Map<unknown, Type | CachePending>;
constructor();
protected initializeCache(): void;
cacheSet(languageNode: unknown, type: Type): void;
cacheGet(languageNode: unknown): Type | undefined;
cacheClear(): void;
pendingSet(languageNode: unknown): void;
pendingClear(languageNode: unknown): void;
pendingGet(languageNode: unknown): boolean;
}
//# sourceMappingURL=caching.d.ts.map