analyzeObject2Node method

  1. @override
Future<RetainingNode?> analyzeObject2Node(
  1. LeakAnalyzer analyzer,
  2. RetainingObject object
)
override

Implementation

@override
Future<RetainingNode?> analyzeObject2Node(
    LeakAnalyzer analyzer, RetainingObject object) async {
  InstanceRef instanceRef = object.value as InstanceRef;
  final String name = instanceRef.classRef?.name ?? '';

  Class? clz;
  if (instanceRef.classRef?.id != null) {
    clz = (await analyzer._getObjInstanceById(instanceRef.classRef!.id!))
        as Class?;
  }

  SourceCodeLocation? sourceCodeLocation;
  if (object.parentField != null && clz != null) {
    sourceCodeLocation =
        await LeakAnalyzer._getSourceCodeLocation(object.parentField!, clz);
  }

  String? toString;
  if (instanceRef.id != null) {
    toString = await analyzer._invokeMethod(instanceRef.id!, 'toString', []);
  }

  String? keyInfo = await LeakAnalyzer._map2String(object);

  ClosureInfo? closureInfo;
  if (object.value!.json != null) {
    closureInfo = await LeakAnalyzer._getClosureInfo(
        Instance.parse(object.value!.json!));
  }

  return RetainingNode(
    name,
    parentField: object.parentField?.toString(),
    parentIndex: object.parentListIndex,
    parentKey: keyInfo,
    libraries: clz?.library?.uri,
    sourceCodeLocation: sourceCodeLocation,
    closureInfo: closureInfo,
    string: toString,
    leakedNodeType: await LeakAnalyzer._getObjectType(clz),
  );
}