Skip to content

Commit cb1b063

Browse files
Merge pull request #1222 from ivanz/goto-implementation
Implemented "Go to Implementation" and "Peek Implementation"
2 parents 29806fb + ac3dbdf commit cb1b063

File tree

6 files changed

+49
-6
lines changed

6 files changed

+49
-6
lines changed

CHANGELOG.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 1.8.0 _(Not Yet Released)_
2+
3+
#### Go to Implementation
4+
5+
* Added support for "Go to Implementation" and "Peek Implementation" introduced in Visual Studio Code 1.9. ([#37](https://github.com/OmniSharp/omnisharp-vscode/issues/37)) _(Contributed by [@ivanz](https://github.com/ivanz))_
6+
17
## 1.7.0 (February 8, 2017)
28

39
#### Syntax Hightlighting
@@ -83,15 +89,15 @@
8389
* Brings support for running all supported distros on top of Linux Kernel >= 4.6
8490
* Enable debugger support for Arch Linux ([#564](https://github.com/OmniSharp/omnisharp-vscode/issues/564))
8591
* Improve debugger install errors for macOS without openSSL symlinks ([#986](https://github.com/OmniSharp/omnisharp-vscode/pull/986)), and x86 Windows ([#998](https://github.com/OmniSharp/omnisharp-vscode/pull/998)).
86-
* Improve debugger performance using precompiled debugger binaries ([#896](https://github.com/OmniSharp/omnisharp-vscode/issues/896))([#971](https://github.com/OmniSharp/omnisharp-vscode/issues/971)).
92+
* Improve debugger performance using precompiled debugger binaries ([#896](https://github.com/OmniSharp/omnisharp-vscode/issues/896))([#971](https://github.com/OmniSharp/omnisharp-vscode/issues/971)).
8793

8894
#### Syntax Highlighting
8995

9096
* Tons of great syntax highlighting fixes and support! _(All contributed by [@ivanz](https://github.com/ivanz))_
9197
* Fix for field declarations. ([#757](https://github.com/OmniSharp/omnisharp-vscode/issues/757))
9298
* Fix for generic types with multiple type parameters. ([#960](https://github.com/OmniSharp/omnisharp-vscode/issues/960))
9399
* Proper support for interpolated strings (verbatim and non-verbatim). ([#852](https://github.com/OmniSharp/omnisharp-vscode/issues/852))
94-
* Fix for multi-line properties. ([#854](https://github.com/OmniSharp/omnisharp-vscode/issues/854))
100+
* Fix for multi-line properties. ([#854](https://github.com/OmniSharp/omnisharp-vscode/issues/854))
95101
* Fixes for events, nested type references (e.g. `Root.IInterface<Something.Nested>`), variable declarations, nested classes, and fields spanning multiple lines
96102

97103
#### Hover Tooltips
@@ -117,7 +123,7 @@
117123
* Ensure diagnostics are cleared in files when they are no longer needed. ([#858](https://github.com/OmniSharp/omnisharp-vscode/issues/858))
118124
* Enqueue requests for diagnostics in visible editors when the extension starts up. ([#843](https://github.com/OmniSharp/omnisharp-vscode/issues/843))
119125
* Provide fallback URLs for debugger downloads. ([#930](https://github.com/OmniSharp/omnisharp-vscode/issues/930))
120-
* Properly require .NET Framework 4.6 in the OmniSharp.exe.config file to ensure that the user is displayed a dialog on Windows machines that don't have .NET Framework 4.6 installed. ([#937](https://github.com/OmniSharp/omnisharp-vscode/issues/937))
126+
* Properly require .NET Framework 4.6 in the OmniSharp.exe.config file to ensure that the user is displayed a dialog on Windows machines that don't have .NET Framework 4.6 installed. ([#937](https://github.com/OmniSharp/omnisharp-vscode/issues/937))
121127
* Fix issue with installing on non-English installations of Windows. ([#938](https://github.com/OmniSharp/omnisharp-vscode/issues/938))
122128
* Display platform information when acquiring runtime dependencies. ([#948](https://github.com/OmniSharp/omnisharp-vscode/issues/948))
123129

@@ -165,7 +171,7 @@ Several new settings have been added:
165171

166172
#### Performance
167173

168-
* Major improvements have been made to editor performance. The communication with the OmniSharp server has been rewritten to allow long-running operations (such as gathering all errors and warnings) to queue while high priority operations (such as text buffer changes) run serially. ([#902](https://github.com/OmniSharp/omnisharp-vscode/pull/902)) _(Thanks to [@david-driscoll](https://github.com/david-driscoll) for his help with this change!)_
174+
* Major improvements have been made to editor performance. The communication with the OmniSharp server has been rewritten to allow long-running operations (such as gathering all errors and warnings) to queue while high priority operations (such as text buffer changes) run serially. ([#902](https://github.com/OmniSharp/omnisharp-vscode/pull/902)) _(Thanks to [@david-driscoll](https://github.com/david-driscoll) for his help with this change!)_
169175

170176
#### Other Improvements
171177

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"tslint-microsoft-contrib": "^2.0.12",
6262
"typescript": "^2.0.3",
6363
"vsce": "^1.7.0",
64-
"vscode": "^1.0.0"
64+
"vscode": "^1.0.3"
6565
},
6666
"runtimeDependencies": [
6767
{
@@ -300,7 +300,7 @@
300300
}
301301
],
302302
"engines": {
303-
"vscode": "^1.5.0"
303+
"vscode": "^1.9.0"
304304
},
305305
"activationEvents": [
306306
"onLanguage:csharp",
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
'use strict';
7+
8+
import AbstractSupport from './abstractProvider';
9+
import { FindImplementationsRequest } from '../omnisharp/protocol';
10+
import * as serverUtils from '../omnisharp/utils';
11+
import { createRequest, toLocation } from '../omnisharp/typeConvertion';
12+
import { TextDocument, Position, CancellationToken, ImplementationProvider, ProviderResult, Definition } from 'vscode';
13+
14+
export default class CSharpImplementationProvider extends AbstractSupport implements ImplementationProvider {
15+
public provideImplementation(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<Definition> {
16+
const request = <FindImplementationsRequest>createRequest(document, position);
17+
18+
return serverUtils.findImplementations(this._server, request, token).then(response => {
19+
if (!response || !response.QuickFixes) {
20+
return;
21+
}
22+
23+
return response.QuickFixes.map(fix => toLocation(fix));
24+
});
25+
}
26+
}

src/omnisharp/extension.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as vscode from 'vscode';
77
import TelemetryReporter from 'vscode-extension-telemetry';
88

99
import DefinitionProvider from '../features/definitionProvider';
10+
import ImplementationProvider from '../features/implementationProvider';
1011
import CodeLensProvider from '../features/codeLensProvider';
1112
import DefinitionMetadataDocumentProvider from '../features/definitionMetadataDocumentProvider';
1213
import DocumentHighlightProvider from '../features/documentHighlightProvider';
@@ -47,6 +48,7 @@ export function activate(context: vscode.ExtensionContext, reporter: TelemetryRe
4748
localDisposables.push(definitionMetadataDocumentProvider);
4849

4950
localDisposables.push(vscode.languages.registerDefinitionProvider(documentSelector, new DefinitionProvider(server, definitionMetadataDocumentProvider)));
51+
localDisposables.push(vscode.languages.registerImplementationProvider(documentSelector, new ImplementationProvider(server)));
5052
localDisposables.push(vscode.languages.registerCodeLensProvider(documentSelector, new CodeLensProvider(server)));
5153
localDisposables.push(vscode.languages.registerDocumentHighlightProvider(documentSelector, new DocumentHighlightProvider(server)));
5254
localDisposables.push(vscode.languages.registerDocumentSymbolProvider(documentSelector, new DocumentSymbolProvider(server)));

src/omnisharp/protocol.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export module Requests {
2121
export const FormatRange = '/formatRange';
2222
export const GetCodeActions = '/getcodeactions';
2323
export const GoToDefinition = '/gotoDefinition';
24+
export const FindImplementations = '/findimplementations';
2425
export const Projects = '/projects';
2526
export const RemoveFromProject = '/removefromproject';
2627
export const Rename = '/rename';
@@ -70,6 +71,10 @@ export interface GoToDefinitionRequest extends Request
7071
WantMetadata?: boolean;
7172
}
7273

74+
export interface FindImplementationsRequest extends Request
75+
{
76+
}
77+
7378
export interface LinePositionSpanTextChange {
7479
NewText: string;
7580
StartLine: number;

src/omnisharp/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ export function filesChanged(server: OmniSharpServer, requests: protocol.Request
2525
return server.makeRequest<void>(protocol.Requests.FilesChanged, requests);
2626
}
2727

28+
export function findImplementations(server: OmniSharpServer, request: protocol.FindImplementationsRequest, token: vscode.CancellationToken) {
29+
return server.makeRequest<protocol.QuickFixResponse>(protocol.Requests.FindImplementations, request);
30+
}
31+
2832
export function findSymbols(server: OmniSharpServer, request: protocol.FindSymbolsRequest, token: vscode.CancellationToken) {
2933
return server.makeRequest<protocol.FindSymbolsResponse>(protocol.Requests.FindSymbols, request, token);
3034
}

0 commit comments

Comments
 (0)