From efb0ee4c02e3a8048ae2395158f11dced8c5f90e Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 13 Mar 2018 11:53:45 +0100 Subject: Start using solidity-parser-antlr --- packages/sol-cov/src/collect_coverage_entries.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'packages/sol-cov/src/collect_coverage_entries.ts') diff --git a/packages/sol-cov/src/collect_coverage_entries.ts b/packages/sol-cov/src/collect_coverage_entries.ts index d29fa2c37..6da81fbfc 100644 --- a/packages/sol-cov/src/collect_coverage_entries.ts +++ b/packages/sol-cov/src/collect_coverage_entries.ts @@ -2,7 +2,7 @@ import * as ethUtil from 'ethereumjs-util'; import * as fs from 'fs'; import * as _ from 'lodash'; import * as path from 'path'; -import * as SolidityParser from 'solidity-parser-sc'; +import * as parser from 'solidity-parser-antlr'; import { ASTVisitor, CoverageEntriesDescription } from './ast_visitor'; import { getLocationByOffset } from './source_maps'; @@ -13,11 +13,11 @@ const coverageEntriesBySourceHash: { [sourceHash: string]: CoverageEntriesDescri export const collectCoverageEntries = (contractSource: string, fileName: string) => { const sourceHash = ethUtil.sha3(contractSource).toString('hex'); if (_.isUndefined(coverageEntriesBySourceHash[sourceHash])) { - const ast = SolidityParser.parse(contractSource); + const ast = parser.parse(contractSource, { range: true }); const locationByOffset = getLocationByOffset(contractSource); - const astVisitor = new ASTVisitor(locationByOffset); - astVisitor.walkAST(ast); - coverageEntriesBySourceHash[sourceHash] = astVisitor.getCollectedCoverageEntries(); + const visitor = new ASTVisitor(locationByOffset); + parser.visit(ast, visitor); + coverageEntriesBySourceHash[sourceHash] = visitor.getCollectedCoverageEntries(); } const coverageEntriesDescription = coverageEntriesBySourceHash[sourceHash]; return coverageEntriesDescription; -- cgit