(currentSpan: HTMLSpanElement, lineNumber: number,
pos: number, end: number, adjust: number)
| 234 | } |
| 235 | |
| 236 | private insertSourcePositions(currentSpan: HTMLSpanElement, lineNumber: number, |
| 237 | pos: number, end: number, adjust: number): void { |
| 238 | const view = this; |
| 239 | const sps = this.sourceResolver.sourcePositionsInRange(this.source.sourceId, pos - adjust, end); |
| 240 | let offset = 0; |
| 241 | for (const sourcePosition of sps) { |
| 242 | // Internally, line numbers are 0-based so we have to substract 1 from the line number. This |
| 243 | // path in only taken by non-Wasm code. Wasm code relies on setSourceLineToBytecodePosition. |
| 244 | this.sourceResolver.addAnyPositionToLine(lineNumber - 1, sourcePosition); |
| 245 | const textNode = currentSpan.tagName === "SPAN" ? currentSpan.lastChild : currentSpan; |
| 246 | if (!(textNode instanceof Text)) continue; |
| 247 | const splitLength = Math.max(0, sourcePosition.scriptOffset - pos - offset); |
| 248 | offset += splitLength; |
| 249 | const replacementNode = textNode.splitText(splitLength); |
| 250 | const span = document.createElement("span"); |
| 251 | span.setAttribute("scriptOffset", sourcePosition.scriptOffset.toString()); |
| 252 | span.classList.add("source-position"); |
| 253 | const marker = document.createElement("span"); |
| 254 | marker.classList.add("marker"); |
| 255 | span.appendChild(marker); |
| 256 | const inlining = this.sourceResolver.getInliningForPosition(sourcePosition); |
| 257 | if (inlining && view.showAdditionalInliningPosition) { |
| 258 | const sourceName = this.sourceResolver.getSourceName(inlining.sourceId); |
| 259 | const inliningMarker = document.createElement("span"); |
| 260 | inliningMarker.classList.add("inlining-marker"); |
| 261 | inliningMarker.setAttribute("data-descr", `${sourceName} was inlined here`); |
| 262 | span.appendChild(inliningMarker); |
| 263 | } |
| 264 | span.onclick = function (e: MouseEvent) { |
| 265 | e.stopPropagation(); |
| 266 | view.onSelectSourcePosition(sourcePosition, !e.shiftKey); |
| 267 | }; |
| 268 | view.addHtmlElementToSourcePosition(sourcePosition, span); |
| 269 | textNode.parentNode.insertBefore(span, replacementNode); |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | private insertLineNumber(lineElement: HTMLElement, lineNumber: number): void { |
| 274 | const lineNumberElement = document.createElement("div"); |
no test coverage detected