MCPcopy Create free account
hub / github.com/CodinGame/monaco-vscode-api / updateFromContents

Method updateFromContents

demo/src/features/testing.ts:95–137  ·  view source on GitHub ↗

* Parses the tests from the input text, and updates the tests contained * by this file to be those from the text,

(
      controller: vscode.TestController,
      content: string,
      item: vscode.TestItem
    )

Source from the content-addressed store, hash-verified

93 * by this file to be those from the text,
94 */
95 public updateFromContents(
96 controller: vscode.TestController,
97 content: string,
98 item: vscode.TestItem
99 ): void {
100 const ancestors = [{ item, children: [] as vscode.TestItem[] }]
101 const thisGeneration = generationCounter++
102 this.didResolve = true
103
104 const ascend = (depth: number) => {
105 while (ancestors.length > depth) {
106 const finished = ancestors.pop()!
107 finished.item.children.replace(finished.children)
108 }
109 }
110
111 parseMarkdown(content, {
112 onTest: (range, a, operator, b, expected) => {
113 const parent = ancestors[ancestors.length - 1]!
114 const data = new TestCase(a, operator as Operator, b, expected, thisGeneration)
115 const id = `${item.uri}/${data.getLabel()}`
116
117 const tcase = controller.createTestItem(id, data.getLabel(), item.uri)
118 testData.set(tcase, data)
119 tcase.range = range
120 parent.children.push(tcase)
121 },
122
123 onHeading: (range, name, depth) => {
124 ascend(depth)
125 const parent = ancestors[ancestors.length - 1]!
126 const id = `${item.uri}/${name}`
127
128 const thead = controller.createTestItem(id, name, item.uri)
129 thead.range = range
130 testData.set(thead, new TestHeading(thisGeneration))
131 parent.children.push(thead)
132 ancestors.push({ item: thead, children: [] })
133 }
134 })
135
136 ascend(0) // finish and assign children for all remaining items
137 }
138 }
139
140 class TestHeading {

Callers 2

updateFromDiskMethod · 0.95
updateNodeForDocumentFunction · 0.80

Calls 3

getLabelMethod · 0.95
parseMarkdownFunction · 0.85
setMethod · 0.80

Tested by

no test coverage detected