Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consume the completion trigger character API #1776

Merged
merged 5 commits into from
Oct 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2156,4 +2156,4 @@
}
]
}
}
}
8 changes: 6 additions & 2 deletions src/features/completionItemProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import AbstractSupport from './abstractProvider';
import * as protocol from '../omnisharp/protocol';
import * as serverUtils from '../omnisharp/utils';
import {createRequest} from '../omnisharp/typeConvertion';
import {CompletionItemProvider, CompletionItem, CompletionItemKind, CancellationToken, TextDocument, Range, Position, CompletionList} from 'vscode';
import {CompletionItemProvider, CompletionItem, CompletionItemKind, CompletionContext, CompletionTriggerKind, CancellationToken, TextDocument, Range, Position, CompletionList} from 'vscode';

export default class OmniSharpCompletionItemProvider extends AbstractSupport implements CompletionItemProvider {

Expand All @@ -25,7 +25,7 @@ export default class OmniSharpCompletionItemProvider extends AbstractSupport imp
';', '+', '-', '*', '/', '%', '&', '|', '^', '!',
'~', '=', '<', '>', '?', '@', '#', '\'', '\"', '\\'];

public provideCompletionItems(document: TextDocument, position: Position, token: CancellationToken): Promise<CompletionList> {
public provideCompletionItems(document: TextDocument, position: Position, token: CancellationToken, context: CompletionContext): Promise<CompletionList> {

let wordToComplete = '';
let range = document.getWordRangeAtPosition(position);
Expand All @@ -38,6 +38,10 @@ export default class OmniSharpCompletionItemProvider extends AbstractSupport imp
req.WantDocumentationForEveryCompletionResult = true;
req.WantKind = true;
req.WantReturnType = true;
if (context.triggerKind == CompletionTriggerKind.TriggerCharacter)
{
req.TriggerCharacter = context.triggerCharacter;
}

return serverUtils.autoComplete(this._server, req).then(responses => {

Expand Down
2 changes: 1 addition & 1 deletion src/omnisharp/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function activate(context: vscode.ExtensionContext, reporter: TelemetryRe
localDisposables.push(vscode.languages.registerDocumentRangeFormattingEditProvider(documentSelector, new FormatProvider(server, reporter)));
localDisposables.push(vscode.languages.registerOnTypeFormattingEditProvider(documentSelector, new FormatProvider(server, reporter), '}', ';'));
}
localDisposables.push(vscode.languages.registerCompletionItemProvider(documentSelector, new CompletionItemProvider(server, reporter), '.'));
localDisposables.push(vscode.languages.registerCompletionItemProvider(documentSelector, new CompletionItemProvider(server, reporter), '.', ' '));
localDisposables.push(vscode.languages.registerWorkspaceSymbolProvider(new WorkspaceSymbolProvider(server, reporter)));
localDisposables.push(vscode.languages.registerSignatureHelpProvider(documentSelector, new SignatureHelpProvider(server, reporter), '(', ','));
const codeActionProvider = new CodeActionProvider(server, reporter);
Expand Down
1 change: 1 addition & 0 deletions src/omnisharp/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ export interface AutoCompleteRequest extends Request {
WantSnippet?: boolean;
WantReturnType?: boolean;
WantKind?: boolean;
TriggerCharacter?: string;
}

export interface AutoCompleteResponse {
Expand Down