Skip to content

Commit 1efd3b4

Browse files
committed
move code from codelens provider to dotnetTest
1 parent 0302243 commit 1efd3b4

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

src/features/codeLensProvider.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import {CancellationToken, CodeLens, Range, Uri, TextDocument, CodeLensProvider} from 'vscode';
99
import {toRange, toLocation} from '../typeConvertion';
1010
import AbstractSupport from './abstractProvider';
11+
import {updateCodeLensForTest} from './dotnetTest';
1112
import * as protocol from '../protocol';
1213
import * as serverUtils from '../omnisharpUtils';
1314

@@ -52,14 +53,7 @@ export default class OmniSharpCodeLensProvider extends AbstractSupport implement
5253
OmniSharpCodeLensProvider._convertQuickFix(bucket, fileName, child);
5354
}
5455

55-
let testFeature = node.Features.find(value => value.startsWith('XunitTestMethod'));
56-
if (testFeature) {
57-
// this test method has a test feature
58-
let testMethod = testFeature.split(':')[1];
59-
60-
bucket.push(new CodeLens(toRange(node.Location), { title: "run test", command: 'dotnet.test.run', arguments: [testMethod, fileName] }));
61-
bucket.push(new CodeLens(toRange(node.Location), { title: "debug test", command: 'dotnet.test.debug', arguments: [testMethod, fileName] }));
62-
}
56+
updateCodeLensForTest(bucket, fileName, node);
6357
}
6458

6559
resolveCodeLens(codeLens: CodeLens, token: CancellationToken): Thenable<CodeLens> {

src/features/dotnetTest.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
'use strict';
77

88
import {OmnisharpServer} from '../omnisharpServer';
9+
import {toRange} from '../typeConvertion';
910
import * as vscode from 'vscode';
1011
import * as serverUtils from "../omnisharpUtils";
12+
import * as protocol from '../protocol';
1113

1214
export function registerDotNetTestRunCommand(server: OmnisharpServer): vscode.Disposable {
1315
return vscode.commands.registerCommand(
@@ -54,4 +56,20 @@ export function debugDotnetTest(testMethod: string, fileName: string, server: Om
5456
}
5557
).then(undefined, reason => { vscode.window.showErrorMessage('Failed to debug test because ' + reason + '.') });
5658
});
59+
}
60+
61+
export function updateCodeLensForTest(bucket: vscode.CodeLens[], fileName: string, node: protocol.Node) {
62+
let testFeature = node.Features.find(value => value.startsWith('XunitTestMethod'));
63+
if (testFeature) {
64+
// this test method has a test feature
65+
let testMethod = testFeature.split(':')[1];
66+
67+
bucket.push(new vscode.CodeLens(
68+
toRange(node.Location),
69+
{ title: "run test", command: 'dotnet.test.run', arguments: [testMethod, fileName] }));
70+
71+
bucket.push(new vscode.CodeLens(
72+
toRange(node.Location),
73+
{ title: "debug test", command: 'dotnet.test.debug', arguments: [testMethod, fileName] }));
74+
}
5775
}

0 commit comments

Comments
 (0)