aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-cov/src
diff options
context:
space:
mode:
authorperissology <perissology@protonmail.com>2018-06-27 22:26:12 +0800
committerperissology <perissology@protonmail.com>2018-06-27 22:26:12 +0800
commite0a2afc068a48f58786bc3a3952ffe024edc037c (patch)
tree1a8b3723d96399ce9d1e4537554e0d08e045ba9e /packages/sol-cov/src
parent92cb9c3807917049b392d86160e7d88f73a5c7b4 (diff)
downloaddexon-sol-tools-e0a2afc068a48f58786bc3a3952ffe024edc037c.tar
dexon-sol-tools-e0a2afc068a48f58786bc3a3952ffe024edc037c.tar.gz
dexon-sol-tools-e0a2afc068a48f58786bc3a3952ffe024edc037c.tar.bz2
dexon-sol-tools-e0a2afc068a48f58786bc3a3952ffe024edc037c.tar.lz
dexon-sol-tools-e0a2afc068a48f58786bc3a3952ffe024edc037c.tar.xz
dexon-sol-tools-e0a2afc068a48f58786bc3a3952ffe024edc037c.tar.zst
dexon-sol-tools-e0a2afc068a48f58786bc3a3952ffe024edc037c.zip
rename function
Diffstat (limited to 'packages/sol-cov/src')
-rw-r--r--packages/sol-cov/src/ast_visitor.ts12
-rw-r--r--packages/sol-cov/src/collect_coverage_entries.ts4
2 files changed, 8 insertions, 8 deletions
diff --git a/packages/sol-cov/src/ast_visitor.ts b/packages/sol-cov/src/ast_visitor.ts
index 166cf13bd..a6bca4704 100644
--- a/packages/sol-cov/src/ast_visitor.ts
+++ b/packages/sol-cov/src/ast_visitor.ts
@@ -48,7 +48,7 @@ export class ASTVisitor {
this._visitFunctionLikeDefinition(ast);
}
public ContractDefinition(ast: Parser.ContractDefinition): void {
- if (this._ignoreExpression(ast)) {
+ if (this._shouldIgnoreExpression(ast)) {
this._ignoreRangesWithin.push(ast.range as [number, number]);
}
}
@@ -106,7 +106,7 @@ export class ASTVisitor {
public ModifierInvocation(ast: Parser.ModifierInvocation): void {
const BUILTIN_MODIFIERS = ['public', 'view', 'payable', 'external', 'internal', 'pure', 'constant'];
if (!_.includes(BUILTIN_MODIFIERS, ast.name)) {
- if (this._ignoreExpression(ast)) {
+ if (this._shouldIgnoreExpression(ast)) {
return;
}
this._modifiersStatementIds.push(this._entryId);
@@ -119,7 +119,7 @@ export class ASTVisitor {
right: Parser.ASTNode,
type: BranchType,
): void {
- if (this._ignoreExpression(ast)) {
+ if (this._shouldIgnoreExpression(ast)) {
return;
}
this._branchMap[this._entryId++] = {
@@ -129,7 +129,7 @@ export class ASTVisitor {
};
}
private _visitStatement(ast: Parser.ASTNode): void {
- if (this._ignoreExpression(ast)) {
+ if (this._shouldIgnoreExpression(ast)) {
return;
}
this._statementMap[this._entryId++] = this._getExpressionRange(ast);
@@ -144,7 +144,7 @@ export class ASTVisitor {
};
return range;
}
- private _ignoreExpression(ast: Parser.ASTNode): boolean {
+ private _shouldIgnoreExpression(ast: Parser.ASTNode): boolean {
const [astStart, astEnd] = ast.range as [number, number];
const isRangeIgnored = _.some(
this._ignoreRangesWithin,
@@ -153,7 +153,7 @@ export class ASTVisitor {
return this._ignoreRangesBeginningAt.includes(astStart) || isRangeIgnored;
}
private _visitFunctionLikeDefinition(ast: Parser.ModifierDefinition | Parser.FunctionDefinition): void {
- if (this._ignoreExpression(ast)) {
+ if (this._shouldIgnoreExpression(ast)) {
this._ignoreRangesWithin.push(ast.range as [number, number]);
return;
}
diff --git a/packages/sol-cov/src/collect_coverage_entries.ts b/packages/sol-cov/src/collect_coverage_entries.ts
index 703af3099..bdbcd613e 100644
--- a/packages/sol-cov/src/collect_coverage_entries.ts
+++ b/packages/sol-cov/src/collect_coverage_entries.ts
@@ -5,6 +5,8 @@ import * as parser from 'solidity-parser-antlr';
import { ASTVisitor, CoverageEntriesDescription } from './ast_visitor';
import { getLocationByOffset } from './source_maps';
+const IGNORE_RE = /\/\*\s*solcov\s+ignore\s+next\s*\*\/\s*/gm;
+
// Parsing source code for each transaction/code is slow and therefore we cache it
const coverageEntriesBySourceHash: { [sourceHash: string]: CoverageEntriesDescription } = {};
@@ -22,8 +24,6 @@ export const collectCoverageEntries = (contractSource: string) => {
return coverageEntriesDescription;
};
-const IGNORE_RE = /\/\*\s*solcov\s+ignore\s+next\s*\*\/\s*/gm;
-
// Gather the start index of all code blocks preceeded by "/* solcov ignore next */"
function gatherRangesToIgnore(contractSource: string): number[] {
const ignoreRangesStart = [];