Add middleware for processing deprecated. Fix #79584
This commit is contained in:
parent
e493a50a3b
commit
210302848e
1 changed files with 28 additions and 1 deletions
|
@ -9,9 +9,10 @@ import * as fs from 'fs';
|
|||
import * as nls from 'vscode-nls';
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
import { languages, window, commands, ExtensionContext, Range, Position, CompletionItem, CompletionItemKind, TextEdit, SnippetString, workspace } from 'vscode';
|
||||
import { languages, window, commands, ExtensionContext, Range, Position, CompletionItem, CompletionItemKind, TextEdit, SnippetString, workspace, CompletionItemTag } from 'vscode';
|
||||
import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, Disposable } from 'vscode-languageclient';
|
||||
import { getCustomDataPathsInAllWorkspaces, getCustomDataPathsFromAllExtensions } from './customData';
|
||||
import { isArray } from 'util';
|
||||
|
||||
// this method is called when vs code is activated
|
||||
export function activate(context: ExtensionContext) {
|
||||
|
@ -44,6 +45,32 @@ export function activate(context: ExtensionContext) {
|
|||
},
|
||||
initializationOptions: {
|
||||
dataPaths
|
||||
},
|
||||
middleware: {
|
||||
async provideCompletionItem(document, position, context, token, next) {
|
||||
const result = await next(document, position, context, token);
|
||||
if (result) {
|
||||
if (isArray(result)) {
|
||||
return result.map(r => {
|
||||
return {
|
||||
...r,
|
||||
tags: (r as any).deprecated ? [CompletionItemTag.Deprecated] : undefined
|
||||
};
|
||||
});
|
||||
} else {
|
||||
return {
|
||||
isIncomplete: result.isIncomplete,
|
||||
items: result.items.map(r => {
|
||||
return {
|
||||
...r,
|
||||
tags: (r as any).deprecated ? [CompletionItemTag.Deprecated] : undefined
|
||||
};
|
||||
})
|
||||
};
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue