parameters: (grammar, code_lines, module_node, pos)
docstring: Returns the possible node names (e.g. import_from, xor_test or yield_stmt).
docstring_summary: Returns the possible node names (e.g. import_from, xor_test or yield_stmt).
docstring_tokens: Returns the possible node names ( e . g . import_from xor_test or yield_stmt ) .
function: def get_stack_at_position(grammar, code_lines, module_node, pos):
      """
      Returns the possible node names (e.g. import_from, xor_test or yield_stmt).
      """
      class EndMarkerReached(Exception):
          pass
  
      def tokenize_without_endmarker(code):
          # TODO This is for now not an official parso API that exists purely
          #   for Jedi.
          tokens = grammar._tokenize(code)
          for token_ in tokens:
              if token_.string == safeword:
                  raise EndMarkerReached()
              elif token_.prefix.endswith(safeword):
                  # This happens with comments.
                  raise EndMarkerReached()
              else:
                  yield token_
  
      # The code might be indedented, just remove it.
      code = dedent(_get_code_for_stack(code_lines, module_node, pos))
      # We use a word to tell Jedi when we have reached the start of the
      # completion.
      # Use Z as a prefix because it's not part of a number suffix.
      safeword = 'ZZZ_USER_WANTS_TO_COMPLETE_HERE_WITH_JEDI'
      code = code + ' ' + safeword
  
      p = Parser(grammar._pgen_grammar, error_recovery=True)
      try:
          p.parse(tokens=tokenize_without_endmarker(code))
      except EndMarkerReached:
          return Stack(p.pgen_parser.stack)
      raise SystemError("This really shouldn't happen. There's a bug in Jedi.")
function_tokens: def get_stack_at_position ( grammar , code_lines , module_node , pos ) : class EndMarkerReached ( Exception ) : pass def tokenize_without_endmarker ( code ) : # TODO This is for now not an official parso API that exists purely #   for Jedi. tokens = grammar . _tokenize ( code ) for token_ in tokens : if token_ . string == safeword : raise EndMarkerReached ( ) elif token_ . prefix . endswith ( safeword ) : # This happens with comments. raise EndMarkerReached ( ) else : yield token_ # The code might be indedented, just remove it. code = dedent ( _get_code_for_stack ( code_lines , module_node , pos ) ) # We use a word to tell Jedi when we have reached the start of the # completion. # Use Z as a prefix because it's not part of a number suffix. safeword = 'ZZZ_USER_WANTS_TO_COMPLETE_HERE_WITH_JEDI' code = code + ' ' + safeword p = Parser ( grammar . _pgen_grammar , error_recovery = True ) try : p . parse ( tokens = tokenize_without_endmarker ( code ) ) except EndMarkerReached : return Stack ( p . pgen_parser . stack ) raise SystemError ( "This really shouldn't happen. There's a bug in Jedi." )