-
Notifications
You must be signed in to change notification settings - Fork 676
/
referenceProvider.ts
28 lines (22 loc) · 1.3 KB
/
referenceProvider.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import AbstractSupport from './abstractProvider';
import * as protocol from '../omnisharp/protocol';
import * as serverUtils from '../omnisharp/utils';
import {createRequest, toLocation} from '../omnisharp/typeConvertion';
import {ReferenceProvider, Location, TextDocument, CancellationToken, Position} from 'vscode';
export default class OmnisharpReferenceProvider extends AbstractSupport implements ReferenceProvider {
public provideReferences(document: TextDocument, position: Position, options: { includeDeclaration: boolean;}, token: CancellationToken): Promise<Location[]> {
let req = createRequest<protocol.FindUsagesRequest>(document, position);
req.OnlyThisFile = false;
req.ExcludeDefinition = false;
return serverUtils.findUsages(this._server, req, token).then(res => {
if (res && Array.isArray(res.QuickFixes)) {
return res.QuickFixes.map(toLocation);
}
});
}
}