mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 02:28:34 +01:00
Add middleware for processing deprecated. Fix #79584
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user