framesOf static method
The frames of stack that are not the framework's, as frames holds
them.
Read off the text, in both of the shapes a stack arrives in: the VM's
own, #3 member (uri:12:5), and the terse one package:stack_trace
prints, uri 12:5 member, whose file paths are relative to the working
directory and are resolved against it here.
Implementation
static List<String> framesOf(StackTrace? stack) {
if (stack == null) return const [];
var frames = <String>[];
for (var line in '$stack'.split('\n')) {
line = line.trimRight();
var match = _vmFrame.firstMatch(line) ?? _terseFrame.firstMatch(line);
if (match == null) continue;
var written = match.group(1)!;
var uri = _scheme.hasMatch(written)
? written
: '${Uri.base.resolveUri(Uri.file(written))}';
if (_framework.any(uri.startsWith)) continue;
var column = match.group(3);
frames.add(
column == null
? '$uri:${match.group(2)}'
: '$uri:${match.group(2)}:$column',
);
if (frames.length == maxFrames) break;
}
return frames;
}