pappasam/jedi-language-server

how to run jedi to find references using a lsp client?

Closed this issue · 1 comments

Can I run a lsp client to find references programatically?

I know jedi is a language server as theoreticallty I can connect to pylance and extract references from a function call is invoked.

For example for the following code:

import os
from getpass import getpass
from GPT4Readability.utils import *
import importlib.resources as pkg_resources  


def generate_readme(root_dir, output_name, model):
    """Generates a README.md file based on the python files in the provided directory

    Args:
        root_dir (str): The root directory of the python package to parse and generate a readme for
    """

    # prompt_folder_name = os.path.join(os.path.dirname(__file__), "prompts")
    # prompt_path = os.path.join(prompt_folder_name, "readme_prompt.txt")

    with pkg_resources.open_text('GPT4Readability.prompts','readme_prompt.txt') as f:         
        inb_msg = f.read()

    # with open(prompt_path) as f:
    #     lines = f.readlines()
    # inb_msg = "".join(lines)

    file_check_result = check_files_in_directory(root_dir)

Here I need to find out check_files_in_directory is defined in the GPT4Readability.utils.

I am stugglign to find this informaiton.

I know jedi is a language server

Jedi is not a language server. It is a Python API. Some projects like jedi-language-server build language servers on top of Jedi.


This is probably what you are looking for: https://jedi.readthedocs.io/en/latest/docs/api.html#jedi.Script.get_references