diff options
author | perissology <perissology@protonmail.com> | 2018-06-25 22:55:19 +0800 |
---|---|---|
committer | perissology <perissology@protonmail.com> | 2018-06-25 22:55:19 +0800 |
commit | 1a4e99431bf0cfc8c5db2235a935d62ebb8469b2 (patch) | |
tree | 9755eee5cfd2d71b3c14c5276c11bf2ea6c79b73 /packages | |
parent | bbd414bdcd3bcbe3a00ff38664cd9c6e488a7d6a (diff) | |
download | dexon-0x-contracts-1a4e99431bf0cfc8c5db2235a935d62ebb8469b2.tar.gz dexon-0x-contracts-1a4e99431bf0cfc8c5db2235a935d62ebb8469b2.tar.zst dexon-0x-contracts-1a4e99431bf0cfc8c5db2235a935d62ebb8469b2.zip |
support ignoring entire contracts
Diffstat (limited to 'packages')
-rw-r--r-- | packages/sol-cov/src/ast_visitor.ts | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/packages/sol-cov/src/ast_visitor.ts b/packages/sol-cov/src/ast_visitor.ts index 49b7ac4bd..166cf13bd 100644 --- a/packages/sol-cov/src/ast_visitor.ts +++ b/packages/sol-cov/src/ast_visitor.ts @@ -23,11 +23,13 @@ export class ASTVisitor { private _modifiersStatementIds: number[] = []; private _statementMap: StatementMap = {}; private _locationByOffset: LocationByOffset; - private _ignoreRangesBeginingAt: number[]; + private _ignoreRangesBeginningAt: number[]; + // keep track of contract/function ranges that are to be ignored + // so we can also ignore any children nodes within the contract/function private _ignoreRangesWithin: Array<[number, number]> = []; - constructor(locationByOffset: LocationByOffset, ignoreRangesBeginingAt: number[] = []) { + constructor(locationByOffset: LocationByOffset, ignoreRangesBeginningAt: number[] = []) { this._locationByOffset = locationByOffset; - this._ignoreRangesBeginingAt = ignoreRangesBeginingAt; + this._ignoreRangesBeginningAt = ignoreRangesBeginningAt; } public getCollectedCoverageEntries(): CoverageEntriesDescription { const coverageEntriesDescription = { @@ -45,6 +47,11 @@ export class ASTVisitor { public FunctionDefinition(ast: Parser.FunctionDefinition): void { this._visitFunctionLikeDefinition(ast); } + public ContractDefinition(ast: Parser.ContractDefinition): void { + if (this._ignoreExpression(ast)) { + this._ignoreRangesWithin.push(ast.range as [number, number]); + } + } public ModifierDefinition(ast: Parser.ModifierDefinition): void { this._visitFunctionLikeDefinition(ast); } @@ -143,13 +150,10 @@ export class ASTVisitor { this._ignoreRangesWithin, ([rangeStart, rangeEnd]: [number, number]) => astStart >= rangeStart && astEnd <= rangeEnd, ); - return this._ignoreRangesBeginingAt.includes(astStart) || isRangeIgnored; + return this._ignoreRangesBeginningAt.includes(astStart) || isRangeIgnored; } private _visitFunctionLikeDefinition(ast: Parser.ModifierDefinition | Parser.FunctionDefinition): void { if (this._ignoreExpression(ast)) { - // we want to ignore everything within this function - // add this nodes range to the ignoreRangesWithin array - // so we can ignore any later nodes that are children of this node this._ignoreRangesWithin.push(ast.range as [number, number]); return; } |