diff options
author | Alex Browne <stephenalexbrowne@gmail.com> | 2018-06-21 03:36:04 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-21 03:36:04 +0800 |
commit | 6fe31587780ab309015d392747cebe61ff82b679 (patch) | |
tree | 63e4da546e294a1a1e042130c1db2cc4d498e54f /packages/sol-cov/src/utils.ts | |
parent | f5decb1d7e8de9a198f1cf1b258a043181ce26d5 (diff) | |
parent | bbd12e33ec2436b9a483ec41799fd15839593785 (diff) | |
download | dexon-sol-tools-6fe31587780ab309015d392747cebe61ff82b679.tar dexon-sol-tools-6fe31587780ab309015d392747cebe61ff82b679.tar.gz dexon-sol-tools-6fe31587780ab309015d392747cebe61ff82b679.tar.bz2 dexon-sol-tools-6fe31587780ab309015d392747cebe61ff82b679.tar.lz dexon-sol-tools-6fe31587780ab309015d392747cebe61ff82b679.tar.xz dexon-sol-tools-6fe31587780ab309015d392747cebe61ff82b679.tar.zst dexon-sol-tools-6fe31587780ab309015d392747cebe61ff82b679.zip |
Merge pull request #725 from 0xProject/feature/revert-trace-code-snippets
Include source code snippets in revert stack traces
Diffstat (limited to 'packages/sol-cov/src/utils.ts')
-rw-r--r-- | packages/sol-cov/src/utils.ts | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/packages/sol-cov/src/utils.ts b/packages/sol-cov/src/utils.ts index 4f16a1cda..d31696636 100644 --- a/packages/sol-cov/src/utils.ts +++ b/packages/sol-cov/src/utils.ts @@ -66,4 +66,10 @@ export const utils = { } return structLogs; }, + getRange(sourceCode: string, range: SingleFileSourceRange): string { + const lines = sourceCode.split('\n').slice(range.start.line - 1, range.end.line); + lines[lines.length - 1] = lines[lines.length - 1].slice(0, range.end.column); + lines[0] = lines[0].slice(range.start.column); + return lines.join('\n'); + }, }; |