@@ -7,13 +7,7 @@ import * as vscode from 'vscode';
7
7
import * as lsp from 'vscode-languageserver-protocol' ;
8
8
import { RoslynLanguageServer } from '../server/roslynLanguageServer' ;
9
9
import { CSharpExtensionId } from '../../constants/csharpExtensionId' ;
10
- import { csharpDevkitExtensionId , getCSharpDevKit } from '../../utils/getCSharpDevKit' ;
11
- import path from 'path' ;
12
- import { readJsonSync } from 'fs-extra' ;
13
-
14
- export const copilotLanguageServerExtensionComponentName = '@microsoft/visualstudio.copilot.roslyn.languageserver' ;
15
- export const copilotLanguageServerExtensionAssemblyName = 'Microsoft.VisualStudio.Copilot.Roslyn.LanguageServer.dll' ;
16
- const copilotLanguageServerExtensionCapabilitiesFileName = 'capabilities.json' ;
10
+ import { getCSharpDevKit } from '../../utils/getCSharpDevKit' ;
17
11
18
12
type ActiveExperiments = { [ name : string ] : string | number | boolean | string [ ] } ;
19
13
@@ -29,17 +23,9 @@ export interface ContextResolveParam {
29
23
data ?: any ;
30
24
activeExperiments : ActiveExperiments ;
31
25
}
32
-
33
- const oldResolveContextMethodName = 'roslyn/resolveContext' ;
34
- const oldresolveContextMethodSupportedVersion = '1' ;
35
- const newResolveContextMethodName = 'roslyn/resolveContext@2' ;
36
- const newResolveContextMethodSupportedVersion = '1' ;
37
- const oldResolveContextRequest = new lsp . RequestType < ContextResolveParam , SupportedContextItem [ ] , void > (
38
- oldResolveContextMethodName ,
39
- lsp . ParameterStructures . auto
40
- ) ;
41
- const newResolveContextRequest = new lsp . RequestType < ContextResolveParam , SupportedContextItem [ ] , void > (
42
- newResolveContextMethodName ,
26
+ const resolveContextMethodName = 'roslyn/resolveContext@2' ;
27
+ const resolveContextRequest = new lsp . RequestType < ContextResolveParam , SupportedContextItem [ ] , void > (
28
+ resolveContextMethodName ,
43
29
lsp . ParameterStructures . auto
44
30
) ;
45
31
@@ -85,43 +71,8 @@ export function registerCopilotContextProviders(
85
71
return ;
86
72
}
87
73
88
- devkit . activate ( ) . then ( async ( devKitExports ) => {
74
+ devkit . activate ( ) . then ( async ( ) => {
89
75
try {
90
- let resolveMethod : lsp . RequestType < ContextResolveParam , SupportedContextItem [ ] , void > | undefined =
91
- undefined ;
92
- const copilotServerExtensionfolder = devKitExports . components [ copilotLanguageServerExtensionComponentName ] ;
93
- if ( copilotServerExtensionfolder ) {
94
- const capabilitiesFilePath = path . join (
95
- copilotServerExtensionfolder ,
96
- copilotLanguageServerExtensionCapabilitiesFileName
97
- ) ;
98
- const capabilitiesContent = await readJsonSync ( capabilitiesFilePath ) ;
99
- for ( const capability of capabilitiesContent ?. capabilities ?? [ ] ) {
100
- if (
101
- capability . method === oldResolveContextMethodName &&
102
- capability . version === oldresolveContextMethodSupportedVersion
103
- ) {
104
- resolveMethod = oldResolveContextRequest ;
105
- channel . debug ( `supported 'roslyn/resolveContext' method found in capabilities.json` ) ;
106
- break ;
107
- } else if (
108
- capability . method === newResolveContextMethodName &&
109
- capability . version === newResolveContextMethodSupportedVersion
110
- ) {
111
- resolveMethod = newResolveContextRequest ;
112
- channel . debug ( `supported 'roslyn/resolveContext@2' method found in capabilities.json` ) ;
113
- break ;
114
- }
115
- }
116
- }
117
-
118
- if ( ! resolveMethod ) {
119
- channel . debug (
120
- `Failed to find compatible version of context provider from installed version of ${ csharpDevkitExtensionId } .`
121
- ) ;
122
- return ;
123
- }
124
-
125
76
const copilotApi = vscode . extensions . getExtension < CopilotApi > ( 'github.copilot' ) ;
126
77
if ( ! copilotApi ) {
127
78
channel . debug (
@@ -150,7 +101,11 @@ export function registerCopilotContextProviders(
150
101
if ( ! contextResolveParam ) {
151
102
return [ ] ;
152
103
}
153
- const items = await languageServer . sendRequest ( resolveMethod , contextResolveParam , token ) ;
104
+ const items = await languageServer . sendRequest (
105
+ resolveContextRequest ,
106
+ contextResolveParam ,
107
+ token
108
+ ) ;
154
109
channel . trace ( `Copilot context provider resolved ${ items . length } items` ) ;
155
110
return items ;
156
111
} ,
0 commit comments