skir 1.2.5 → 1.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/casing.d.ts +5 -0
- package/dist/casing.js +23 -0
- package/dist/casing.js.map +1 -0
- package/dist/command_line_parser.d.ts +36 -0
- package/dist/command_line_parser.d.ts.map +1 -0
- package/dist/command_line_parser.js +240 -0
- package/dist/command_line_parser.js.map +1 -0
- package/dist/compatibility_checker.d.ts +74 -0
- package/dist/compatibility_checker.js +331 -0
- package/dist/compatibility_checker.js.map +1 -0
- package/dist/compiler.d.ts +3 -0
- package/dist/compiler.js +406 -0
- package/dist/compiler.js.map +1 -0
- package/dist/completion_helper.d.ts +27 -0
- package/dist/completion_helper.js +101 -0
- package/dist/completion_helper.js.map +1 -0
- package/dist/config.d.ts +18 -0
- package/dist/config.js +19 -0
- package/dist/config.js.map +1 -0
- package/dist/config_parser.d.ts +34 -0
- package/dist/config_parser.js +217 -0
- package/dist/config_parser.js.map +1 -0
- package/dist/definition_finder.d.ts +16 -0
- package/dist/definition_finder.js +375 -0
- package/dist/definition_finder.js.map +1 -0
- package/dist/dependency_manager.d.ts +14 -0
- package/dist/dependency_manager.js +109 -0
- package/dist/dependency_manager.js.map +1 -0
- package/dist/doc_comment_parser.d.ts +6 -0
- package/dist/doc_comment_parser.js +269 -0
- package/dist/doc_comment_parser.js.map +1 -0
- package/dist/doc_reference_resolver.d.ts +5 -0
- package/dist/doc_reference_resolver.js +232 -0
- package/dist/doc_reference_resolver.js.map +1 -0
- package/dist/error_renderer.d.ts +24 -0
- package/dist/error_renderer.js +326 -0
- package/dist/error_renderer.js.map +1 -0
- package/dist/exit_error.d.ts +8 -0
- package/dist/exit_error.d.ts.map +1 -0
- package/dist/exit_error.js +8 -0
- package/dist/exit_error.js.map +1 -0
- package/dist/expected_names.d.ts +11 -0
- package/dist/expected_names.js +34 -0
- package/dist/expected_names.js.map +1 -0
- package/dist/formatter.d.ts +28 -0
- package/dist/formatter.js +338 -0
- package/dist/formatter.js.map +1 -0
- package/dist/get_dependencies_flow.d.ts +40 -0
- package/dist/get_dependencies_flow.js +177 -0
- package/dist/get_dependencies_flow.js.map +1 -0
- package/dist/import_block_formatter.d.ts +3 -0
- package/dist/import_block_formatter.js +36 -0
- package/dist/import_block_formatter.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/io.d.ts +23 -0
- package/dist/io.d.ts.map +1 -0
- package/dist/io.js +58 -0
- package/dist/io.js.map +1 -0
- package/dist/literals.d.ts +12 -0
- package/dist/literals.js +96 -0
- package/dist/literals.js.map +1 -0
- package/dist/module_collector.d.ts +9 -0
- package/dist/module_collector.js +73 -0
- package/dist/module_collector.js.map +1 -0
- package/dist/module_set.d.ts +51 -0
- package/dist/module_set.js +1331 -0
- package/dist/module_set.js.map +1 -0
- package/dist/package_downloader.d.ts +4 -0
- package/dist/package_downloader.js +256 -0
- package/dist/package_downloader.js.map +1 -0
- package/dist/package_types.d.ts +30 -0
- package/dist/package_types.d.ts.map +1 -0
- package/dist/package_types.js +2 -0
- package/dist/package_types.js.map +1 -0
- package/dist/parser.d.ts +7 -0
- package/dist/parser.js +1335 -0
- package/dist/parser.js.map +1 -0
- package/dist/project_initializer.d.ts +2 -0
- package/dist/project_initializer.d.ts.map +1 -0
- package/dist/project_initializer.js +207 -0
- package/dist/project_initializer.js.map +1 -0
- package/dist/snapshotter.d.ts +16 -0
- package/dist/snapshotter.js +263 -0
- package/dist/snapshotter.js.map +1 -0
- package/dist/tokenizer.d.ts +18 -0
- package/dist/tokenizer.js +244 -0
- package/dist/tokenizer.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import * as fs from "fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { GetDependenciesFlow } from "./get_dependencies_flow.js";
|
|
4
|
+
import { REAL_FILE_SYSTEM } from "./io.js";
|
|
5
|
+
import { downloadPackage } from "./package_downloader.js";
|
|
6
|
+
export class DependencyManager {
|
|
7
|
+
constructor(rootDir, githubToken, fileReader = REAL_FILE_SYSTEM, packageDownloader = downloadPackage) {
|
|
8
|
+
this.rootDir = rootDir;
|
|
9
|
+
this.githubToken = githubToken;
|
|
10
|
+
this.fileReader = fileReader;
|
|
11
|
+
this.packageDownloader = packageDownloader;
|
|
12
|
+
}
|
|
13
|
+
async getDependencies(dependencies, writeOption = "write") {
|
|
14
|
+
const flow = new GetDependenciesFlow(await this.readDependenciesFile(), this.githubToken, this.packageDownloader);
|
|
15
|
+
const result = await flow.run(dependencies);
|
|
16
|
+
if (result.kind === "success" &&
|
|
17
|
+
writeOption === "write" &&
|
|
18
|
+
result.changed) {
|
|
19
|
+
await this.writeOnDisk(result.packages);
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
async writeOnDisk(packages) {
|
|
24
|
+
// Write everything to a temp directory first, then rename it.
|
|
25
|
+
const relPathToContent = new Map();
|
|
26
|
+
for (const [packageId, pkg] of Object.entries(packages)) {
|
|
27
|
+
for (const [modulePath, content] of Object.entries(pkg.modules)) {
|
|
28
|
+
const relPath = packageId +
|
|
29
|
+
modulePath
|
|
30
|
+
.substring(packageId.length)
|
|
31
|
+
.replace(/\.skir$/, ".readonly.skir");
|
|
32
|
+
relPathToContent.set(relPath, content);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
relPathToContent.set(DEPENDENCIES_FILENAME, JSON.stringify(packages, null, 2));
|
|
36
|
+
const unixMillis = Date.now();
|
|
37
|
+
const tempDir = this.externalDir + "." + unixMillis + ".tmp";
|
|
38
|
+
const limboDir = this.externalDir + ".~" + unixMillis + ".tmp";
|
|
39
|
+
let tempDirExists = false;
|
|
40
|
+
let limboDirExists = false;
|
|
41
|
+
try {
|
|
42
|
+
await fs.mkdir(tempDir, { recursive: true });
|
|
43
|
+
tempDirExists = true;
|
|
44
|
+
// Write all files in parallel
|
|
45
|
+
const writePromises = Array.from(relPathToContent.entries()).map(async ([relPath, content]) => {
|
|
46
|
+
const fullPath = path.join(tempDir, relPath);
|
|
47
|
+
const dir = path.dirname(fullPath);
|
|
48
|
+
await fs.mkdir(dir, { recursive: true });
|
|
49
|
+
await fs.writeFile(fullPath, content, "utf-8");
|
|
50
|
+
});
|
|
51
|
+
await Promise.all(writePromises);
|
|
52
|
+
try {
|
|
53
|
+
await fs.rename(this.externalDir, limboDir);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
// It's okay if externalDir doesn't exist yet.
|
|
57
|
+
const doesNotExist = error &&
|
|
58
|
+
typeof error === "object" &&
|
|
59
|
+
"code" in error &&
|
|
60
|
+
error.code === "ENOENT";
|
|
61
|
+
if (!doesNotExist) {
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
limboDirExists = true;
|
|
66
|
+
await fs.rename(tempDir, this.externalDir);
|
|
67
|
+
tempDirExists = false;
|
|
68
|
+
await fs.rm(limboDir, { recursive: true, force: true });
|
|
69
|
+
limboDirExists = false;
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
if (tempDirExists) {
|
|
73
|
+
try {
|
|
74
|
+
await fs.rm(tempDir, { recursive: true, force: true });
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
console.error(e);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (limboDirExists) {
|
|
81
|
+
try {
|
|
82
|
+
await fs.rm(limboDir, { recursive: true, force: true });
|
|
83
|
+
}
|
|
84
|
+
catch (e) {
|
|
85
|
+
console.error(e);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
get externalDir() {
|
|
91
|
+
return path.join(this.rootDir, "skir-external");
|
|
92
|
+
}
|
|
93
|
+
async readDependenciesFile() {
|
|
94
|
+
const dependenciesPath = path.join(this.externalDir, DEPENDENCIES_FILENAME);
|
|
95
|
+
const content = await this.fileReader.readTextFileAsync(dependenciesPath);
|
|
96
|
+
if (content === undefined) {
|
|
97
|
+
return {};
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
return JSON.parse(content);
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
console.error(`Failed to parse ${dependenciesPath}:`, error);
|
|
104
|
+
return {};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const DEPENDENCIES_FILENAME = "dependencies.json";
|
|
109
|
+
//# sourceMappingURL=dependency_manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependency_manager.js","sourceRoot":"","sources":["../src/dependency_manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAmB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAQ1D,MAAM,OAAO,iBAAiB;IAC5B,YACmB,OAAe,EACf,WAA+B,EAC/B,aAA8B,gBAAgB,EAC9C,oBAAuC,eAAe;QAHtD,YAAO,GAAP,OAAO,CAAQ;QACf,gBAAW,GAAX,WAAW,CAAoB;QAC/B,eAAU,GAAV,UAAU,CAAoC;QAC9C,sBAAiB,GAAjB,iBAAiB,CAAqC;IACtE,CAAC;IAEJ,KAAK,CAAC,eAAe,CACnB,YAAgC,EAChC,cAAoC,OAAO;QAE3C,MAAM,IAAI,GAAG,IAAI,mBAAmB,CAClC,MAAM,IAAI,CAAC,oBAAoB,EAAE,EACjC,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,iBAAiB,CACvB,CAAC;QACF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,YAAY,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AC,KAAK,CAAC,mBAAmB,gBAAgB,GAAG,EAAE,KAAK,CAAC,CAAC;YAC7D,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AAED,MAAM,qBAAqB,GAAG,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Doc, MutableDoc, Result, Token } from "skir-internal";
|
|
2
|
+
export declare function parseDocComment(docComment: Token, completionMode?: {
|
|
3
|
+
position: number;
|
|
4
|
+
}): Result<Doc>;
|
|
5
|
+
export declare function mergeDocs(docs: readonly Doc[]): MutableDoc;
|
|
6
|
+
//# sourceMappingURL=doc_comment_parser.d.ts.map
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
export function parseDocComment(docComment, completionMode) {
|
|
2
|
+
const parser = new DocCommentParser(docComment, completionMode);
|
|
3
|
+
return parser.parse();
|
|
4
|
+
}
|
|
5
|
+
class DocCommentParser {
|
|
6
|
+
constructor(docComment, completionMode) {
|
|
7
|
+
this.docComment = docComment;
|
|
8
|
+
this.completionMode = completionMode;
|
|
9
|
+
this.pieces = [];
|
|
10
|
+
this.errors = [];
|
|
11
|
+
this.currentText = "";
|
|
12
|
+
this.charIndex = -1;
|
|
13
|
+
const { text } = docComment;
|
|
14
|
+
if (text.startsWith("/// ")) {
|
|
15
|
+
this.content = text.slice(4);
|
|
16
|
+
}
|
|
17
|
+
else if (text.startsWith("///")) {
|
|
18
|
+
this.content = text.slice(3);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
throw new Error("Expected doc comment to start with ///");
|
|
22
|
+
}
|
|
23
|
+
this.charIndex = 0;
|
|
24
|
+
}
|
|
25
|
+
parse() {
|
|
26
|
+
this.parseDocComment();
|
|
27
|
+
// Add any remaining text
|
|
28
|
+
if (this.currentText.length > 0) {
|
|
29
|
+
this.pieces.push({ kind: "text", text: this.currentText });
|
|
30
|
+
}
|
|
31
|
+
const { pieces } = this;
|
|
32
|
+
const text = pieces
|
|
33
|
+
.map((p) => {
|
|
34
|
+
switch (p.kind) {
|
|
35
|
+
case "text":
|
|
36
|
+
return p.text;
|
|
37
|
+
case "reference":
|
|
38
|
+
return p.referenceRange.text;
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
.join("");
|
|
42
|
+
return {
|
|
43
|
+
result: {
|
|
44
|
+
text: text,
|
|
45
|
+
pieces: this.pieces,
|
|
46
|
+
},
|
|
47
|
+
errors: this.errors,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
parseDocComment() {
|
|
51
|
+
// Matches unescaped [ or ], OR escaped [[ or ]]
|
|
52
|
+
const specialCharRegex = /\[\[|\]\]|\[|\]/g;
|
|
53
|
+
while (this.charIndex < this.content.length) {
|
|
54
|
+
// Find next special character or escaped bracket
|
|
55
|
+
specialCharRegex.lastIndex = this.charIndex;
|
|
56
|
+
const match = specialCharRegex.exec(this.content);
|
|
57
|
+
if (!match) {
|
|
58
|
+
// No more special characters, add rest as text
|
|
59
|
+
this.currentText += this.content.slice(this.charIndex);
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
// Add text before the special character
|
|
63
|
+
if (match.index > this.charIndex) {
|
|
64
|
+
this.currentText += this.content.slice(this.charIndex, match.index);
|
|
65
|
+
}
|
|
66
|
+
const matched = match[0];
|
|
67
|
+
this.charIndex = match.index;
|
|
68
|
+
if (matched === "[[") {
|
|
69
|
+
// Escaped left bracket
|
|
70
|
+
this.currentText += "[";
|
|
71
|
+
this.charIndex += 2;
|
|
72
|
+
}
|
|
73
|
+
else if (matched === "]]") {
|
|
74
|
+
// Escaped right bracket
|
|
75
|
+
this.currentText += "]";
|
|
76
|
+
this.charIndex += 2;
|
|
77
|
+
}
|
|
78
|
+
else if (matched === "[") {
|
|
79
|
+
// Start of a reference - save current text if any
|
|
80
|
+
if (this.currentText.length > 0) {
|
|
81
|
+
this.pieces.push({ kind: "text", text: this.currentText });
|
|
82
|
+
this.currentText = "";
|
|
83
|
+
}
|
|
84
|
+
// Parse the reference
|
|
85
|
+
const reference = this.parseReference();
|
|
86
|
+
this.pieces.push(reference);
|
|
87
|
+
}
|
|
88
|
+
else if (matched === "]") {
|
|
89
|
+
// Unmatched right bracket - treat as text
|
|
90
|
+
this.currentText += matched;
|
|
91
|
+
this.charIndex++;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
parseReference() {
|
|
96
|
+
const { content, docComment } = this;
|
|
97
|
+
const leftBracketCharIndex = this.charIndex;
|
|
98
|
+
const contentOffset = docComment.text.length - content.length;
|
|
99
|
+
const startPosition = docComment.position + contentOffset + leftBracketCharIndex;
|
|
100
|
+
const rightBracketCharIndex = content.indexOf("]", leftBracketCharIndex);
|
|
101
|
+
// End position: right after the closing bracket or at end of the line if
|
|
102
|
+
// not found.
|
|
103
|
+
const endCharIndex = rightBracketCharIndex < 0 ? content.length : rightBracketCharIndex + 1;
|
|
104
|
+
const referenceText = content.slice(leftBracketCharIndex, endCharIndex);
|
|
105
|
+
const referenceRange = {
|
|
106
|
+
text: referenceText,
|
|
107
|
+
originalText: referenceText,
|
|
108
|
+
position: startPosition,
|
|
109
|
+
line: docComment.line,
|
|
110
|
+
colNumber: startPosition - docComment.line.position,
|
|
111
|
+
};
|
|
112
|
+
let hasError = false;
|
|
113
|
+
if (rightBracketCharIndex < 0) {
|
|
114
|
+
hasError = true;
|
|
115
|
+
this.errors.push({
|
|
116
|
+
token: referenceRange,
|
|
117
|
+
message: "Unterminated reference",
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
// Move past the left bracket
|
|
121
|
+
this.charIndex++;
|
|
122
|
+
const wordRegex = /[a-zA-Z][_a-zA-Z0-9]*/g;
|
|
123
|
+
const tokens = [];
|
|
124
|
+
while (this.charIndex < endCharIndex) {
|
|
125
|
+
const char = content[this.charIndex];
|
|
126
|
+
const contentOffset = docComment.text.length - content.length;
|
|
127
|
+
const position = docComment.position + contentOffset + this.charIndex;
|
|
128
|
+
const makeToken = (text) => ({
|
|
129
|
+
text: text,
|
|
130
|
+
originalText: text,
|
|
131
|
+
position: position,
|
|
132
|
+
line: docComment.line,
|
|
133
|
+
colNumber: position - docComment.line.position,
|
|
134
|
+
});
|
|
135
|
+
if (char === ".") {
|
|
136
|
+
// Dot token
|
|
137
|
+
tokens.push(makeToken("."));
|
|
138
|
+
this.charIndex++;
|
|
139
|
+
}
|
|
140
|
+
else if (/^[a-zA-Z]/.test(char)) {
|
|
141
|
+
// Start of a word token - use regex to match the whole word
|
|
142
|
+
wordRegex.lastIndex = this.charIndex;
|
|
143
|
+
const match = wordRegex.exec(content);
|
|
144
|
+
const word = match[0];
|
|
145
|
+
tokens.push(makeToken(word));
|
|
146
|
+
this.charIndex += word.length;
|
|
147
|
+
}
|
|
148
|
+
else if (char === "]") {
|
|
149
|
+
// Reached the end of the reference
|
|
150
|
+
tokens.push(makeToken("]"));
|
|
151
|
+
this.charIndex++;
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
// Invalid character in reference (including whitespace)
|
|
155
|
+
const contentOffset = docComment.text.length - content.length;
|
|
156
|
+
const column = this.docComment.colNumber + contentOffset + this.charIndex;
|
|
157
|
+
hasError = true;
|
|
158
|
+
this.errors.push({
|
|
159
|
+
token: referenceRange,
|
|
160
|
+
message: `Invalid character in reference at column ${column + 1}`,
|
|
161
|
+
});
|
|
162
|
+
// Exit loop
|
|
163
|
+
this.charIndex = endCharIndex;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (!hasError && this.completionMode) {
|
|
167
|
+
const { position } = this.completionMode;
|
|
168
|
+
const refAbsoluteStart = startPosition;
|
|
169
|
+
const refAbsoluteEnd = docComment.position + contentOffset + endCharIndex;
|
|
170
|
+
if (position >= refAbsoluteStart && position < refAbsoluteEnd) {
|
|
171
|
+
const inExistingWord = tokens.some((t) => {
|
|
172
|
+
return (/^[a-zA-Z]/.test(t.text) &&
|
|
173
|
+
position >= t.position &&
|
|
174
|
+
position <= t.position + t.text.length);
|
|
175
|
+
});
|
|
176
|
+
if (!inExistingWord) {
|
|
177
|
+
const fakeToken = {
|
|
178
|
+
text: "...",
|
|
179
|
+
originalText: "",
|
|
180
|
+
position: position,
|
|
181
|
+
line: docComment.line,
|
|
182
|
+
colNumber: position - docComment.line.position,
|
|
183
|
+
};
|
|
184
|
+
const insertIndex = tokens.findIndex((t) => t.position >= position);
|
|
185
|
+
if (insertIndex === -1) {
|
|
186
|
+
tokens.push(fakeToken);
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
tokens.splice(insertIndex, 0, fakeToken);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const nameParts = hasError ? [] : this.parseNameParts(tokens);
|
|
195
|
+
return {
|
|
196
|
+
kind: "reference",
|
|
197
|
+
nameParts: nameParts,
|
|
198
|
+
absolute: tokens[0]?.text === ".",
|
|
199
|
+
referee: undefined,
|
|
200
|
+
docComment: this.docComment,
|
|
201
|
+
referenceRange: referenceRange,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
parseNameParts(tokens) {
|
|
205
|
+
const nameParts = [];
|
|
206
|
+
let expect = "identifier or '.'";
|
|
207
|
+
for (const token of tokens) {
|
|
208
|
+
let expected;
|
|
209
|
+
if (/^[a-zA-Z]/.test(token.text) || token.text === "...") {
|
|
210
|
+
// Identifier token or fake completion token.
|
|
211
|
+
expected = expect === "identifier or '.'" || expect === "identifier";
|
|
212
|
+
expect = "'.' or ']'";
|
|
213
|
+
nameParts.push({
|
|
214
|
+
token: token,
|
|
215
|
+
declaration: undefined,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
else if (token.text === ".") {
|
|
219
|
+
expected = expect === "identifier or '.'" || expect === "'.' or ']'";
|
|
220
|
+
expect = "identifier";
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
if (token.text !== "]") {
|
|
224
|
+
throw new Error(`Unexpected token in doc reference: ${token.text}`);
|
|
225
|
+
}
|
|
226
|
+
expected = expect === "'.' or ']'";
|
|
227
|
+
}
|
|
228
|
+
if (!expected) {
|
|
229
|
+
this.errors.push({
|
|
230
|
+
token: token,
|
|
231
|
+
expected: expect,
|
|
232
|
+
});
|
|
233
|
+
return [];
|
|
234
|
+
}
|
|
235
|
+
if (token.text === "]") {
|
|
236
|
+
return nameParts;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
// An error has already been pushed to signify the unterminated reference.
|
|
240
|
+
return [];
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
export function mergeDocs(docs) {
|
|
244
|
+
if (docs.length <= 0) {
|
|
245
|
+
return EMPTY_DOC;
|
|
246
|
+
}
|
|
247
|
+
// Insert '\n' between each doc comment (== line)
|
|
248
|
+
const text = docs.map((d) => d.text).join("\n");
|
|
249
|
+
const pieces = [];
|
|
250
|
+
for (let i = 0; i < docs.length; ++i) {
|
|
251
|
+
const doc = docs[i];
|
|
252
|
+
if (i !== 0) {
|
|
253
|
+
pieces.push({
|
|
254
|
+
kind: "text",
|
|
255
|
+
text: "\n",
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
doc.pieces.forEach((p) => pieces.push(p));
|
|
259
|
+
}
|
|
260
|
+
return {
|
|
261
|
+
text: text,
|
|
262
|
+
pieces: pieces,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
const EMPTY_DOC = Object.freeze({
|
|
266
|
+
text: "",
|
|
267
|
+
pieces: Object.freeze([]),
|
|
268
|
+
});
|
|
269
|
+
//# sourceMappingURL=doc_comment_parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doc_comment_parser.js","sourceRoot":"","sources":["../src/doc_comment_parser.ts"],"names":[],"mappings":"AAaA,MAAM,UAAU,eAAe,CAC7B,UAAiB,EACjB,cAAqC;IAErC,MAAM,MAAM,GAAG,IAAI,gBAAgB,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IAChE,OAAO,MAAM,CAAC,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C,MAAM,CAAC;IACnC,IAAI,EAAE,EAAE;IACR,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;CAC1B,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ErrorSink, Module, MutableConstant, MutableMethod, MutableRecord, MutableRecordField, RecordKey, RecordLocation } from "skir-internal";
|
|
2
|
+
export type Documentee = MutableConstant | MutableMethod | MutableRecord | MutableRecordField;
|
|
3
|
+
/** Resolve the references in the doc comments of the given declaration. */
|
|
4
|
+
export declare function resolveDocReferences(documentee: Documentee, docModule: Module, getModule: (modulePath: string) => Module | undefined, recordMap: ReadonlyMap<RecordKey, RecordLocation>, errors: ErrorSink): void;
|
|
5
|
+
//# sourceMappingURL=doc_reference_resolver.d.ts.map
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { declarationsToExpectedNames, ExpectedNamesCollector, } from "./expected_names.js";
|
|
2
|
+
/** Resolve the references in the doc comments of the given declaration. */
|
|
3
|
+
export function resolveDocReferences(documentee, docModule, getModule, recordMap, errors) {
|
|
4
|
+
const doc = documentee.kind === "field" ? documentee.field.doc : documentee.doc;
|
|
5
|
+
const docReferences = doc.pieces.filter((p) => p.kind === "reference");
|
|
6
|
+
if (docReferences.length <= 0) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
// Build list of naming scopes to search, in order of priority.
|
|
10
|
+
const scopes = buildScopes(documentee, docModule, recordMap);
|
|
11
|
+
// Resolve each reference by searching through scopes in priority order.
|
|
12
|
+
for (const reference of docReferences) {
|
|
13
|
+
resolveReferenceInScopes(reference, scopes, docModule, getModule, errors);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function buildScopes(documentee, docModule, recordMap) {
|
|
17
|
+
const scopes = [];
|
|
18
|
+
const pushRecordAncestorsToScopes = (record) => {
|
|
19
|
+
const { key } = record;
|
|
20
|
+
const location = recordMap.get(key);
|
|
21
|
+
const ancestors = [...location.recordAncestors].reverse();
|
|
22
|
+
for (const ancestor of ancestors) {
|
|
23
|
+
scopes.push(ancestor);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const pushTypeToScopes = (type) => {
|
|
27
|
+
if (type) {
|
|
28
|
+
const recordKey = tryFindRecordForType(type);
|
|
29
|
+
if (recordKey) {
|
|
30
|
+
const { record } = recordMap.get(recordKey);
|
|
31
|
+
scopes.push(record);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
switch (documentee.kind) {
|
|
36
|
+
case "constant": {
|
|
37
|
+
scopes.push(docModule);
|
|
38
|
+
pushTypeToScopes(documentee.type);
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
case "field": {
|
|
42
|
+
const { field, record } = documentee;
|
|
43
|
+
pushRecordAncestorsToScopes(record);
|
|
44
|
+
scopes.push(docModule);
|
|
45
|
+
pushTypeToScopes(field.type);
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
case "method": {
|
|
49
|
+
scopes.push(docModule);
|
|
50
|
+
pushTypeToScopes(documentee.requestType);
|
|
51
|
+
pushTypeToScopes(documentee.responseType);
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
case "record": {
|
|
55
|
+
pushRecordAncestorsToScopes(documentee);
|
|
56
|
+
scopes.push(docModule);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return scopes;
|
|
61
|
+
}
|
|
62
|
+
function resolveReferenceInScopes(reference, scopes, docModule, getModule, errors) {
|
|
63
|
+
const { nameParts } = reference;
|
|
64
|
+
if (nameParts.length <= 0) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const expectedNamesCollector = new ExpectedNamesCollector();
|
|
68
|
+
for (const scope of scopes) {
|
|
69
|
+
if (reference.absolute && scope !== docModule) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const referee = tryResolveReference(nameParts, scope, docModule, getModule);
|
|
73
|
+
if (referee.kind === "no-match") {
|
|
74
|
+
expectedNamesCollector.collect(referee.expectedNames);
|
|
75
|
+
// Try the next scope.
|
|
76
|
+
}
|
|
77
|
+
else if (referee.kind === "failed-match") {
|
|
78
|
+
if (referee.error) {
|
|
79
|
+
errors.push(referee.error);
|
|
80
|
+
}
|
|
81
|
+
// Don't try the next scope.
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
reference.referee = referee;
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// No match in any scope. Report an error on the first name part.
|
|
90
|
+
const firstName = nameParts[0].token;
|
|
91
|
+
errors.push({
|
|
92
|
+
token: firstName,
|
|
93
|
+
message: "Not found",
|
|
94
|
+
expectedNames: expectedNamesCollector.expectedNames,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
// Try to resolve a reference by looking it up in the given scope.
|
|
98
|
+
function tryResolveReference(nameParts, scope, docModule, getModule) {
|
|
99
|
+
let firstNameMatched = false;
|
|
100
|
+
for (let i = 0; i < nameParts.length; i++) {
|
|
101
|
+
const namePart = nameParts[i];
|
|
102
|
+
const match = scope.nameToDeclaration[namePart.token.text];
|
|
103
|
+
if (!match) {
|
|
104
|
+
const expectedNames = declarationsToExpectedNames(scope.nameToDeclaration, (d) => scope === docModule ||
|
|
105
|
+
(d.kind !== "import" && d.kind !== "import-alias"));
|
|
106
|
+
if (firstNameMatched) {
|
|
107
|
+
return {
|
|
108
|
+
kind: "failed-match",
|
|
109
|
+
error: {
|
|
110
|
+
token: namePart.token,
|
|
111
|
+
message: "Not found",
|
|
112
|
+
expectedNames: expectedNames,
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
return {
|
|
118
|
+
kind: "no-match",
|
|
119
|
+
expectedNames: expectedNames,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
firstNameMatched = true;
|
|
124
|
+
const isLastPart = i === nameParts.length - 1;
|
|
125
|
+
const makeExpectedToBeLastNameFailedMatch = () => ({
|
|
126
|
+
kind: "failed-match",
|
|
127
|
+
error: {
|
|
128
|
+
token: namePart.token,
|
|
129
|
+
message: "Expected to be the last name in the sequence",
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
switch (match.kind) {
|
|
133
|
+
case "constant":
|
|
134
|
+
case "method": {
|
|
135
|
+
namePart.declaration = match;
|
|
136
|
+
if (isLastPart) {
|
|
137
|
+
return match;
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
return makeExpectedToBeLastNameFailedMatch();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
case "record": {
|
|
144
|
+
scope = match;
|
|
145
|
+
namePart.declaration = match;
|
|
146
|
+
if (isLastPart) {
|
|
147
|
+
return match;
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
case "field": {
|
|
154
|
+
namePart.declaration = match;
|
|
155
|
+
if (isLastPart) {
|
|
156
|
+
return {
|
|
157
|
+
kind: "field",
|
|
158
|
+
field: match,
|
|
159
|
+
record: scope,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
return makeExpectedToBeLastNameFailedMatch();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
case "import-alias": {
|
|
167
|
+
if (isLastPart) {
|
|
168
|
+
return {
|
|
169
|
+
kind: "failed-match",
|
|
170
|
+
error: {
|
|
171
|
+
token: namePart.token,
|
|
172
|
+
message: "Cannot be the last name in the sequence",
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
// Falls through
|
|
177
|
+
}
|
|
178
|
+
case "import": {
|
|
179
|
+
if (scope !== docModule) {
|
|
180
|
+
// Cannot refer to other module's imports.
|
|
181
|
+
return {
|
|
182
|
+
kind: "failed-match",
|
|
183
|
+
error: {
|
|
184
|
+
token: namePart.token,
|
|
185
|
+
message: "Cannot refer to other module's imports",
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
const { resolvedModulePath } = match;
|
|
190
|
+
if (!resolvedModulePath) {
|
|
191
|
+
return {
|
|
192
|
+
kind: "failed-match",
|
|
193
|
+
error: null, // An error has already been registered
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
const importedModule = getModule(resolvedModulePath);
|
|
197
|
+
if (!importedModule) {
|
|
198
|
+
return {
|
|
199
|
+
kind: "failed-match",
|
|
200
|
+
error: null, // An error has already been registered
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
scope = importedModule;
|
|
204
|
+
if (match.kind === "import") {
|
|
205
|
+
// Rewind to this name part, but with the imported module as scope.
|
|
206
|
+
--i;
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
namePart.declaration = match;
|
|
210
|
+
}
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
case "removed": {
|
|
214
|
+
throw new TypeError();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
throw new Error("Unreachable");
|
|
219
|
+
}
|
|
220
|
+
function tryFindRecordForType(type) {
|
|
221
|
+
switch (type.kind) {
|
|
222
|
+
case "array":
|
|
223
|
+
return tryFindRecordForType(type.item);
|
|
224
|
+
case "optional":
|
|
225
|
+
return tryFindRecordForType(type.other);
|
|
226
|
+
case "record":
|
|
227
|
+
return type.key;
|
|
228
|
+
case "primitive":
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
//# sourceMappingURL=doc_reference_resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doc_reference_resolver.js","sourceRoot":"","sources":["../src/doc_reference_resolver.ts"],"names":[],"mappings":"AAoBA,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAQ7B,2EAA2E;AAC3E,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