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 | |
parent | dedddcfcf5793dfa9313569d4a831029a8270d59 (diff) | |
download | dexon-0x-contracts-e4d55242d88695a5d95cad7689ca304ecafb2252.tar.gz dexon-0x-contracts-e4d55242d88695a5d95cad7689ca304ecafb2252.tar.zst dexon-0x-contracts-e4d55242d88695a5d95cad7689ca304ecafb2252.zip |
Update to match latest type definitions and other small changes
-rw-r--r-- | packages/sol-cov/src/ast_visitor.ts | 5 | ||||
-rw-r--r-- | packages/sol-cov/src/get_source_range_snippet.ts | 15 |
2 files changed, 11 insertions, 9 deletions
diff --git a/packages/sol-cov/src/ast_visitor.ts b/packages/sol-cov/src/ast_visitor.ts index 16984b5ec..564f0f7d2 100644 --- a/packages/sol-cov/src/ast_visitor.ts +++ b/packages/sol-cov/src/ast_visitor.ts @@ -116,8 +116,9 @@ export class ASTVisitor { this._statementMap[this._entryId++] = this._getExpressionRange(ast); } private _getExpressionRange(ast: Parser.ASTNode): SingleFileSourceRange { - const start = this._locationByOffset[ast.range[0]]; - const end = this._locationByOffset[ast.range[1] + 1]; + const astRange = ast.range as [number, number]; + const start = this._locationByOffset[astRange[0]]; + const end = this._locationByOffset[astRange[1] + 1]; const range = { start, end, 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; } |