Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add new lsp extension to send dependency information from client to servers #338

Merged
merged 3 commits into from
Feb 27, 2025

Conversation

ege0zcan
Copy link
Contributor

Problem

Servers don't have in depth information regarding dependencies on the client side

Solution

Define new interface that allows clients to send dependency information to servers

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.


export interface NotifyDependencyPathsParams {
moduleName: string
programmingLangugage: string

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo. Also, "prog lang" may be misleading. This is more like a "mode" or "kind" which triggers heuristics that look at the workspace. In other places (Lambda, SAM CLI, Toolkits, even CodeWhisperer), it's called a "runtime".

For example, "node" is not a programming language, but a node project involves js + ts. Which "programming language" would we specify there?

Suggested change
programmingLangugage: string
runtime: string

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point, what about runtimeLanguage I still think we need the language information and not the runtime

For a node project with both js and ts files, the client can send one notification for each language, imo this is not redundant but rather being explicit in the communication. I am open to discuss

moduleName: string
programmingLangugage: string
files: string[]
dirs: string[]
Copy link

@justinmk3 justinmk3 Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a depth parameter?

Suggested change
dirs: string[]
/** Absolute paths to directories to watch(?) */
dirs: string[]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, at least right now I would rather keep that detail out of scope and let the servers decide on depth. It would be easy to add an extra field in the future

@@ -0,0 +1,10 @@
export const NOTIFY_DEPENDENCY_PATHS_NOTIFICATION_METHOD = 'aws/notifyDependencyPaths'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(off topic: uppercase is not gaining anything here except a longer, more awkward name.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried following the existing convention to keep a unified approach but indeed an unwanted side effect is the lengthy constant name. Though there is a clear benefit of having this string in a constant since it will be used by runtimes as well as by clients

@@ -0,0 +1,10 @@
export const NOTIFY_DEPENDENCY_PATHS_NOTIFICATION_METHOD = 'aws/notifyDependencyPaths'

export interface NotifyDependencyPathsParams {
Copy link
Contributor

@volodkevych volodkevych Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's difficult to understand what this protocol is needed for and how to use it. Some context, proper documentation may help.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1
I expect some discussions on this PR so I didn't add any documentation just yet since things are fluid at the moment

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, notify dependency paths about what? Is this a change notification that the dependency paths have been updated? If so we can mimic https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_didChangeWorkspaceFolders and call it

didChangeDependencyPaths instead?

Comment on lines 12 to 14
files: string[]
/** Absolute paths to dependency directories*/
dirs: string[]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between { files: string[], dirs: string[]} and {paths: string[]}?

@ege0zcan ege0zcan marked this pull request as ready for review February 26, 2025 22:23
@ege0zcan ege0zcan requested a review from a team as a code owner February 26, 2025 22:23
@kmile
Copy link
Contributor

kmile commented Feb 26, 2025

Thanks for the updates, looks good to me!

@ege0zcan ege0zcan merged commit cbaf65f into main Feb 27, 2025
4 checks passed
@ege0zcan ege0zcan deleted the dependencyDisclosure branch February 27, 2025 12:40
/** Name of the module being processed */
moduleName: string
/** Programming language runtime (e.g., 'javascript', 'python', 'java') */
runtimeLanguage: string

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a node project with both js and ts files, the client can send one notification for each language, imo this is not redundant but rather being explicit in the communication. I am open to discuss

I thought we discussed that the state for dependency tracking was defined exactly once for a workspace? Thus multiple requests overwrite the previous request.

If that's not the case, then the docstring here should mention "the client must send one notification for each language".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants