1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 |
|
4 |
|
5 |
|
6 | class LociTable {
|
7 | constructor(locations = new Map()) {
|
8 | this.locations = locations;
|
9 | }
|
10 | static apiClassKey() {
|
11 | return "api_class";
|
12 | }
|
13 | static apiDecoratorKey() {
|
14 | return "api_decorator";
|
15 | }
|
16 | static apiNameKey() {
|
17 | return "api_name";
|
18 | }
|
19 | static apiDescriptionKey() {
|
20 | return "api_description";
|
21 | }
|
22 | static endpointClassKey(endpointName) {
|
23 | return `endpoint_<${endpointName}>_class`;
|
24 | }
|
25 | static endpointDecoratorKey(endpointName) {
|
26 | return `endpoint_<${endpointName}>_decorator`;
|
27 | }
|
28 | static endpointMethodKey(endpointName) {
|
29 | return `endpoint_<${endpointName}>_method`;
|
30 | }
|
31 | static endpointPathKey(endpointName) {
|
32 | return `endpoint_<${endpointName}>_path`;
|
33 | }
|
34 | static endpointTagsKey(endpointName) {
|
35 | return `endpoint_<${endpointName}>_tags`;
|
36 | }
|
37 | static endpointTagKey(endpointName, tag) {
|
38 | return `endpoint_<${endpointName}>_tag_<${tag}>`;
|
39 | }
|
40 | static endpointRequestKey(endpointName) {
|
41 | return `endpoint_<${endpointName}>_request`;
|
42 | }
|
43 | static endpointDescriptionKey(endpointName) {
|
44 | return `endpoint_<${endpointName}>_description`;
|
45 | }
|
46 | static typeKey(typeName) {
|
47 | return `type_<${typeName}>`;
|
48 | }
|
49 | |
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 | add(key, locus) {
|
56 | if (this.locations.has(key)) {
|
57 | throw new Error(`Key already present in type table: ${key}`);
|
58 | }
|
59 | this.locations.set(key, locus);
|
60 | }
|
61 | |
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 | addMorphNode(key, node) {
|
68 | this.add(key, {
|
69 | file: node.getSourceFile().getFilePath(),
|
70 | line: node.getStartLineNumber(),
|
71 | column: node.getStartLinePos()
|
72 | });
|
73 | }
|
74 | |
75 |
|
76 |
|
77 |
|
78 |
|
79 | get(key) {
|
80 | return this.locations.get(key);
|
81 | }
|
82 | |
83 |
|
84 |
|
85 |
|
86 |
|
87 | getOrError(key) {
|
88 | const location = this.get(key);
|
89 | if (location === undefined) {
|
90 | throw new Error(`Key not present in location table: ${key}`);
|
91 | }
|
92 | return location;
|
93 | }
|
94 | |
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 | equalsMorphNode(key, node) {
|
101 | const existingLocus = this.getOrError(key);
|
102 | if (existingLocus.file !== node.getSourceFile().getFilePath() ||
|
103 | existingLocus.line !== node.getStartLineNumber() ||
|
104 | existingLocus.column !== node.getStartLinePos()) {
|
105 | return false;
|
106 | }
|
107 | return true;
|
108 | }
|
109 | }
|
110 | exports.LociTable = LociTable;
|