diff options
author | Alex Browne <stephenalexbrowne@gmail.com> | 2018-06-20 04:01:06 +0800 |
---|---|---|
committer | Alex Browne <stephenalexbrowne@gmail.com> | 2018-06-21 03:22:39 +0800 |
commit | e4d55242d88695a5d95cad7689ca304ecafb2252 (patch) | |
tree | 802cb8a00d2776ce456d5a41ac8f1bc5f2b11514 /packages/sol-cov/src/get_source_range_snippet.ts | |
parent | dedddcfcf5793dfa9313569d4a831029a8270d59 (diff) | |
download | dexon-sol-tools-e4d55242d88695a5d95cad7689ca304ecafb2252.tar dexon-sol-tools-e4d55242d88695a5d95cad7689ca304ecafb2252.tar.gz dexon-sol-tools-e4d55242d88695a5d95cad7689ca304ecafb2252.tar.bz2 dexon-sol-tools-e4d55242d88695a5d95cad7689ca304ecafb2252.tar.lz dexon-sol-tools-e4d55242d88695a5d95cad7689ca304ecafb2252.tar.xz dexon-sol-tools-e4d55242d88695a5d95cad7689ca304ecafb2252.tar.zst dexon-sol-tools-e4d55242d88695a5d95cad7689ca304ecafb2252.zip |
Update to match latest type definitions and other small changes
Diffstat (limited to 'packages/sol-cov/src/get_source_range_snippet.ts')
-rw-r--r-- | packages/sol-cov/src/get_source_range_snippet.ts | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/packages/sol-cov/src/get_source_range_snippet.ts b/packages/sol-cov/src/get_source_range_snippet.ts index 48c74dd27..30d6ec802 100644 --- a/packages/sol-cov/src/get_source_range_snippet.ts +++ b/packages/sol-cov/src/get_source_range_snippet.ts @@ -9,7 +9,7 @@ interface ASTInfo { type: string; node: Parser.ASTNode; name: string | null; - range: SingleFileSourceRange; + range?: SingleFileSourceRange; } // Parsing source code for each transaction/code is slow and therefore we cache it @@ -30,13 +30,13 @@ export function getSourceRangeSnippet(sourceRange: SourceRange, sourceCode: stri const sourceCodeInRange = utils.getRange(sourceCode, sourceRange.location); return { ...astInfo, + range: astInfo.range as SingleFileSourceRange, source: sourceCodeInRange, fileName: sourceRange.fileName, }; } -// A visitor which collects ASTInfo for contract definitions, function -// definitions, and other types of statements. +// A visitor which collects ASTInfo for most nodes in the AST. class ASTInfoVisitor { private _astInfos: ASTInfo[] = []; public getASTInfoForRange(sourceRange: SourceRange): ASTInfo | null { @@ -165,11 +165,12 @@ class ASTInfoVisitor { }, }; for (const astInfo of this._astInfos) { + const astInfoRange = astInfo.range as SingleFileSourceRange; if ( - astInfo.range.start.column === offsetSourceRange.location.start.column && - astInfo.range.start.line === offsetSourceRange.location.start.line && - astInfo.range.end.column === offsetSourceRange.location.end.column && - astInfo.range.end.line === offsetSourceRange.location.end.line + astInfoRange.start.column === offsetSourceRange.location.start.column && + astInfoRange.start.line === offsetSourceRange.location.start.line && + astInfoRange.end.column === offsetSourceRange.location.end.column && + astInfoRange.end.line === offsetSourceRange.location.end.line ) { return astInfo; } |