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

Function getValidStackFrames

src/test/dart/utils/stack_trace.test.ts:32–58  ·  view source on GitHub ↗
(prefix: string, uri: string, withLineCol: boolean)

Source from the content-addressed store, hash-verified

30const col = 45;
31
32function getValidStackFrames(prefix: string, uri: string, withLineCol: boolean): string[] {
33 const frames = withLineCol
34 ? [
35 // Dart/Flutter
36 `${prefix}(${uri}:${line}:${col})`,
37 `${prefix}(${uri}:${line}:${col}))`, // This extra closing paren exists in Dart stacks 🤷‍♂️
38 // Flutter web
39 `${uri} ${line}:${col} ${prefix}`,
40 ]
41 : [
42 // Dart/Flutter
43 `${prefix}(${uri})`,
44 `${prefix}(${uri}))`, // This extra closing paren exists in Dart stacks 🤷‍♂️
45 // Flutter web
46 `${uri} ${prefix}`,
47 ];
48
49 // Assertion failure
50 if (!prefix) {
51 if (withLineCol)
52 frames.push(`'${uri}': Failed assertion: line ${line} pos ${col}: '!keyReservation.contains(key)': is not true.`);
53 else
54 frames.push(`'${uri}': Failed assertion: '!keyReservation.contains(key)': is not true.`);
55 }
56
57 return frames;
58}
59
60describe("stack trace parser", () => {
61 it(`parses strings over ${maxStackFrameMessageLength} characters quickly`, () => {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected