From c6ab1c4f25923e4eef1473eafa711182281aedd9 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 16 Sep 2020 11:31:46 +0200 Subject: [PATCH] use remix-astwalker --- apps/remix-ide/package.json | 1 + apps/remix-ide/src/app/editor/contextualListener.js | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/remix-ide/package.json b/apps/remix-ide/package.json index ee772676b8..f04505ae39 100644 --- a/apps/remix-ide/package.json +++ b/apps/remix-ide/package.json @@ -56,6 +56,7 @@ "npm-run-all": "^4.0.2", "onchange": "^3.2.1", "remix-analyzer": "0.5.3", + "remix-astwalker": "0.0.25", "remix-debug": "0.4.5", "remix-lib": "0.4.30", "remix-simulator": "0.1.9-beta.6", diff --git a/apps/remix-ide/src/app/editor/contextualListener.js b/apps/remix-ide/src/app/editor/contextualListener.js index 57a549b6e3..60dbadd8a0 100644 --- a/apps/remix-ide/src/app/editor/contextualListener.js +++ b/apps/remix-ide/src/app/editor/contextualListener.js @@ -1,8 +1,8 @@ 'use strict' const remixdebug = require('@remix-project/remix-debug') +const { AstWalker } = require('@remix-project/remix-astwalker') const csjs = require('csjs-inject') const SourceMappingDecoder = remixdebug.SourceMappingDecoder -const AstWalker = remixdebug.AstWalker const EventManager = require('../../lib/events') const globalRegistry = require('../../global/registry') import { Plugin } from '@remixproject/engine' @@ -97,8 +97,7 @@ class ContextualListener extends Plugin { _buildIndex (compilationResult, source) { if (compilationResult && compilationResult.sources) { - const callback = {} - callback['*'] = (node) => { + const callback = (node) => { if (node && node.referencedDeclaration) { if (!this._index['Declarations'][node.referencedDeclaration]) { this._index['Declarations'][node.referencedDeclaration] = [] @@ -106,10 +105,9 @@ class ContextualListener extends Plugin { this._index['Declarations'][node.referencedDeclaration].push(node) } this._index['FlatReferences'][node.id] = node - return true } for (const s in compilationResult.sources) { - this.astWalker.walk(compilationResult.sources[s].ast, callback) + this.astWalker.walkFull(compilationResult.sources[s].ast, callback) } } }