aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-06-20 04:01:06 +0800
committerAlex Browne <stephenalexbrowne@gmail.com>2018-06-21 03:22:39 +0800
commite4d55242d88695a5d95cad7689ca304ecafb2252 (patch)
tree802cb8a00d2776ce456d5a41ac8f1bc5f2b11514
parentdedddcfcf5793dfa9313569d4a831029a8270d59 (diff)
downloaddexon-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
-rw-r--r--packages/sol-cov/src/ast_visitor.ts5
-rw-r--r--packages/sol-cov/src/get_source_range_snippet.ts15
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;
}