Skip to content

Commit

Permalink
feat: add new lsp extension to send dependency information from clien…
Browse files Browse the repository at this point in the history
…t to servers (#338)

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

* chore: add docstrings to notifyDependencyPathsParams

* chore: rename notifyDependencyPaths to didChangeDependencyPaths

---------

Co-authored-by: Ege Ozcan <[email protected]>
  • Loading branch information
ege0zcan and Ege Ozcan authored Feb 27, 2025
1 parent e2d7267 commit cbaf65f
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"precompile": "npm run generate-types --workspaces --if-present",
"compile": "tsc --build && npm run compile --workspaces --if-present",
"check:formatting": "prettier --check .",
"fix:prettier": "prettier . --write",
"format": "prettier . --write",
"format-staged": "npx pretty-quick --staged",
"prepare": "husky .husky",
"test": "npm run test --workspaces --if-present",
Expand Down
10 changes: 10 additions & 0 deletions runtimes/protocol/didChangeDependencyPaths.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {
DID_CHANGE_DEPENDENCY_PATHS_NOTIFICATION_METHOD,
DidChangeDependencyPathsParams,
ProtocolNotificationType,
} from './lsp'

export const didChangeDependencyPathsNotificationType = new ProtocolNotificationType<
DidChangeDependencyPathsParams,
void
>(DID_CHANGE_DEPENDENCY_PATHS_NOTIFICATION_METHOD)
5 changes: 3 additions & 2 deletions runtimes/protocol/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export * from './lsp'
export * from './auth'
export * from './chat'
export * from './telemetry'
export * from './didChangeDependencyPaths'
export * from './getConfigurationFromServer'
export * from './identity-management'
export * from './lsp'
export * from './notification'
export * from './telemetry'
8 changes: 5 additions & 3 deletions runtimes/runtimes/base-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
TextDocument,
telemetryNotificationType,
SemanticTokensRequest,

didChangeDependencyPathsNotificationType,
// Chat
chatRequestType,
endChatRequestType,
Expand All @@ -37,7 +37,6 @@ import {
Runtime,
Telemetry,
Workspace,
Notification,
SDKClientConstructorV2,
SDKClientConstructorV3,
SDKInitializator,
Expand All @@ -59,7 +58,7 @@ import {
updateProfileRequestType,
} from '../protocol/identity-management'
import { IdentityManagement } from '../server-interface/identity-management'
import { Encoding, WebBase64Encoding } from './encoding'
import { WebBase64Encoding } from './encoding'
import { LoggingServer } from './lsp/router/loggingServer'
import { Service } from 'aws-sdk'
import { ServiceConfigurationOptions } from 'aws-sdk/lib/service'
Expand Down Expand Up @@ -205,6 +204,9 @@ export const baseRuntime = (connections: { reader: MessageReader; writer: Messag
onLogInlineCompletionSessionResults: handler => {
lspConnection.onNotification(logInlineCompletionSessionResultsNotificationType, handler)
},
onDidChangeDependencyPaths(handler) {
lspConnection.onNotification(didChangeDependencyPathsNotificationType, handler)
},
},
}

Expand Down
4 changes: 4 additions & 0 deletions runtimes/runtimes/standalone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
ShowDocumentRequest,
CancellationToken,
GetSsoTokenParams,
didChangeDependencyPathsNotificationType,
} from '../protocol'
import { ProposedFeatures, createConnection } from 'vscode-languageserver/node'
import {
Expand Down Expand Up @@ -328,6 +329,9 @@ export const standalone = (props: RuntimeProps) => {
onLogInlineCompletionSessionResults: handler => {
lspConnection.onNotification(logInlineCompletionSessionResultsNotificationType, handler)
},
onDidChangeDependencyPaths(handler) {
lspConnection.onNotification(didChangeDependencyPathsNotificationType, handler)
},
},
}

Expand Down
2 changes: 2 additions & 0 deletions runtimes/server-interface/lsp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {
DeleteFilesParams,
CreateFilesParams,
RenameFilesParams,
DidChangeDependencyPathsParams,
} from '../protocol'

// Re-export whole surface of LSP protocol used in Runtimes.
Expand Down Expand Up @@ -144,5 +145,6 @@ export type Lsp = {
handler: NotificationHandler<LogInlineCompletionSessionResultsParams>
) => void
onGetConfigurationFromServer: (handler: RequestHandler<GetConfigurationFromServerParams, LSPAny, void>) => void
onDidChangeDependencyPaths: (handler: NotificationHandler<DidChangeDependencyPathsParams>) => void
}
}
25 changes: 25 additions & 0 deletions types/didChangeDependencyPaths.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export const DID_CHANGE_DEPENDENCY_PATHS_NOTIFICATION_METHOD = 'aws/didChangeDependencyPaths'

/**
* Parameters for notifying AWS language server about dependency paths
*/
export interface DidChangeDependencyPathsParams {
/** Name of the module being processed */
moduleName: string
/** Programming language runtime (e.g., 'javascript', 'python', 'java') */
runtimeLanguage: string
/** Absolute paths to dependency files and directories*/
paths: string[]
/**
* Glob patterns to include specific files/directories
* Patterns should conform to https://github.com/isaacs/node-glob
* @optional
*/
includePatterns?: string[]
/**
* Glob patterns to exclude specific files/directories
* Patterns should conform to https://github.com/isaacs/node-glob
* @optional
*/
excludePatterns?: string[]
}
5 changes: 3 additions & 2 deletions types/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './chat'
export * from './auth'
export * from './lsp'
export * from './chat'
export * from './didChangeDependencyPaths'
export * from './inlineCompletionWithReferences'
export * from './lsp'

0 comments on commit cbaf65f

Please sign in to comment.