Skip to content

Commit

Permalink
Add middleware for processing deprecated. Fix #79584
Browse files Browse the repository at this point in the history
  • Loading branch information
octref committed Aug 26, 2019
1 parent bf3779f commit faec415
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion extensions/css-language-features/client/src/cssMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
}
};

Expand Down

0 comments on commit faec415

Please sign in to comment.