Skip to content

Commit

Permalink
plugin: support 'deprecated' strikethrough
Browse files Browse the repository at this point in the history
The following pull-request adds support for the following:
- support for `tags` strikethrough for deprecated completion items.
- support for the deprecated `deprecated` flag for completion items.

Signed-off-by: vince-fugnitto <vincent.fugnitto@ericsson.com>
  • Loading branch information
vince-fugnitto committed Oct 5, 2020
1 parent 57b4b67 commit 9942018
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/plugin-ext/src/common/plugin-api-rpc-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import * as theia from '@theia/plugin';
import { UriComponents } from './uri-components';
import { CompletionItemTag } from '../plugin/types-impl';

// Should contains internal Plugin API types

Expand Down Expand Up @@ -114,6 +115,9 @@ export interface Completion {
commitCharacters?: string[];
additionalTextEdits?: SingleEditOperation[];
command?: Command;
tags?: CompletionItemTag[];
/** @deprecated use tags instead. */
deprecated?: boolean;
}

export interface SingleEditOperation {
Expand Down
9 changes: 7 additions & 2 deletions packages/plugin-ext/src/plugin/languages/completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { URI } from 'vscode-uri';
import * as theia from '@theia/plugin';
import { CompletionList, Range, SnippetString } from '../types-impl';
import { CompletionItemTag, CompletionList, Range, SnippetString } from '../types-impl';
import { DocumentsExtImpl } from '../documents';
import * as Converter from '../type-converters';
import { Position } from '../../common/plugin-api-rpc';
Expand Down Expand Up @@ -146,6 +146,10 @@ export class CompletionAdapter {
};
}

const tags = (!!item.tags?.length || item.deprecated === true)
? [CompletionItemTag.Deprecated]
: undefined;

return {
id,
parentId,
Expand All @@ -161,7 +165,8 @@ export class CompletionAdapter {
range,
additionalTextEdits: item.additionalTextEdits && item.additionalTextEdits.map(Converter.fromTextEdit),
command: this.commands.converter.toSafeCommand(item.command, toDispose),
commitCharacters: item.commitCharacters
commitCharacters: item.commitCharacters,
tags
};
}

Expand Down
5 changes: 5 additions & 0 deletions packages/plugin/src/theia.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6489,6 +6489,11 @@ declare module '@theia/plugin' {
*/
textEdit?: TextEdit;

/**
* @deprecated Use `CompletionItem.tags` instead.
*/
deprecated?: boolean;

/**
* Creates a new completion item.
*
Expand Down

0 comments on commit 9942018

Please sign in to comment.