Merge pull request #2833 from ethereum/ensureSourcehighlight_yul

Check if ast present
uiCheck
yann300 5 years ago committed by GitHub
commit d26ee5c6d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/app/compiler/compiler-abstract.js
  2. 8
      src/lib/offsetToLineColumnConverter.js

@ -32,6 +32,10 @@ module.exports = class CompilerAbstract {
getSourceName (fileIndex) {
if (this.data && this.data.sources) {
return Object.keys(this.data.sources)[fileIndex]
} else if (Object.keys(this.source.sources).length === 1) {
// if we don't have ast, we return the only one filename present.
const sourcesArray = Object.keys(this.source.sources)
return sourcesArray[0]
}
return null
}

@ -19,14 +19,20 @@ export class OffsetToLineColumnConverter extends Plugin {
offsetToLineColumn (rawLocation, file, sources, asts) {
if (!this.lineBreakPositionsByContent[file]) {
const sourcesArray = Object.keys(sources)
if (!asts && file === 0 && sourcesArray.length === 1) {
// if we don't have ast, we process the only one available content
this.lineBreakPositionsByContent[file] = this.sourceMappingDecoder.getLinebreakPositions(sources[sourcesArray[0]].content)
} else {
for (var filename in asts) {
var source = asts[filename]
const source = asts[filename]
if (source.id === file) {
this.lineBreakPositionsByContent[file] = this.sourceMappingDecoder.getLinebreakPositions(sources[filename].content)
break
}
}
}
}
return this.sourceMappingDecoder.convertOffsetToLineColumn(rawLocation, this.lineBreakPositionsByContent[file])
}

Loading…
Cancel
Save