| 472 | } |
| 473 | |
| 474 | private _attachToNewTargets(targets: ITarget[], launcher: ILauncher) { |
| 475 | for (const target of targets.values()) { |
| 476 | if (!target.waitingForDebugger()) { |
| 477 | continue; |
| 478 | } |
| 479 | |
| 480 | if (TreeNode.targetNodes.has(target)) { |
| 481 | continue; |
| 482 | } |
| 483 | |
| 484 | const parentTarget = target.parent(); |
| 485 | const parent = parentTarget ? TreeNode.targetNodes.get(parentTarget) : this._root; |
| 486 | if (!parent) { |
| 487 | throw new Error(`Got target with unknown parent: ${target.name()}`); |
| 488 | } |
| 489 | |
| 490 | const node = new TreeNode(target) as TargetTreeNode; |
| 491 | parent.add(node); |
| 492 | this.attach(node, launcher); |
| 493 | } |
| 494 | } |
| 495 | |
| 496 | /** |
| 497 | * Terminates all targets in the tree that aren't in the `targets` list. |