Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
rename function
Browse files Browse the repository at this point in the history
  • Loading branch information
ewingrj committed Jun 27, 2018
1 parent 92cb9c3 commit e0a2afc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions packages/sol-cov/src/ast_visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
Expand Down Expand Up @@ -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);
Expand All @@ -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++] = {
Expand All @@ -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);
Expand All @@ -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,
Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/sol-cov/src/collect_coverage_entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } = {};

Expand All @@ -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 = [];
Expand Down

0 comments on commit e0a2afc

Please sign in to comment.