UNPKG

2.01 kBTypeScriptView Raw
1import { Node } from "ts-morph";
2/**
3 * Loci table is a lookup table for syntax location data.
4 */
5export declare class LociTable {
6 static apiClassKey(): string;
7 static apiDecoratorKey(): string;
8 static apiNameKey(): string;
9 static apiDescriptionKey(): string;
10 static endpointClassKey(endpointName: string): string;
11 static endpointDecoratorKey(endpointName: string): string;
12 static endpointMethodKey(endpointName: string): string;
13 static endpointPathKey(endpointName: string): string;
14 static endpointTagsKey(endpointName: string): string;
15 static endpointTagKey(endpointName: string, tag: string): string;
16 static endpointRequestKey(endpointName: string): string;
17 static endpointDescriptionKey(endpointName: string): string;
18 static typeKey(typeName: string): string;
19 private locations;
20 constructor(locations?: Map<string, Locus>);
21 /**
22 * Add a locus to the loci table. If the lookup key is already present, `add` will throw an error.
23 *
24 * @param key lookup key
25 * @param locus target locus
26 */
27 add(key: string, locus: Locus): void;
28 /**
29 * Add a locus to the loci table by inferring from a ts-morph node. If the lookup key is already present, `addMorphNode` will throw an error.
30 *
31 * @param key lookup key
32 * @param node ts-morph node
33 */
34 addMorphNode(key: string, node: Node): void;
35 /**
36 * Retrieve a locus by lookup key.
37 *
38 * @param key lookup key
39 */
40 get(key: string): Locus | undefined;
41 /**
42 * Retrieve a locus by lookup key or error.
43 *
44 * @param key lookup key
45 */
46 getOrError(key: string): Locus;
47 /**
48 * Check if an exsiting locus matches a ts-morph node.
49 *
50 * @param key lookup key
51 * @param node ts-morph node
52 */
53 equalsMorphNode(key: string, node: Node): boolean;
54}
55/**
56 * Locus represents a particular position in a file.
57 */
58export interface Locus {
59 file: string;
60 line: number;
61 column: number;
62}