Skip to content

Commit cbaf65f

Browse files
ege0zcanEge Ozcan
andauthored
feat: add new lsp extension to send dependency information from client 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]>
1 parent e2d7267 commit cbaf65f

File tree

8 files changed

+53
-8
lines changed

8 files changed

+53
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"precompile": "npm run generate-types --workspaces --if-present",
3030
"compile": "tsc --build && npm run compile --workspaces --if-present",
3131
"check:formatting": "prettier --check .",
32-
"fix:prettier": "prettier . --write",
32+
"format": "prettier . --write",
3333
"format-staged": "npx pretty-quick --staged",
3434
"prepare": "husky .husky",
3535
"test": "npm run test --workspaces --if-present",
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import {
2+
DID_CHANGE_DEPENDENCY_PATHS_NOTIFICATION_METHOD,
3+
DidChangeDependencyPathsParams,
4+
ProtocolNotificationType,
5+
} from './lsp'
6+
7+
export const didChangeDependencyPathsNotificationType = new ProtocolNotificationType<
8+
DidChangeDependencyPathsParams,
9+
void
10+
>(DID_CHANGE_DEPENDENCY_PATHS_NOTIFICATION_METHOD)

runtimes/protocol/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
export * from './lsp'
21
export * from './auth'
32
export * from './chat'
4-
export * from './telemetry'
3+
export * from './didChangeDependencyPaths'
54
export * from './getConfigurationFromServer'
65
export * from './identity-management'
6+
export * from './lsp'
77
export * from './notification'
8+
export * from './telemetry'

runtimes/runtimes/base-runtime.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
TextDocument,
1111
telemetryNotificationType,
1212
SemanticTokensRequest,
13-
13+
didChangeDependencyPathsNotificationType,
1414
// Chat
1515
chatRequestType,
1616
endChatRequestType,
@@ -37,7 +37,6 @@ import {
3737
Runtime,
3838
Telemetry,
3939
Workspace,
40-
Notification,
4140
SDKClientConstructorV2,
4241
SDKClientConstructorV3,
4342
SDKInitializator,
@@ -59,7 +58,7 @@ import {
5958
updateProfileRequestType,
6059
} from '../protocol/identity-management'
6160
import { IdentityManagement } from '../server-interface/identity-management'
62-
import { Encoding, WebBase64Encoding } from './encoding'
61+
import { WebBase64Encoding } from './encoding'
6362
import { LoggingServer } from './lsp/router/loggingServer'
6463
import { Service } from 'aws-sdk'
6564
import { ServiceConfigurationOptions } from 'aws-sdk/lib/service'
@@ -205,6 +204,9 @@ export const baseRuntime = (connections: { reader: MessageReader; writer: Messag
205204
onLogInlineCompletionSessionResults: handler => {
206205
lspConnection.onNotification(logInlineCompletionSessionResultsNotificationType, handler)
207206
},
207+
onDidChangeDependencyPaths(handler) {
208+
lspConnection.onNotification(didChangeDependencyPathsNotificationType, handler)
209+
},
208210
},
209211
}
210212

runtimes/runtimes/standalone.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
ShowDocumentRequest,
1616
CancellationToken,
1717
GetSsoTokenParams,
18+
didChangeDependencyPathsNotificationType,
1819
} from '../protocol'
1920
import { ProposedFeatures, createConnection } from 'vscode-languageserver/node'
2021
import {
@@ -328,6 +329,9 @@ export const standalone = (props: RuntimeProps) => {
328329
onLogInlineCompletionSessionResults: handler => {
329330
lspConnection.onNotification(logInlineCompletionSessionResultsNotificationType, handler)
330331
},
332+
onDidChangeDependencyPaths(handler) {
333+
lspConnection.onNotification(didChangeDependencyPathsNotificationType, handler)
334+
},
331335
},
332336
}
333337

runtimes/server-interface/lsp.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import {
4646
DeleteFilesParams,
4747
CreateFilesParams,
4848
RenameFilesParams,
49+
DidChangeDependencyPathsParams,
4950
} from '../protocol'
5051

5152
// Re-export whole surface of LSP protocol used in Runtimes.
@@ -144,5 +145,6 @@ export type Lsp = {
144145
handler: NotificationHandler<LogInlineCompletionSessionResultsParams>
145146
) => void
146147
onGetConfigurationFromServer: (handler: RequestHandler<GetConfigurationFromServerParams, LSPAny, void>) => void
148+
onDidChangeDependencyPaths: (handler: NotificationHandler<DidChangeDependencyPathsParams>) => void
147149
}
148150
}

types/didChangeDependencyPaths.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export const DID_CHANGE_DEPENDENCY_PATHS_NOTIFICATION_METHOD = 'aws/didChangeDependencyPaths'
2+
3+
/**
4+
* Parameters for notifying AWS language server about dependency paths
5+
*/
6+
export interface DidChangeDependencyPathsParams {
7+
/** Name of the module being processed */
8+
moduleName: string
9+
/** Programming language runtime (e.g., 'javascript', 'python', 'java') */
10+
runtimeLanguage: string
11+
/** Absolute paths to dependency files and directories*/
12+
paths: string[]
13+
/**
14+
* Glob patterns to include specific files/directories
15+
* Patterns should conform to https://github.com/isaacs/node-glob
16+
* @optional
17+
*/
18+
includePatterns?: string[]
19+
/**
20+
* Glob patterns to exclude specific files/directories
21+
* Patterns should conform to https://github.com/isaacs/node-glob
22+
* @optional
23+
*/
24+
excludePatterns?: string[]
25+
}

types/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
export * from './chat'
21
export * from './auth'
3-
export * from './lsp'
2+
export * from './chat'
3+
export * from './didChangeDependencyPaths'
44
export * from './inlineCompletionWithReferences'
5+
export * from './lsp'

0 commit comments

Comments
 (0)