|
|
@ -1,7 +1,7 @@ |
|
|
|
'use strict' |
|
|
|
'use strict' |
|
|
|
|
|
|
|
const { AstWalker } = require('@remix-project/remix-astwalker') |
|
|
|
const remixLib = require('@remix-project/remix-lib') |
|
|
|
const remixLib = require('@remix-project/remix-lib') |
|
|
|
const util = remixLib.util |
|
|
|
const util = remixLib.util |
|
|
|
const AstWalker = require('./astWalker') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Decompress the source mapping given by solc-bin.js |
|
|
|
* Decompress the source mapping given by solc-bin.js |
|
|
@ -144,33 +144,26 @@ function findNodeAtInstructionIndex (astNodeType, instIndex, sourceMap, ast) { |
|
|
|
|
|
|
|
|
|
|
|
function findNodeAtSourceLocation (astNodeType, sourceLocation, ast) { |
|
|
|
function findNodeAtSourceLocation (astNodeType, sourceLocation, ast) { |
|
|
|
const astWalker = new AstWalker() |
|
|
|
const astWalker = new AstWalker() |
|
|
|
const callback = {} |
|
|
|
|
|
|
|
let found = null |
|
|
|
let found = null |
|
|
|
callback['*'] = function (node) { |
|
|
|
const callback = function (node) { |
|
|
|
const nodeLocation = sourceLocationFromAstNode(node) |
|
|
|
const nodeLocation = sourceLocationFromAstNode(node) |
|
|
|
if (!nodeLocation) { |
|
|
|
if (!nodeLocation) { |
|
|
|
return true |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
if (nodeLocation.start <= sourceLocation.start && nodeLocation.start + nodeLocation.length >= sourceLocation.start + sourceLocation.length) { |
|
|
|
if (nodeLocation.start <= sourceLocation.start && nodeLocation.start + nodeLocation.length >= sourceLocation.start + sourceLocation.length) { |
|
|
|
if (astNodeType === node.nodeType) { |
|
|
|
if (astNodeType === node.nodeType) { |
|
|
|
found = node |
|
|
|
found = node |
|
|
|
return false |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
astWalker.walk(ast.ast, callback) |
|
|
|
astWalker.walkFull(ast.ast, callback) |
|
|
|
return found |
|
|
|
return found |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function nodesAtPosition (astNodeType, position, ast) { |
|
|
|
function nodesAtPosition (astNodeType, position, ast) { |
|
|
|
const astWalker = new AstWalker() |
|
|
|
const astWalker = new AstWalker() |
|
|
|
const callback = {} |
|
|
|
|
|
|
|
const found = [] |
|
|
|
const found = [] |
|
|
|
callback['*'] = function (node) { |
|
|
|
const callback = function (node) { |
|
|
|
var nodeLocation = sourceLocationFromAstNode(node) |
|
|
|
var nodeLocation = sourceLocationFromAstNode(node) |
|
|
|
if (!nodeLocation) { |
|
|
|
if (!nodeLocation) { |
|
|
|
return |
|
|
|
return |
|
|
@ -178,14 +171,10 @@ function nodesAtPosition (astNodeType, position, ast) { |
|
|
|
if (nodeLocation.start <= position && nodeLocation.start + nodeLocation.length >= position) { |
|
|
|
if (nodeLocation.start <= position && nodeLocation.start + nodeLocation.length >= position) { |
|
|
|
if (!astNodeType || astNodeType === node.nodeType) { |
|
|
|
if (!astNodeType || astNodeType === node.nodeType) { |
|
|
|
found.push(node) |
|
|
|
found.push(node) |
|
|
|
if (astNodeType) return false |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return true |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
astWalker.walk(ast.ast, callback) |
|
|
|
astWalker.walkFull(ast.ast, callback) |
|
|
|
return found |
|
|
|
return found |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|