1 | "use strict";
|
2 |
|
3 |
|
4 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
5 | if (k2 === undefined) k2 = k;
|
6 | var desc = Object.getOwnPropertyDescriptor(m, k);
|
7 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
8 | desc = { enumerable: true, get: function() { return m[k]; } };
|
9 | }
|
10 | Object.defineProperty(o, k2, desc);
|
11 | }) : (function(o, m, k, k2) {
|
12 | if (k2 === undefined) k2 = k;
|
13 | o[k2] = m[k];
|
14 | }));
|
15 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
16 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
17 | }) : function(o, v) {
|
18 | o["default"] = v;
|
19 | });
|
20 | var __importStar = (this && this.__importStar) || function (mod) {
|
21 | if (mod && mod.__esModule) return mod;
|
22 | var result = {};
|
23 | if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
24 | __setModuleDefault(result, mod);
|
25 | return result;
|
26 | };
|
27 | Object.defineProperty(exports, "__esModule", { value: true });
|
28 | exports.PackageDocComment = void 0;
|
29 | const ts = __importStar(require("typescript"));
|
30 | class PackageDocComment {
|
31 | |
32 |
|
33 |
|
34 | static tryFindInSourceFile(sourceFile, collector) {
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 | let packageCommentRange = undefined;
|
48 | for (const commentRange of ts.getLeadingCommentRanges(sourceFile.text, sourceFile.getFullStart()) || []) {
|
49 | if (commentRange.kind === ts.SyntaxKind.MultiLineCommentTrivia) {
|
50 | const commentBody = sourceFile.text.substring(commentRange.pos, commentRange.end);
|
51 |
|
52 | if (/^\s*\/\*\*/.test(commentBody)) {
|
53 |
|
54 |
|
55 | if (/\@packageDocumentation/i.test(commentBody)) {
|
56 | packageCommentRange = commentRange;
|
57 | }
|
58 | break;
|
59 | }
|
60 | }
|
61 | }
|
62 | if (!packageCommentRange) {
|
63 |
|
64 |
|
65 | for (const statement of sourceFile.statements) {
|
66 | const ranges = [];
|
67 | ranges.push(...(ts.getLeadingCommentRanges(sourceFile.text, statement.getFullStart()) || []));
|
68 | ranges.push(...(ts.getTrailingCommentRanges(sourceFile.text, statement.getEnd()) || []));
|
69 | for (const commentRange of ranges) {
|
70 | const commentBody = sourceFile.text.substring(commentRange.pos, commentRange.end);
|
71 | if (/\@packageDocumentation/i.test(commentBody)) {
|
72 | collector.messageRouter.addAnalyzerIssueForPosition("ae-misplaced-package-tag" , 'The @packageDocumentation comment must appear at the top of entry point *.d.ts file', sourceFile, commentRange.pos);
|
73 | break;
|
74 | }
|
75 | }
|
76 | }
|
77 | }
|
78 | return packageCommentRange;
|
79 | }
|
80 | }
|
81 | exports.PackageDocComment = PackageDocComment;
|
82 |
|
\ | No newline at end of file |