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. 16
      src/lib/offsetToLineColumnConverter.js

@ -32,6 +32,10 @@ module.exports = class CompilerAbstract {
getSourceName (fileIndex) { getSourceName (fileIndex) {
if (this.data && this.data.sources) { if (this.data && this.data.sources) {
return Object.keys(this.data.sources)[fileIndex] 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 return null
} }

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

Loading…
Cancel
Save