(result)
| 294 | } |
| 295 | |
| 296 | override async processAsm(result): Promise<ParsedAsmResult> { |
| 297 | // Handle "error" documents. |
| 298 | if (!result.asm.includes('\n') && result.asm[0] === '<') { |
| 299 | return {asm: [{text: result.asm, source: null}]}; |
| 300 | } |
| 301 | |
| 302 | // result.asm is an array of javap stdouts |
| 303 | const parseds = result.asm.map(asm => this.parseAsmForClass(asm.text)); |
| 304 | // Sort class file outputs according to first source line they reference |
| 305 | parseds.sort((o1, o2) => o1.firstSourceLine - o2.firstSourceLine); |
| 306 | |
| 307 | const segments: ParsedAsmResultLine[] = []; |
| 308 | for (const [classNumber, parsed] of parseds.entries()) { |
| 309 | if (classNumber > 0) { |
| 310 | // Separate classes with two line breaks |
| 311 | segments.push({text: '', source: null}, {text: '', source: null}); |
| 312 | } |
| 313 | for (let i = 0; i < parsed.textsBeforeMethod.length; i++) { |
| 314 | // Line-based highlighting doesn't work if some segments span multiple lines, |
| 315 | // even if they don't have a source line number |
| 316 | // -> split the lines and create segment for each separately |
| 317 | for (const line of utils.splitLines(parsed.textsBeforeMethod[i])) { |
| 318 | // javap output always starts with "Compiled from" on first line, discard these lines. |
| 319 | if (line.startsWith('Compiled from')) { |
| 320 | continue; |
| 321 | } |
| 322 | segments.push({ |
| 323 | text: line, |
| 324 | source: null, |
| 325 | }); |
| 326 | } |
| 327 | |
| 328 | // textsBeforeMethod[last] is actually *after* the last method. |
| 329 | // Check whether there is a method following the text block |
| 330 | if (i < parsed.methods.length) { |
| 331 | for (const {text, sourceLine} of parsed.methods[i].instructions) { |
| 332 | segments.push({text: text, source: {file: null, line: sourceLine}}); |
| 333 | } |
| 334 | } |
| 335 | } |
| 336 | } |
| 337 | return {asm: segments}; |
| 338 | } |
| 339 | |
| 340 | parseAsmForClass(javapOut: string) { |
| 341 | const textsBeforeMethod: string[] = []; |
no test coverage detected