Skip to content

Commit

Permalink
Implemented "Go to Implementation". Closes dotnet#37
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanz committed Feb 11, 2017
1 parent 29806fb commit ac3dbdf
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 6 deletions.
14 changes: 10 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.8.0 _(Not Yet Released)_

#### Go to Implementation

* 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))_

## 1.7.0 (February 8, 2017)

#### Syntax Hightlighting
Expand Down Expand Up @@ -83,15 +89,15 @@
* Brings support for running all supported distros on top of Linux Kernel >= 4.6
* Enable debugger support for Arch Linux ([#564](https://github.com/OmniSharp/omnisharp-vscode/issues/564))
* 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)).
* 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)).
* 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)).

#### Syntax Highlighting

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

#### Hover Tooltips
Expand All @@ -117,7 +123,7 @@
* Ensure diagnostics are cleared in files when they are no longer needed. ([#858](https://github.com/OmniSharp/omnisharp-vscode/issues/858))
* Enqueue requests for diagnostics in visible editors when the extension starts up. ([#843](https://github.com/OmniSharp/omnisharp-vscode/issues/843))
* Provide fallback URLs for debugger downloads. ([#930](https://github.com/OmniSharp/omnisharp-vscode/issues/930))
* 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))
* 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))
* Fix issue with installing on non-English installations of Windows. ([#938](https://github.com/OmniSharp/omnisharp-vscode/issues/938))
* Display platform information when acquiring runtime dependencies. ([#948](https://github.com/OmniSharp/omnisharp-vscode/issues/948))

Expand Down Expand Up @@ -165,7 +171,7 @@ Several new settings have been added:

#### Performance

* 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!)_
* 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!)_

#### Other Improvements

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"tslint-microsoft-contrib": "^2.0.12",
"typescript": "^2.0.3",
"vsce": "^1.7.0",
"vscode": "^1.0.0"
"vscode": "^1.0.3"
},
"runtimeDependencies": [
{
Expand Down Expand Up @@ -300,7 +300,7 @@
}
],
"engines": {
"vscode": "^1.5.0"
"vscode": "^1.9.0"
},
"activationEvents": [
"onLanguage:csharp",
Expand Down
26 changes: 26 additions & 0 deletions src/features/implementationProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*---------------------------------------------------------------------------------------------
* 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 { FindImplementationsRequest } from '../omnisharp/protocol';
import * as serverUtils from '../omnisharp/utils';
import { createRequest, toLocation } from '../omnisharp/typeConvertion';
import { TextDocument, Position, CancellationToken, ImplementationProvider, ProviderResult, Definition } from 'vscode';

export default class CSharpImplementationProvider extends AbstractSupport implements ImplementationProvider {
public provideImplementation(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<Definition> {
const request = <FindImplementationsRequest>createRequest(document, position);

return serverUtils.findImplementations(this._server, request, token).then(response => {
if (!response || !response.QuickFixes) {
return;
}

return response.QuickFixes.map(fix => toLocation(fix));
});
}
}
2 changes: 2 additions & 0 deletions src/omnisharp/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as vscode from 'vscode';
import TelemetryReporter from 'vscode-extension-telemetry';

import DefinitionProvider from '../features/definitionProvider';
import ImplementationProvider from '../features/implementationProvider';
import CodeLensProvider from '../features/codeLensProvider';
import DefinitionMetadataDocumentProvider from '../features/definitionMetadataDocumentProvider';
import DocumentHighlightProvider from '../features/documentHighlightProvider';
Expand Down Expand Up @@ -47,6 +48,7 @@ export function activate(context: vscode.ExtensionContext, reporter: TelemetryRe
localDisposables.push(definitionMetadataDocumentProvider);

localDisposables.push(vscode.languages.registerDefinitionProvider(documentSelector, new DefinitionProvider(server, definitionMetadataDocumentProvider)));
localDisposables.push(vscode.languages.registerImplementationProvider(documentSelector, new ImplementationProvider(server)));
localDisposables.push(vscode.languages.registerCodeLensProvider(documentSelector, new CodeLensProvider(server)));
localDisposables.push(vscode.languages.registerDocumentHighlightProvider(documentSelector, new DocumentHighlightProvider(server)));
localDisposables.push(vscode.languages.registerDocumentSymbolProvider(documentSelector, new DocumentSymbolProvider(server)));
Expand Down
5 changes: 5 additions & 0 deletions src/omnisharp/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export module Requests {
export const FormatRange = '/formatRange';
export const GetCodeActions = '/getcodeactions';
export const GoToDefinition = '/gotoDefinition';
export const FindImplementations = '/findimplementations';
export const Projects = '/projects';
export const RemoveFromProject = '/removefromproject';
export const Rename = '/rename';
Expand Down Expand Up @@ -70,6 +71,10 @@ export interface GoToDefinitionRequest extends Request
WantMetadata?: boolean;
}

export interface FindImplementationsRequest extends Request
{
}

export interface LinePositionSpanTextChange {
NewText: string;
StartLine: number;
Expand Down
4 changes: 4 additions & 0 deletions src/omnisharp/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export function filesChanged(server: OmniSharpServer, requests: protocol.Request
return server.makeRequest<void>(protocol.Requests.FilesChanged, requests);
}

export function findImplementations(server: OmniSharpServer, request: protocol.FindImplementationsRequest, token: vscode.CancellationToken) {
return server.makeRequest<protocol.QuickFixResponse>(protocol.Requests.FindImplementations, request);
}

export function findSymbols(server: OmniSharpServer, request: protocol.FindSymbolsRequest, token: vscode.CancellationToken) {
return server.makeRequest<protocol.FindSymbolsResponse>(protocol.Requests.FindSymbols, request, token);
}
Expand Down

0 comments on commit ac3dbdf

Please sign in to comment.