function getPartialPathCompletion()

in src/completion/completeJSONata.ts [74:106]


function getPartialPathCompletion({
  jsonataNode,
  node,
  asl,
  nodePosition,
  endPosition,
}: FunctionCompletionProperties): CompletionList | undefined {
  const isJsonataPathNode = jsonataNode.node.type === 'name' && jsonataNode.node.position && jsonataNode.node.value

  const isParentNodePath = jsonataNode.parent?.type === 'path'
  const parentPath = jsonataNode.parent?.steps

  if (isJsonataPathNode && isParentNodePath && parentPath) {
    const parentPathKey: string = parentPath
      .map((step) => step.value)
      .filter((value) => typeof value === 'string' && value)
      .join('.')

    const range = Range.create(
      Position.create(nodePosition.line, endPosition.character - parentPathKey.length),
      endPosition,
    )
    return {
      isIncomplete: true,
      items: getVariablesCompletionList({
        node,
        value: parentPathKey,
        asl,
        replaceRange: range,
      }),
    }
  }
}