UNPKG

@openzeppelin/upgrade-safe-transpiler

Version:

Solidity preprocessor used to generate OpenZeppelin Contracts Upgrade Safe.

31 lines 1.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.renameInheritdoc = renameInheritdoc; const utils_1 = require("solidity-ast/utils"); const rename_1 = require("../rename"); const ast_utils_1 = require("../solc/ast-utils"); const match_1 = require("../utils/match"); function* renameInheritdoc(sourceUnit, { readOriginal, getData, resolver }) { for (const contract of (0, utils_1.findAll)('ContractDefinition', sourceUnit)) { const baseContracts = contract.linearizedBaseContracts.map(i => resolver.resolveContract(i)); for (const doc of (0, utils_1.findAll)('StructuredDocumentation', contract)) { const bounds = (0, ast_utils_1.getNodeBounds)(doc); const re = /(@inheritdoc\s+)([a-zA-Z0-9$_]+)/; const match = (0, match_1.matchBuffer)(readOriginal(doc, 'buffer'), re); if (match) { yield { start: bounds.start + match.start + match.captureLengths[0], length: match.captureLengths[1], kind: 'rename-inheritdoc', transform: source => { const ref = baseContracts.find(c => c?.canonicalName == source); return ref !== undefined && getData(ref).importFromPeer !== undefined ? source : source.replace(/[a-zA-Z0-9$_]+$/, rename_1.renameContract); }, }; } } } } //# sourceMappingURL=rename-inheritdoc.js.map