Skip to content
This repository was archived by the owner on Feb 22, 2020. It is now read-only.

Commit 19d6a2a

Browse files
authored
Add badges. (#116)
1 parent 259ad81 commit 19d6a2a

File tree

3 files changed

+52
-12
lines changed

3 files changed

+52
-12
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
"typescript": "^3.1.6"
158158
},
159159
"dependencies": {
160-
"@sourcegraph/basic-code-intel": "9.0.0",
160+
"@sourcegraph/basic-code-intel": "10.0.0",
161161
"@sourcegraph/lsp-client": "^2.0.0-beta.2",
162162
"@sourcegraph/vscode-ws-jsonrpc": "0.0.3-fork",
163163
"prettier": "^1.16.4",

src/lang-go.ts

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import '@babel/polyfill'
22

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'
44
import { convertHover } from '@sourcegraph/lsp-client/dist/lsp-conversion'
55
import * as wsrpc from '@sourcegraph/vscode-ws-jsonrpc'
66
import { ajax } from 'rxjs/ajax'
@@ -817,15 +817,50 @@ export function activate(ctx: sourcegraph.ExtensionContext = DUMMY_CTX): void {
817817

818818
ctx.subscriptions.add(
819819
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+
},
821838
})
822839
)
823840
ctx.subscriptions.add(
824841
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+
},
829864
})
830865
)
831866
ctx.subscriptions.add(
@@ -850,7 +885,12 @@ export function activate(ctx: sourcegraph.ExtensionContext = DUMMY_CTX): void {
850885
return [
851886
...(lsifReferences === undefined ? [] : lsifReferences.value),
852887
// 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+
})),
854894
]
855895
},
856896
})

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -700,10 +700,10 @@
700700
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.7.0.tgz#9a06f4f137ee84d7df0460c1fdb1135ffa6c50fd"
701701
integrity sha512-ONhaKPIufzzrlNbqtWFFd+jlnemX6lJAgq9ZeiZtS7I1PIf/la7CW4m83rTXRnVnsMbW2k56pGYu7AUFJD9Pow==
702702

703-
"@sourcegraph/basic-code-intel@9.0.0":
704-
version "9.0.0"
705-
resolved "https://registry.yarnpkg.com/@sourcegraph/basic-code-intel/-/basic-code-intel-9.0.0.tgz#fb750d8b02a4dcb6eb1dab123ea547c3c8897203"
706-
integrity sha512-HChZ2dOlG2teKWwnTG72zZcK7eXpndCzp/z0nM+UmDgtUG7xAoO68xt1NMmko2mkD/aTqlya4ni9D9jMEN5oAA==
703+
"@sourcegraph/basic-code-intel@10.0.0":
704+
version "10.0.0"
705+
resolved "https://registry.yarnpkg.com/@sourcegraph/basic-code-intel/-/basic-code-intel-10.0.0.tgz#b505f9c8dd2cd63b0bd98b3fd8ad4c7813464c65"
706+
integrity sha512-ZYFv3zMEOQK3LlSr5McevXWMbBZsuOLT3JWrr1T4bCZ4prQ3A5yvyIinsDWAK5y31obTrb+v0KZJ0i8ly7HbAg==
707707
dependencies:
708708
lodash "^4.17.11"
709709
rxjs "^6.3.3"

0 commit comments

Comments
 (0)