aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-cov/src/instrument_solidity.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/sol-cov/src/instrument_solidity.ts')
-rw-r--r--packages/sol-cov/src/instrument_solidity.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/packages/sol-cov/src/instrument_solidity.ts b/packages/sol-cov/src/instrument_solidity.ts
new file mode 100644
index 000000000..ac58270cb
--- /dev/null
+++ b/packages/sol-cov/src/instrument_solidity.ts
@@ -0,0 +1,16 @@
+import * as fs from 'fs';
+import * as _ from 'lodash';
+import * as path from 'path';
+import * as SolidityParser from 'solidity-parser-sc';
+
+import { ASTVisitor, CoverageEntriesDescription } from './ast_visitor';
+import { getLocationByOffset } from './source_maps';
+
+export const collectCoverageEntries = (contractSource: string, fileName: string) => {
+ const ast = SolidityParser.parse(contractSource);
+ const locationByOffset = getLocationByOffset(contractSource);
+ const astVisitor = new ASTVisitor(locationByOffset);
+ astVisitor.walkAST(ast);
+ const coverageEntries = astVisitor.getCollectedCoverageEntries();
+ return coverageEntries;
+};