@microsoft/api-extractor
Version:
Validate, document, and review the exported API for a TypeScript library
61 lines (59 loc) • 2.4 kB
JavaScript
;
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
const AstPackage_1 = require("../ast/AstPackage");
const AstEnum_1 = require("../ast/AstEnum");
const AstEnumValue_1 = require("../ast/AstEnumValue");
const AstFunction_1 = require("../ast/AstFunction");
const AstStructuredType_1 = require("../ast/AstStructuredType");
const AstMethod_1 = require("../ast/AstMethod");
const AstNamespace_1 = require("../ast/AstNamespace");
const AstProperty_1 = require("../ast/AstProperty");
const AstModuleVariable_1 = require("../ast/AstModuleVariable");
/**
* This is a helper class that provides a standard way to walk the AstItem
* abstract syntax tree.
*/
class AstItemVisitor {
visit(astItem, refObject) {
if (astItem instanceof AstStructuredType_1.default) {
this.visitAstStructuredType(astItem, refObject);
}
else if (astItem instanceof AstEnum_1.default) {
this.visitAstEnum(astItem, refObject);
}
else if (astItem instanceof AstEnumValue_1.default) {
this.visitAstEnumValue(astItem, refObject);
}
else if (astItem instanceof AstFunction_1.default) {
this.visitAstFunction(astItem, refObject);
}
else if (astItem instanceof AstPackage_1.default) {
this.visitAstPackage(astItem, refObject);
}
else if (astItem instanceof AstProperty_1.default) {
this.visitAstProperty(astItem, refObject);
}
else if (astItem instanceof AstMethod_1.default) {
this.visitAstMethod(astItem, refObject);
}
else if (astItem instanceof AstNamespace_1.default) {
this.visitAstNamespace(astItem, refObject);
}
else if (astItem instanceof AstModuleVariable_1.default) {
this.visitAstModuleVariable(astItem, refObject);
}
else {
throw new Error('Not implemented');
}
}
visitAstMethod(astMethod, refObject) {
this.visitAstMember(astMethod, refObject);
}
visitAstProperty(astProperty, refObject) {
this.visitAstMember(astProperty, refObject);
}
}
exports.default = AstItemVisitor;
//# sourceMappingURL=AstItemVisitor.js.map