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

Low-hanging nullable fruit #5186

Merged
merged 19 commits into from
Apr 25, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Remove Range support from createRequest
No consumer uses Range.
  • Loading branch information
50Wliu committed Apr 24, 2022
commit eb8e2a8fbf9cf9d534bb16f037564a4d7fe3e6b3
21 changes: 5 additions & 16 deletions src/omnisharp/typeConversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,29 +62,18 @@ export function toVSCodePosition(point: protocol.V2.Point): vscode.Position {
return new vscode.Position(point.Line, point.Column);
}

export function createRequest<T extends protocol.Request>(document: vscode.TextDocument, where: vscode.Position | vscode.Range, includeBuffer: boolean = false): T {

let Line: number, Column: number;

if (where instanceof vscode.Position) {
Line = where.line;
Column = where.character;
} else if (where instanceof vscode.Range) {
Line = where.start.line;
Column = where.start.character;
}

export function createRequest<T extends protocol.Request>(document: vscode.TextDocument, where: vscode.Position, includeBuffer: boolean = false): T {
// for metadata sources, we need to remove the [metadata] from the filename, and prepend the $metadata$ authority
// this is expected by the Omnisharp server to support metadata-to-metadata navigation
let fileName = document.uri.scheme === "omnisharp-metadata" ?
const fileName = document.uri.scheme === "omnisharp-metadata" ?
`${document.uri.authority}${document.fileName.replace("[metadata] ", "")}` :
document.fileName;

let request: protocol.Request = {
const request: protocol.Request = {
FileName: fileName,
Buffer: includeBuffer ? document.getText() : undefined,
Line,
Column
Line: where.line,
Column: where.character,
};

return <T>request;
Expand Down