MCPcopy Create free account
hub / github.com/Dart-Code/Dart-Code / groupDiscovered

Method groupDiscovered

src/shared/test/test_model.ts:459–506  ·  view source on GitHub ↗
(dartCodeDebugSessionID: string, suitePath: string, source: TestSource, groupID: number, groupName: string | undefined, parentID: number | undefined, groupPath: string | undefined, range: Range | undefined, _hasStarted = false)

Source from the content-addressed store, hash-verified

457 }
458
459 public groupDiscovered(dartCodeDebugSessionID: string, suitePath: string, source: TestSource, groupID: number, groupName: string | undefined, parentID: number | undefined, groupPath: string | undefined, range: Range | undefined, _hasStarted = false): GroupNode {
460 groupPath ??= suitePath;
461 const suite = this.suites.getForPath(suitePath)!;
462 const existingGroup = suite.reuseMatchingGroup(groupName);
463 const oldParent = existingGroup?.parent;
464 let parent = parentID ? suite.getMyGroup(dartCodeDebugSessionID, parentID)! : suite.node;
465
466 /**
467 * If we're a dynamic test/group, we should be re-parented under the dynamic node that came from
468 * the analyzer.
469 */
470 if (groupName && source === TestSource.Result)
471 parent = this.findMatchingDynamicNode(parent, groupName) ?? parent;
472
473 const groupNode = existingGroup || new GroupNode(suite, parent, groupName, groupPath, range);
474
475 suite.storeGroup(dartCodeDebugSessionID, groupID, groupNode);
476
477 if (existingGroup) {
478 groupNode.parent = parent;
479 groupNode.name = groupName;
480 groupNode.path = groupPath;
481 if (range)
482 groupNode.range = range;
483 } else {
484 groupNode.testSource = source;
485 }
486
487 this.markAsNotDeleted(groupNode);
488
489 // Remove from old parent if required
490 const hasChangedParent = oldParent !== parent;
491 if (oldParent && hasChangedParent) {
492 oldParent.children.splice(oldParent.children.indexOf(groupNode), 1);
493 this.updateNode({ node: oldParent });
494 }
495
496 // Push to new parent if required.
497 if (!groupNode.parent.children.find((n) => n === groupNode))
498 groupNode.parent.children.push(groupNode);
499
500 this.updateNode({ node: groupNode });
501 this.setupRangeTracking(groupNode, source, suitePath, range, groupPath);
502
503 this.testEventListeners.forEach((l) => l.groupDiscovered(dartCodeDebugSessionID, groupNode));
504
505 return groupNode;
506 }
507
508 public testDiscovered(dartCodeDebugSessionID: string, suitePath: string, source: TestSource, testID: number, testName: string | undefined, groupID: number | undefined, testPath: string | undefined, range: Range | undefined, startTime: number | undefined, hasStarted = false): TestNode {
509 testPath ??= suitePath;

Callers

nothing calls this directly

Calls 9

markAsNotDeletedMethod · 0.95
updateNodeMethod · 0.95
setupRangeTrackingMethod · 0.95
getForPathMethod · 0.80
reuseMatchingGroupMethod · 0.80
getMyGroupMethod · 0.80
storeGroupMethod · 0.80
groupDiscoveredMethod · 0.65

Tested by

no test coverage detected