@@ -3,22 +3,7 @@ import { BehaviorSubject, Subject, Subscription } from 'rxjs'
3
3
import { mapTo } from 'rxjs/operators'
4
4
import * as sinon from 'sinon'
5
5
import * as sourcegraph from 'sourcegraph'
6
- import { deprecate } from 'util'
7
- import { assertTypeIsCompatible , notImplemented } from './util'
8
-
9
- interface DeprecatedTypeDefinitionProvider {
10
- provideTypeDefinition (
11
- document : sourcegraph . TextDocument ,
12
- position : Position
13
- ) : sourcegraph . ProviderResult < sourcegraph . Definition >
14
- }
15
-
16
- interface DeprecatedImplementationProvider {
17
- provideImplementation (
18
- document : sourcegraph . TextDocument ,
19
- position : Position
20
- ) : sourcegraph . ProviderResult < sourcegraph . Definition >
21
- }
6
+ import { notImplemented , subTypeOf } from './util'
22
7
23
8
let decorationTypeCounter = 0
24
9
@@ -30,7 +15,7 @@ export const createStubSourcegraphAPI = () => {
30
15
const configSubject = new BehaviorSubject < any > ( { } )
31
16
const rootChanges = new Subject < void > ( )
32
17
const openedTextDocuments = new Subject < sourcegraph . TextDocument > ( )
33
- const stubs /* : typeof import('sourcegraph') */ = {
18
+ const stubs = subTypeOf < typeof import ( 'sourcegraph' ) > ( ) ( {
34
19
// Classes
35
20
URI : URL ,
36
21
Position,
@@ -75,20 +60,6 @@ export const createStubSourcegraphAPI = () => {
75
60
( selector : sourcegraph . DocumentSelector , provider : sourcegraph . CompletionItemProvider ) =>
76
61
new Subscription ( )
77
62
) ,
78
- registerTypeDefinitionProvider : sinon . spy (
79
- deprecate (
80
- ( selector : sourcegraph . DocumentSelector , provider : DeprecatedTypeDefinitionProvider ) =>
81
- new Subscription ( ) ,
82
- 'sourcegraph.languages.registerTypeDefinitionProvider() is deprecated. Use sourcegraph.languages.registerLocationProvider() instead.'
83
- )
84
- ) ,
85
- registerImplementationProvider : sinon . spy (
86
- deprecate (
87
- ( selector : sourcegraph . DocumentSelector , provider : DeprecatedImplementationProvider ) =>
88
- new Subscription ( ) ,
89
- 'sourcegraph.languages.registerImplementationProvider() is deprecated. Use sourcegraph.languages.registerLocationProvider() instead.'
90
- )
91
- ) ,
92
63
} ,
93
64
app : {
94
65
windows : [ ] as sourcegraph . Window [ ] ,
@@ -98,7 +69,7 @@ export const createStubSourcegraphAPI = () => {
98
69
activeWindowChanges : new BehaviorSubject < sourcegraph . Window | undefined > ( undefined ) ,
99
70
100
71
createDecorationType : ( ) => ( { key : 'decorationType' + decorationTypeCounter ++ } ) ,
101
- createPanelView : notImplemented as ( ( id : string ) => sourcegraph . PanelView ) ,
72
+ createPanelView : notImplemented as ( id : string ) => sourcegraph . PanelView ,
102
73
} ,
103
74
configuration : Object . assign ( configSubject . pipe ( mapTo ( undefined ) ) , {
104
75
get : < C extends object = { [ key : string ] : any } > ( ) : sourcegraph . Configuration < C > => ( {
@@ -123,7 +94,6 @@ export const createStubSourcegraphAPI = () => {
123
94
registerCommand : sinon . spy ( ( command : string , callback : ( ...args : any [ ] ) => any ) => new Subscription ( ) ) ,
124
95
executeCommand : sinon . spy < ( command : string , ...args : any [ ] ) => Promise < any > > ( notImplemented ) ,
125
96
} ,
126
- }
127
- assertTypeIsCompatible < typeof sourcegraph > ( stubs )
97
+ } )
128
98
return stubs
129
99
}
0 commit comments