(newState)
| 1466 | } |
| 1467 | |
| 1468 | render(newState) { |
| 1469 | let oldState = this.currentState; |
| 1470 | if (!newState.file || !newState.viewingSource) { |
| 1471 | this.table.style.display = "none"; |
| 1472 | this.hideButton.style.display = "none"; |
| 1473 | this.currentState = null; |
| 1474 | return; |
| 1475 | } |
| 1476 | if (oldState) { |
| 1477 | if (newState.file === oldState.file && |
| 1478 | newState.currentCodeId === oldState.currentCodeId && |
| 1479 | newState.viewingSource === oldState.viewingSource) { |
| 1480 | // No change, nothing to do. |
| 1481 | return; |
| 1482 | } |
| 1483 | } |
| 1484 | this.currentState = newState; |
| 1485 | |
| 1486 | this.table.style.display = "inline-block"; |
| 1487 | this.hideButton.style.display = "inline"; |
| 1488 | removeAllChildren(this.table); |
| 1489 | |
| 1490 | let functionId = |
| 1491 | this.currentState.file.code[this.currentState.currentCodeId].func; |
| 1492 | let sourceView = |
| 1493 | this.currentState.sourceData.generateSourceView(functionId); |
| 1494 | for (let i = 0; i < sourceView.source.length; i++) { |
| 1495 | let sampleCount = sourceView.lineSampleCounts[i] || 0; |
| 1496 | let sampleProportion = sourceView.samplesTotal > 0 ? |
| 1497 | sampleCount / sourceView.samplesTotal : 0; |
| 1498 | let heatBucket; |
| 1499 | if (sampleProportion === 0) { |
| 1500 | heatBucket = "line-none"; |
| 1501 | } else if (sampleProportion < 0.2) { |
| 1502 | heatBucket = "line-cold"; |
| 1503 | } else if (sampleProportion < 0.4) { |
| 1504 | heatBucket = "line-mediumcold"; |
| 1505 | } else if (sampleProportion < 0.6) { |
| 1506 | heatBucket = "line-mediumhot"; |
| 1507 | } else if (sampleProportion < 0.8) { |
| 1508 | heatBucket = "line-hot"; |
| 1509 | } else { |
| 1510 | heatBucket = "line-superhot"; |
| 1511 | } |
| 1512 | |
| 1513 | let row = this.table.insertRow(-1); |
| 1514 | |
| 1515 | let lineNumberCell = row.insertCell(-1); |
| 1516 | lineNumberCell.classList.add("source-line-number"); |
| 1517 | lineNumberCell.textContent = i + sourceView.firstLineNumber; |
| 1518 | |
| 1519 | let sampleCountCell = row.insertCell(-1); |
| 1520 | sampleCountCell.classList.add(heatBucket); |
| 1521 | sampleCountCell.textContent = sampleCount; |
| 1522 | |
| 1523 | let sourceLineCell = row.insertCell(-1); |
| 1524 | sourceLineCell.classList.add(heatBucket); |
| 1525 | sourceLineCell.textContent = sourceView.source[i]; |
nothing calls this directly
no test coverage detected