mirror of
https://github.com/Microsoft/vscode
synced 2024-07-17 02:57:19 +00:00
Add middleware for processing deprecated. Fix #79584
This commit is contained in:
parent
e493a50a3b
commit
210302848e
|
@ -9,9 +9,10 @@ import * as fs from 'fs';
|
||||||
import * as nls from 'vscode-nls';
|
import * as nls from 'vscode-nls';
|
||||||
const localize = nls.loadMessageBundle();
|
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 { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, Disposable } from 'vscode-languageclient';
|
||||||
import { getCustomDataPathsInAllWorkspaces, getCustomDataPathsFromAllExtensions } from './customData';
|
import { getCustomDataPathsInAllWorkspaces, getCustomDataPathsFromAllExtensions } from './customData';
|
||||||
|
import { isArray } from 'util';
|
||||||
|
|
||||||
// this method is called when vs code is activated
|
// this method is called when vs code is activated
|
||||||
export function activate(context: ExtensionContext) {
|
export function activate(context: ExtensionContext) {
|
||||||
|
@ -44,6 +45,32 @@ export function activate(context: ExtensionContext) {
|
||||||
},
|
},
|
||||||
initializationOptions: {
|
initializationOptions: {
|
||||||
dataPaths
|
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