4 * Copyright 2013 Palantir Technologies, Inc.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 Object.defineProperty(exports, "__esModule", { value: true });
19 var tslib_1 = require("tslib");
20 var ts = require("typescript");
21 var exclusion_1 = require("./exclusion");
22 var TagExclusion = /** @class */ (function (_super) {
23 tslib_1.__extends(TagExclusion, _super);
24 function TagExclusion() {
25 var _this = _super !== null && _super.apply(this, arguments) || this;
26 _this.contentTags = _this.descriptor.tags === undefined ? {} : _this.descriptor.tags.content;
27 _this.existenceTags = new Set(_this.descriptor.tags !== undefined && _this.descriptor.tags.existence !== undefined
28 ? _this.descriptor.tags.existence
32 TagExclusion.prototype.excludes = function (node) {
33 var documentationNode = this.getDocumentationNode(node);
34 var tagsWithContents = this.parseTagsWithContents(documentationNode.getFullText());
35 for (var _i = 0, tagsWithContents_1 = tagsWithContents; _i < tagsWithContents_1.length; _i++) {
36 var tagWithContent = tagsWithContents_1[_i];
37 if (this.existenceTags.has(tagWithContent[0])) {
40 var matcherBody = this.contentTags[tagWithContent[0]];
41 if (matcherBody === undefined) {
44 if (new RegExp(matcherBody).test(tagWithContent[1])) {
50 TagExclusion.prototype.getDocumentationNode = function (node) {
51 if (node.kind === ts.SyntaxKind.VariableDeclaration) {
56 TagExclusion.prototype.parseTagsWithContents = function (nodeText) {
57 if (nodeText === undefined) {
60 var docMatches = nodeText.match(/\/\*\*\s*\n?([^\*]*(\*[^\/])?)*\*\//);
61 if (docMatches === null || docMatches.length === 0) {
64 var lines = docMatches[0].match(/[\r\n\s]*\*\s*@.*[\r\n\s]/g);
68 return lines.map(function (line) {
69 var body = line.substring(line.indexOf("@"));
70 var firstSpaceIndex = body.search(/\s/);
71 return [body.substring(1, firstSpaceIndex), body.substring(firstSpaceIndex).trim()];
75 }(exclusion_1.Exclusion));
76 exports.TagExclusion = TagExclusion;