1
1
import '@babel/polyfill'
2
2
3
- import { Handler , initLSIF , asyncFirst , wrapMaybe , Maybe } from '@sourcegraph/basic-code-intel'
3
+ import { Handler , initLSIF , asyncFirst , wrapMaybe , Maybe , impreciseBadge } from '@sourcegraph/basic-code-intel'
4
4
import { convertHover } from '@sourcegraph/lsp-client/dist/lsp-conversion'
5
5
import * as wsrpc from '@sourcegraph/vscode-ws-jsonrpc'
6
6
import { ajax } from 'rxjs/ajax'
@@ -817,15 +817,50 @@ export function activate(ctx: sourcegraph.ExtensionContext = DUMMY_CTX): void {
817
817
818
818
ctx . subscriptions . add (
819
819
sourcegraph . languages . registerHoverProvider ( goFiles , {
820
- provideHover : asyncFirst ( [ lsif . hover , lsp . hover , wrapMaybe ( basicCodeIntel . hover ) ] , null ) ,
820
+ provideHover : async ( doc , pos ) => {
821
+ const lsifResult = await lsif . hover ( doc , pos )
822
+ if ( lsifResult ) {
823
+ return lsifResult . value
824
+ }
825
+
826
+ const lspResult = await lsp . hover ( doc , pos )
827
+ if ( lspResult ) {
828
+ return lspResult . value
829
+ }
830
+
831
+ const val = await basicCodeIntel . hover ( doc , pos )
832
+ if ( ! val ) {
833
+ return undefined
834
+ }
835
+
836
+ return { ...val , badge : impreciseBadge }
837
+ } ,
821
838
} )
822
839
)
823
840
ctx . subscriptions . add (
824
841
sourcegraph . languages . registerDefinitionProvider ( goFiles , {
825
- provideDefinition : asyncFirst (
826
- [ lsif . definition , lsp . definition , wrapMaybe ( basicCodeIntel . definition ) ] ,
827
- null
828
- ) ,
842
+ provideDefinition : async ( doc , pos ) => {
843
+ const lsifResult = await lsif . definition ( doc , pos )
844
+ if ( lsifResult ) {
845
+ return lsifResult . value
846
+ }
847
+
848
+ const lspResult = await lsp . definition ( doc , pos )
849
+ if ( lspResult ) {
850
+ return lspResult . value
851
+ }
852
+
853
+ const val = await basicCodeIntel . definition ( doc , pos )
854
+ if ( ! val ) {
855
+ return undefined
856
+ }
857
+
858
+ if ( Array . isArray ( val ) ) {
859
+ return val . map ( v => ( { ...v , badge : impreciseBadge } ) )
860
+ }
861
+
862
+ return { ...val , badge : impreciseBadge }
863
+ } ,
829
864
} )
830
865
)
831
866
ctx . subscriptions . add (
@@ -850,7 +885,12 @@ export function activate(ctx: sourcegraph.ExtensionContext = DUMMY_CTX): void {
850
885
return [
851
886
...( lsifReferences === undefined ? [ ] : lsifReferences . value ) ,
852
887
// Drop fuzzy references from files that have LSIF results.
853
- ...fuzzyReferences . filter ( fuzzyRef => ! lsifFiles . has ( file ( fuzzyRef ) ) ) ,
888
+ ...fuzzyReferences
889
+ . filter ( fuzzyRef => ! lsifFiles . has ( file ( fuzzyRef ) ) )
890
+ . map ( v => ( {
891
+ ...v ,
892
+ badge : impreciseBadge ,
893
+ } ) ) ,
854
894
]
855
895
} ,
856
896
} )
0 commit comments