@@ -7,7 +7,7 @@ import { URI, UriComponents } from 'vs/base/common/uri';
7
7
import { mixin } from 'vs/base/common/objects' ;
8
8
import type * as vscode from 'vscode' ;
9
9
import * as typeConvert from 'vs/workbench/api/common/extHostTypeConverters' ;
10
- import { Range , Disposable , CompletionList , SnippetString , CodeActionKind , SymbolInformation , DocumentSymbol , SemanticTokensEdits , SemanticTokens , SemanticTokensEdit , Location , InlineCompletionTriggerKindNew , InlineCompletionTriggerKind } from 'vs/workbench/api/common/extHostTypes' ;
10
+ import { Range , Disposable , CompletionList , SnippetString , CodeActionKind , SymbolInformation , DocumentSymbol , SemanticTokensEdits , SemanticTokens , SemanticTokensEdit , Location , InlineCompletionTriggerKind } from 'vs/workbench/api/common/extHostTypes' ;
11
11
import { ISingleEditOperation } from 'vs/editor/common/core/editOperation' ;
12
12
import * as languages from 'vs/editor/common/languages' ;
13
13
import { ExtHostDocuments } from 'vs/workbench/api/common/extHostDocuments' ;
@@ -1184,110 +1184,6 @@ class InlineCompletionAdapter extends InlineCompletionAdapterBase {
1184
1184
}
1185
1185
}
1186
1186
1187
- class InlineCompletionAdapterNew extends InlineCompletionAdapterBase {
1188
- private readonly _references = new ReferenceMap < {
1189
- dispose ( ) : void ;
1190
- items : readonly vscode . InlineCompletionItemNew [ ] ;
1191
- } > ( ) ;
1192
-
1193
- private readonly isAdditionProposedApiEnabled = isProposedApiEnabled ( this . extension , 'inlineCompletionsAdditions' ) ;
1194
-
1195
- constructor (
1196
- private readonly extension : IExtensionDescription ,
1197
- private readonly _documents : ExtHostDocuments ,
1198
- private readonly _provider : vscode . InlineCompletionItemProviderNew ,
1199
- private readonly _commands : CommandsConverter ,
1200
- ) {
1201
- super ( ) ;
1202
- }
1203
-
1204
- private readonly languageTriggerKindToVSCodeTriggerKind : Record < languages . InlineCompletionTriggerKind , vscode . InlineCompletionTriggerKindNew > = {
1205
- [ languages . InlineCompletionTriggerKind . Automatic ] : InlineCompletionTriggerKindNew . Automatic ,
1206
- [ languages . InlineCompletionTriggerKind . Explicit ] : InlineCompletionTriggerKindNew . Invoke ,
1207
- } ;
1208
-
1209
- override async provideInlineCompletions ( resource : URI , position : IPosition , context : languages . InlineCompletionContext , token : CancellationToken ) : Promise < extHostProtocol . IdentifiableInlineCompletions | undefined > {
1210
- const doc = this . _documents . getDocument ( resource ) ;
1211
- const pos = typeConvert . Position . to ( position ) ;
1212
-
1213
- const result = await this . _provider . provideInlineCompletionItems ( doc , pos , {
1214
- selectedCompletionInfo :
1215
- context . selectedSuggestionInfo
1216
- ? {
1217
- range : typeConvert . Range . to ( context . selectedSuggestionInfo . range ) ,
1218
- text : context . selectedSuggestionInfo . text
1219
- }
1220
- : undefined ,
1221
- triggerKind : this . languageTriggerKindToVSCodeTriggerKind [ context . triggerKind ]
1222
- } , token ) ;
1223
-
1224
- if ( ! result ) {
1225
- // undefined and null are valid results
1226
- return undefined ;
1227
- }
1228
-
1229
- if ( token . isCancellationRequested ) {
1230
- // cancelled -> return without further ado, esp no caching
1231
- // of results as they will leak
1232
- return undefined ;
1233
- }
1234
-
1235
- const normalizedResult = Array . isArray ( result ) ? result : result . items ;
1236
- const commands = Array . isArray ( result ) ? [ ] : result . commands || [ ] ;
1237
-
1238
- let disposableStore : DisposableStore | undefined = undefined ;
1239
- const pid = this . _references . createReferenceId ( {
1240
- dispose ( ) {
1241
- disposableStore ?. dispose ( ) ;
1242
- } ,
1243
- items : normalizedResult
1244
- } ) ;
1245
-
1246
- return {
1247
- pid,
1248
- items : normalizedResult . map < extHostProtocol . IdentifiableInlineCompletion > ( ( item , idx ) => {
1249
- let command : languages . Command | undefined = undefined ;
1250
- if ( item . command ) {
1251
- if ( ! disposableStore ) {
1252
- disposableStore = new DisposableStore ( ) ;
1253
- }
1254
- command = this . _commands . toInternal ( item . command , disposableStore ) ;
1255
- }
1256
-
1257
- const insertText = item . insertText ;
1258
- return ( {
1259
- insertText : typeof insertText === 'string' ? insertText : { snippet : insertText . value } ,
1260
- filterText : item . filterText ,
1261
- range : item . range ? typeConvert . Range . from ( item . range ) : undefined ,
1262
- command,
1263
- idx : idx ,
1264
- completeBracketPairs : this . isAdditionProposedApiEnabled ? item . completeBracketPairs : false
1265
- } ) ;
1266
- } ) ,
1267
- commands : commands . map ( c => {
1268
- if ( ! disposableStore ) {
1269
- disposableStore = new DisposableStore ( ) ;
1270
- }
1271
- return this . _commands . toInternal ( c , disposableStore ) ;
1272
- } )
1273
- } ;
1274
- }
1275
-
1276
- override disposeCompletions ( pid : number ) {
1277
- const data = this . _references . disposeReferenceId ( pid ) ;
1278
- data ?. dispose ( ) ;
1279
- }
1280
-
1281
- override handleDidShowCompletionItem ( pid : number , idx : number ) : void {
1282
- const completionItem = this . _references . get ( pid ) ?. items [ idx ] ;
1283
- if ( completionItem ) {
1284
- if ( this . _provider . handleDidShowCompletionItem && this . isAdditionProposedApiEnabled ) {
1285
- this . _provider . handleDidShowCompletionItem ( completionItem ) ;
1286
- }
1287
- }
1288
- }
1289
- }
1290
-
1291
1187
class ReferenceMap < T > {
1292
1188
private readonly _references = new Map < number , T > ( ) ;
1293
1189
private _idPool = 1 ;
@@ -1821,7 +1717,7 @@ type Adapter = DocumentSymbolAdapter | CodeLensAdapter | DefinitionAdapter | Hov
1821
1717
| SelectionRangeAdapter | CallHierarchyAdapter | TypeHierarchyAdapter
1822
1718
| DocumentSemanticTokensAdapter | DocumentRangeSemanticTokensAdapter
1823
1719
| EvaluatableExpressionAdapter | InlineValuesAdapter
1824
- | LinkedEditingRangeAdapter | InlayHintsAdapter | InlineCompletionAdapter | InlineCompletionAdapterNew
1720
+ | LinkedEditingRangeAdapter | InlayHintsAdapter | InlineCompletionAdapter
1825
1721
| DocumentOnDropEditAdapter ;
1826
1722
1827
1723
class AdapterData {
@@ -2253,12 +2149,6 @@ export class ExtHostLanguageFeatures implements extHostProtocol.ExtHostLanguageF
2253
2149
return this . _createDisposable ( handle ) ;
2254
2150
}
2255
2151
2256
- registerInlineCompletionsProviderNew ( extension : IExtensionDescription , selector : vscode . DocumentSelector , provider : vscode . InlineCompletionItemProviderNew ) : vscode . Disposable {
2257
- const handle = this . _addNewAdapter ( new InlineCompletionAdapterNew ( extension , this . _documents , provider , this . _commands . converter ) , extension ) ;
2258
- this . _proxy . $registerInlineCompletionsSupport ( handle , this . _transformDocumentSelector ( selector ) , true ) ;
2259
- return this . _createDisposable ( handle ) ;
2260
- }
2261
-
2262
2152
$provideInlineCompletions ( handle : number , resource : UriComponents , position : IPosition , context : languages . InlineCompletionContext , token : CancellationToken ) : Promise < extHostProtocol . IdentifiableInlineCompletions | undefined > {
2263
2153
return this . _withAdapter ( handle , InlineCompletionAdapterBase , adapter => adapter . provideInlineCompletions ( URI . revive ( resource ) , position , context , token ) , undefined , token ) ;
2264
2154
}
0 commit comments