Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

how to retrieve definition across modules / packages programatically using lsp client?#422

Unanswered
code2graph asked this question inQ&A
Discussion options

how to code up a lsp client to find references programatically?

I know aspython-lsp-server is a language server and theoreticallty I can connect to it and extract references from a function call is invoked.

For example for the following code:

import osfrom getpass import getpassfrom 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 outcheck_files_in_directory is defined in theGPT4Readability.utils.

I am struggling to find this informaiton and any help is welcome.

You must be logged in to vote

Replies: 1 comment

Comment options

As you said yourself and as the name "LanguageServer Protocol" implies, you'll need a client that connects to the language server in order to make use of it programmatically.

You might want to use a client library for this, e.g. for Pythonpylspclient seems reasonable (but I haven't tried it & unfortunately the code seems the be the only documentation). That library in particular has adefinition method to make a "Goto Definition Request" to the language server, which would then return the data necessary to do so.

You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@code2graph@smheidrich

[8]ページ先頭

©2009-2025 Movatter.jp