MCPcopy Create free account
hub / github.com/SplootCode/splootcode / generateSerializedNode

Function generateSerializedNode

scripts/pyright_tray_generate.ts:399–466  ·  view source on GitHub ↗
(moduleName: string, autocompleteEntry: AutocompleteInfo)

Source from the content-addressed store, hash-verified

397}
398
399function generateSerializedNode(moduleName: string, autocompleteEntry: AutocompleteInfo): SerializedNode {
400 if (autocompleteEntry.category === AutocompleteEntryCategory.Value) {
401 const attrNode = {
402 type: 'PYTHON_MEMBER',
403 properties: { member: autocompleteEntry.name },
404 childSets: {
405 object: [
406 {
407 type: 'PY_IDENTIFIER',
408 properties: { identifier: moduleName },
409 childSets: {},
410 },
411 ],
412 },
413 }
414 return attrNode
415 } else if (autocompleteEntry.category === AutocompleteEntryCategory.Function) {
416 const argNames: string[] = autocompleteEntry.arguments
417 .filter((arg) => [FunctionArgType.PositionalOnly, FunctionArgType.PositionalOrKeyword].includes(arg.type))
418 .map((arg) => arg.name)
419
420 const args = autocompleteEntry.arguments
421 .filter(
422 (arg) =>
423 !arg.hasDefault && [FunctionArgType.PositionalOnly, FunctionArgType.PositionalOrKeyword].includes(arg.type)
424 )
425 .map((arg) => {
426 return {
427 type: 'PY_ARG',
428 childSets: {
429 argument: [{ type: 'PYTHON_EXPRESSION', properties: {}, childSets: { tokens: [] } }],
430 },
431 properties: {},
432 }
433 })
434
435 // Ensure at least one empty argument if this function has any optional arguments.
436 if (autocompleteEntry.arguments.length !== 0 && args.length === 0) {
437 args.push({
438 type: 'PY_ARG',
439 childSets: {
440 argument: [{ type: 'PYTHON_EXPRESSION', properties: {}, childSets: { tokens: [] } }],
441 },
442 properties: {},
443 })
444 }
445
446 const callMemberNode = {
447 type: 'PYTHON_CALL_MEMBER',
448 properties: { member: autocompleteEntry.name },
449 meta: {
450 params: argNames,
451 },
452 childSets: {
453 object: [
454 {
455 type: 'PY_IDENTIFIER',
456 properties: { identifier: moduleName },

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected