fix decoding

pull/5370/head
filip mertens 2 years ago committed by Aniket
parent bc82ead7d6
commit 7335b66981
  1. 2
      apps/debugger/src/app/debugger-api.ts
  2. 20
      apps/remix-ide/src/app/plugins/parser/code-parser.tsx
  3. 8
      libs/remix-ui/editor/src/lib/providers/hoverProvider.ts

@ -174,10 +174,12 @@ export const DebuggerApiMixin = (Base) => class extends Base {
onStartDebugging () { onStartDebugging () {
this.call('layout', 'maximiseSidePanel') this.call('layout', 'maximiseSidePanel')
this.emit('startDebugging')
} }
onStopDebugging () { onStopDebugging () {
this.call('layout', 'resetSidePanel') this.call('layout', 'resetSidePanel')
this.emit('stopDebugging')
} }
} }

@ -78,6 +78,8 @@ export class CodeParser extends Plugin {
setCurrentFileAST: (text?: string) => Promise<ParseResult> setCurrentFileAST: (text?: string) => Promise<ParseResult>
getImports: () => Promise<CodeParserImportsData[]> getImports: () => Promise<CodeParserImportsData[]>
debuggerIsOn: boolean = false
constructor(astWalker: any) { constructor(astWalker: any) {
super(profile) super(profile)
@ -98,7 +100,7 @@ export class CodeParser extends Plugin {
} }
const showGasSettings = await this.call('config', 'getAppParameter', 'show-gas') const showGasSettings = await this.call('config', 'getAppParameter', 'show-gas')
const showErrorSettings = await this.call('config', 'getAppParameter', 'display-errors') const showErrorSettings = await this.call('config', 'getAppParameter', 'display-errors')
if (showGasSettings || showErrorSettings || completionSettings) { if (showGasSettings || showErrorSettings || completionSettings || this.debuggerIsOn) {
await this.compilerService.compile() await this.compilerService.compile()
} }
} }
@ -159,6 +161,16 @@ export class CodeParser extends Plugin {
this.on('solidity', 'compilerLoaded', async () => { this.on('solidity', 'compilerLoaded', async () => {
await this.reload() await this.reload()
}) })
this.on('debugger', 'startDebugging', async () => {
this.debuggerIsOn = true
await this.reload()
})
this.on('debugger', 'stopDebugging', async () => {
this.debuggerIsOn = false
await this.reload()
})
} }
async reload(){ async reload(){
@ -338,7 +350,11 @@ export class CodeParser extends Plugin {
* @returns * @returns
*/ */
async nodesAtPosition(position: number, type = ''): Promise<genericASTNode[]> { async nodesAtPosition(position: number, type = ''): Promise<genericASTNode[]> {
const lastCompilationResult = this.compilerAbstract let lastCompilationResult = this.compilerAbstract
if(this.debuggerIsOn) {
lastCompilationResult = await this.call('compilerArtefacts', 'get', '__last')
this.currentFile = await this.call('fileManager', 'file')
}
if (!lastCompilationResult) return [] if (!lastCompilationResult) return []
const urlFromPath = await this.call('fileManager', 'getUrlFromPath', this.currentFile) const urlFromPath = await this.call('fileManager', 'getUrlFromPath', this.currentFile)
if (lastCompilationResult && lastCompilationResult.languageversion.indexOf('soljson') === 0 && lastCompilationResult.data && lastCompilationResult.data.sources && lastCompilationResult.data.sources[this.currentFile]) { if (lastCompilationResult && lastCompilationResult.languageversion.indexOf('soljson') === 0 && lastCompilationResult.data && lastCompilationResult.data.sources && lastCompilationResult.data.sources[this.currentFile]) {

@ -148,18 +148,18 @@ export class RemixHoverProvider implements languages.HoverProvider {
try { try {
const decodedVar = await this.props.plugin.call('debugger', 'decodeLocalVariable', nodeAtPosition.id) const decodedVar = await this.props.plugin.call('debugger', 'decodeLocalVariable', nodeAtPosition.id)
if (decodedVar !== null) { if (decodedVar !== null && decodedVar.type) {
contents.push({ contents.push({
value: JSON.stringify(decodedVar.value, null, '\t') value: `LOCAL VARIABLE ${nodeAtPosition.name}: ${JSON.stringify(decodedVar.value, null, '\t')}`
}) })
} }
} catch (e) {} } catch (e) {}
try { try {
const decodedVar = await this.props.plugin.call('debugger', 'decodeStateVariable', nodeAtPosition.id) const decodedVar = await this.props.plugin.call('debugger', 'decodeStateVariable', nodeAtPosition.id)
if (decodedVar !== null) { if (decodedVar !== null && decodedVar.type) {
contents.push({ contents.push({
value: JSON.stringify(decodedVar.value, null, '\t') value: `STATE VARIABLE ${nodeAtPosition.name}: ${JSON.stringify(decodedVar.value, null, '\t')}`
}) })
} }
} catch (e) {} } catch (e) {}

Loading…
Cancel
Save