Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/platform/parser/test/node/getTestableNodes.util.ts
13405 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { _getTestableNodes } from '../../node/testGenParsing';
7
import { WASMLanguage } from '../../node/treeSitterLanguages';
8
import { insertRangeMarkers } from './markers';
9
10
export async function annotTestableNodes(language: WASMLanguage, source: string, includeSelection = false) {
11
12
const result = await _getTestableNodes(
13
language,
14
source,
15
);
16
17
if (result === null) {
18
return 'testable node NOT found';
19
}
20
21
const markers = result.flatMap(node => {
22
return [
23
{
24
startIndex: node.node.startIndex,
25
endIndex: node.node.endIndex,
26
kind: 'NODE',
27
},
28
{
29
startIndex: node.identifier.range.startIndex,
30
endIndex: node.identifier.range.endIndex,
31
kind: 'IDENT',
32
}
33
];
34
});
35
36
return insertRangeMarkers(source, markers);
37
}
38
39