exclusionFactory.js 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. "use strict";
  2. /**
  3. * @license
  4. * Copyright 2013 Palantir Technologies, Inc.
  5. *
  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
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  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.
  17. */
  18. Object.defineProperty(exports, "__esModule", { value: true });
  19. var utils_1 = require("../../utils");
  20. var blockExclusion_1 = require("./blockExclusion");
  21. var classExclusion_1 = require("./classExclusion");
  22. var tagExclusion_1 = require("./tagExclusion");
  23. var ExclusionFactory = /** @class */ (function () {
  24. function ExclusionFactory() {
  25. }
  26. ExclusionFactory.prototype.constructExclusionsMap = function (ruleArguments) {
  27. var exclusionsMap = new Map();
  28. for (var _i = 0, ruleArguments_1 = ruleArguments; _i < ruleArguments_1.length; _i++) {
  29. var ruleArgument = ruleArguments_1[_i];
  30. this.addRequirements(exclusionsMap, ruleArgument);
  31. }
  32. return exclusionsMap;
  33. };
  34. ExclusionFactory.prototype.addRequirements = function (exclusionsMap, descriptors) {
  35. if (typeof descriptors === "string") {
  36. exclusionsMap.set(descriptors, this.createRequirementsForDocType(descriptors, {}));
  37. return;
  38. }
  39. for (var docType in descriptors) {
  40. if (utils_1.hasOwnProperty(descriptors, docType)) {
  41. exclusionsMap.set(docType, this.createRequirementsForDocType(docType, descriptors[docType]));
  42. }
  43. }
  44. };
  45. ExclusionFactory.prototype.createRequirementsForDocType = function (docType, descriptor) {
  46. var requirements = [];
  47. if (docType === "methods" || docType === "properties") {
  48. requirements.push(new classExclusion_1.ClassExclusion(descriptor));
  49. }
  50. else {
  51. requirements.push(new blockExclusion_1.BlockExclusion(descriptor));
  52. }
  53. if (descriptor.tags !== undefined) {
  54. requirements.push(new tagExclusion_1.TagExclusion(descriptor));
  55. }
  56. return requirements;
  57. };
  58. return ExclusionFactory;
  59. }());
  60. exports.ExclusionFactory = ExclusionFactory;