Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import 'package:vm_service/vm_service.dart';

import '../../shared/diagnostics/primitives/source_location.dart';
import '../../shared/primitives/simple_items.dart';
import '../../shared/primitives/trees.dart';
import '../../shared/ui/search.dart';

Expand Down Expand Up @@ -212,8 +213,6 @@ class StackFrameAndSourcePosition {
String get description {
const unoptimized = '[Unoptimized] ';
const none = '<none>';
const anonymousClosure = '<anonymous closure>';
const closure = '<closure>';
const asyncBreak = '<async break>';

if (frame.kind == FrameKind.kAsyncSuspensionMarker) {
Expand All @@ -224,7 +223,7 @@ class StackFrameAndSourcePosition {
if (name.startsWith(unoptimized)) {
name = name.substring(unoptimized.length);
}
name = name.replaceAll(anonymousClosure, closure);
name = name.replaceAll(anonymousClosureName, closureName);
name = name == none ? name : '$name';
return name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,32 @@ extension CpuSamplesExtension on vm_service.CpuSamples {
if (className != null) {
return '$className.${current.name}';
}
if (current.name == anonymousClosureName &&
current._function is vm_service.FuncRef) {
final nameParts = <String?>[current.name];

final function = current._function as vm_service.FuncRef;
var owner = function.owner;
switch (owner.runtimeType) {
case vm_service.FuncRef:
owner = owner as vm_service.FuncRef;
final functionName = owner.name;

String? className;
if (owner.owner is vm_service.ClassRef) {
className = (owner.owner as vm_service.ClassRef).name;
}

nameParts.insertAll(0, [className, functionName]);
break;
case vm_service.ClassRef:
final className = (owner as vm_service.ClassRef).name;
nameParts.insert(0, className);
}

nameParts.removeWhere((element) => element == null);
return nameParts.join('.');
}
return current.name;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ enum ScreenMetaData {
}

const String traceEventsFieldName = 'traceEvents';

const closureName = '<closure>';

const anonymousClosureName = '<anonymous closure>';
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:intl/intl.dart';

import 'simple_items.dart';

bool isPrivate(String member) => member.startsWith('_');

/// Public properties first, then sort alphabetically
Expand Down Expand Up @@ -292,7 +294,7 @@ String pluralize(String word, int count, {String? plural}) =>
/// See (https://github.com/dart-lang/sdk/issues/36999).
String getSimpleStackFrameName(String? name) {
name ??= '';
final newName = name.replaceAll('<anonymous closure>', '<closure>');
final newName = name.replaceAll(anonymousClosureName, closureName);

// If the class name contains a space, then it is not a valid Dart name. We
// throw out simplified names with spaces to prevent simplifying C++ class
Expand Down