fix decoding

pull/3199/head
filip mertens 2 years ago committed by Aniket
parent 949c4dd22e
commit f38438dab6
  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 () {
this.call('layout', 'maximiseSidePanel')
this.emit('startDebugging')
}
onStopDebugging () {
this.call('layout', 'resetSidePanel')
this.emit('stopDebugging')
}
}

@ -78,6 +78,8 @@ export class CodeParser extends Plugin {
setCurrentFileAST: (text?: string) => Promise<ParseResult>
getImports: () => Promise<CodeParserImportsData[]>
debuggerIsOn: boolean = false
constructor(astWalker: any) {
super(profile)
@ -98,7 +100,7 @@ export class CodeParser extends Plugin {
}
const showGasSettings = await this.call('config', 'getAppParameter', 'show-gas')
const showErrorSettings = await this.call('config', 'getAppParameter', 'display-errors')
if (showGasSettings || showErrorSettings || completionSettings) {
if (showGasSettings || showErrorSettings || completionSettings || this.debuggerIsOn) {
await this.compilerService.compile()
}
}
@ -159,6 +161,16 @@ export class CodeParser extends Plugin {
this.on('solidity', 'compilerLoaded', async () => {
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(){
@ -338,7 +350,11 @@ export class CodeParser extends Plugin {
* @returns
*/
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 []
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]) {

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

Loading…
Cancel
Save