rename function

This commit is contained in:
perissology 2018-06-27 07:26:12 -07:00
parent 92cb9c3807
commit e0a2afc068
2 changed files with 8 additions and 8 deletions

View File

@ -48,7 +48,7 @@ export class ASTVisitor {
this._visitFunctionLikeDefinition(ast); this._visitFunctionLikeDefinition(ast);
} }
public ContractDefinition(ast: Parser.ContractDefinition): void { public ContractDefinition(ast: Parser.ContractDefinition): void {
if (this._ignoreExpression(ast)) { if (this._shouldIgnoreExpression(ast)) {
this._ignoreRangesWithin.push(ast.range as [number, number]); this._ignoreRangesWithin.push(ast.range as [number, number]);
} }
} }
@ -106,7 +106,7 @@ export class ASTVisitor {
public ModifierInvocation(ast: Parser.ModifierInvocation): void { public ModifierInvocation(ast: Parser.ModifierInvocation): void {
const BUILTIN_MODIFIERS = ['public', 'view', 'payable', 'external', 'internal', 'pure', 'constant']; const BUILTIN_MODIFIERS = ['public', 'view', 'payable', 'external', 'internal', 'pure', 'constant'];
if (!_.includes(BUILTIN_MODIFIERS, ast.name)) { if (!_.includes(BUILTIN_MODIFIERS, ast.name)) {
if (this._ignoreExpression(ast)) { if (this._shouldIgnoreExpression(ast)) {
return; return;
} }
this._modifiersStatementIds.push(this._entryId); this._modifiersStatementIds.push(this._entryId);
@ -119,7 +119,7 @@ export class ASTVisitor {
right: Parser.ASTNode, right: Parser.ASTNode,
type: BranchType, type: BranchType,
): void { ): void {
if (this._ignoreExpression(ast)) { if (this._shouldIgnoreExpression(ast)) {
return; return;
} }
this._branchMap[this._entryId++] = { this._branchMap[this._entryId++] = {
@ -129,7 +129,7 @@ export class ASTVisitor {
}; };
} }
private _visitStatement(ast: Parser.ASTNode): void { private _visitStatement(ast: Parser.ASTNode): void {
if (this._ignoreExpression(ast)) { if (this._shouldIgnoreExpression(ast)) {
return; return;
} }
this._statementMap[this._entryId++] = this._getExpressionRange(ast); this._statementMap[this._entryId++] = this._getExpressionRange(ast);
@ -144,7 +144,7 @@ export class ASTVisitor {
}; };
return range; return range;
} }
private _ignoreExpression(ast: Parser.ASTNode): boolean { private _shouldIgnoreExpression(ast: Parser.ASTNode): boolean {
const [astStart, astEnd] = ast.range as [number, number]; const [astStart, astEnd] = ast.range as [number, number];
const isRangeIgnored = _.some( const isRangeIgnored = _.some(
this._ignoreRangesWithin, this._ignoreRangesWithin,
@ -153,7 +153,7 @@ export class ASTVisitor {
return this._ignoreRangesBeginningAt.includes(astStart) || isRangeIgnored; return this._ignoreRangesBeginningAt.includes(astStart) || isRangeIgnored;
} }
private _visitFunctionLikeDefinition(ast: Parser.ModifierDefinition | Parser.FunctionDefinition): void { private _visitFunctionLikeDefinition(ast: Parser.ModifierDefinition | Parser.FunctionDefinition): void {
if (this._ignoreExpression(ast)) { if (this._shouldIgnoreExpression(ast)) {
this._ignoreRangesWithin.push(ast.range as [number, number]); this._ignoreRangesWithin.push(ast.range as [number, number]);
return; return;
} }

View File

@ -5,6 +5,8 @@ import * as parser from 'solidity-parser-antlr';
import { ASTVisitor, CoverageEntriesDescription } from './ast_visitor'; import { ASTVisitor, CoverageEntriesDescription } from './ast_visitor';
import { getLocationByOffset } from './source_maps'; 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 // Parsing source code for each transaction/code is slow and therefore we cache it
const coverageEntriesBySourceHash: { [sourceHash: string]: CoverageEntriesDescription } = {}; const coverageEntriesBySourceHash: { [sourceHash: string]: CoverageEntriesDescription } = {};
@ -22,8 +24,6 @@ export const collectCoverageEntries = (contractSource: string) => {
return coverageEntriesDescription; 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 */" // Gather the start index of all code blocks preceeded by "/* solcov ignore next */"
function gatherRangesToIgnore(contractSource: string): number[] { function gatherRangesToIgnore(contractSource: string): number[] {
const ignoreRangesStart = []; const ignoreRangesStart = [];