analyzeObject2Node method

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

Implementation

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

  Class? clz;
  if (fieldRef.owner?.id != null) {
    var result = await analyzer._getObjInstanceById(fieldRef.owner!.id!);
    if (result is Class?) {
      clz = result;
    }
  }

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

  String? toString;
  if (fieldRef.id != null) {
    toString = await analyzer._invokeMethod(fieldRef.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: LeakedNodeType.field,
  );
}