MCPcopy Create free account
hub / github.com/BUPT-GAMMA/MASFactory / parseDictArgument

Function parseDictArgument

masfactory-visualizer/src/parser/astUtils.ts:75–93  ·  view source on GitHub ↗
(node: TSNode, code: string)

Source from the content-addressed store, hash-verified

73 * Parse dictionary argument (for keys, pull_keys, push_keys)
74 */
75export function parseDictArgument(node: TSNode, code: string): { [key: string]: string } | null {
76 if (node.type === 'dictionary') {
77 const result: { [key: string]: string } = {};
78 for (const child of node.namedChildren) {
79 if (!child) {continue;}
80 if (child.type === 'pair') {
81 const key = child.childForFieldName('key');
82 const value = child.childForFieldName('value');
83 if (key && value) {
84 const keyText = getNodeText(key, code).replace(/^["']|["']$/g, '');
85 const valueText = getNodeText(value, code).replace(/^["']|["']$/g, '');
86 result[keyText] = valueText;
87 }
88 }
89 }
90 return Object.keys(result).length > 0 ? result : null;
91 }
92 return null;
93}
94
95/**
96 * Parse keys-like argument for Node pull_keys/push_keys semantics.

Callers 13

parseCreateNodeFunction · 0.90
parseCreateEdgeFunction · 0.90
parseEdgeFromEntryFunction · 0.90
parseEdgeToExitFunction · 0.90
parseEdgeFromControllerFunction · 0.90
parseEdgeToControllerFunction · 0.90
parseEdgeToTerminateNodeFunction · 0.90
parseEdgeKeysArgumentFunction · 0.90
parseEdgeKeysArgumentFunction · 0.90

Calls 2

getNodeTextFunction · 0.85
keysMethod · 0.80

Tested by

no test coverage detected