Skip to content
This repository was archived by the owner on Jun 7, 2022. It is now read-only.

Commit 153d9b8

Browse files
authored
Add badges. (#306)
1 parent 55c8f6b commit 153d9b8

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@
211211
"yarn-deduplicate": "^1.1.1"
212212
},
213213
"dependencies": {
214-
"@sourcegraph/basic-code-intel": "^9.0.0",
214+
"@sourcegraph/basic-code-intel": "^10.0.0",
215215
"@sourcegraph/lightstep-tracer-webworker": "^0.20.14-fork.3",
216216
"@sourcegraph/typescript-language-server": "^0.3.7-fork",
217217
"@sourcegraph/vscode-ws-jsonrpc": "0.0.3-fork",

src/extension/extension.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { URL as _URL, URLSearchParams as _URLSearchParams } from 'whatwg-url'
66
Object.assign(_URL, self.URL)
77
Object.assign(self, { URL: _URL, URLSearchParams: _URLSearchParams })
88

9-
import { initLSIF, mkIsLSIFAvailable } from '@sourcegraph/basic-code-intel'
9+
import { initLSIF, mkIsLSIFAvailable, impreciseBadge } from '@sourcegraph/basic-code-intel'
1010
import { Tracer as LightstepTracer } from '@sourcegraph/lightstep-tracer-webworker'
1111
import {
1212
createMessageConnection,
@@ -519,7 +519,12 @@ export async function activate(ctx: sourcegraph.ExtensionContext): Promise<void>
519519
if (lsifResult) {
520520
yield lsifResult.value
521521
} else if (!config.value['typescript.serverUrl']) {
522-
yield await basicCodeIntel.hover(textDocument, position)
522+
const result = await basicCodeIntel.hover(textDocument, position)
523+
if (result) {
524+
yield { ...result, badge: impreciseBadge }
525+
} else {
526+
yield undefined
527+
}
523528
} else {
524529
const textDocumentUri = new URL(textDocument.uri)
525530
const serverRootUri = resolveServerRootUri(textDocumentUri, serverSgEndpoint)
@@ -568,7 +573,16 @@ export async function activate(ctx: sourcegraph.ExtensionContext): Promise<void>
568573
if (lsifResult) {
569574
yield lsifResult.value
570575
} else if (!config.value['typescript.serverUrl']) {
571-
yield await basicCodeIntel.definition(textDocument, position)
576+
const result = await basicCodeIntel.definition(textDocument, position)
577+
if (result) {
578+
if (Array.isArray(result)) {
579+
yield result.map(v => ({ ...v, badge: impreciseBadge }))
580+
} else {
581+
yield { ...result, badge: impreciseBadge }
582+
}
583+
} else {
584+
yield undefined
585+
}
572586
} else {
573587
const textDocumentUri = new URL(textDocument.uri)
574588
const serverRootUri = resolveServerRootUri(textDocumentUri, serverSgEndpoint)
@@ -625,7 +639,9 @@ export async function activate(ctx: sourcegraph.ExtensionContext): Promise<void>
625639

626640
yield [
627641
...(lsifReferences === undefined ? [] : lsifReferences.value),
628-
...fuzzyReferences.filter(fuzzyRef => !lsifFiles.has(file(fuzzyRef))),
642+
...fuzzyReferences
643+
.filter(fuzzyRef => !lsifFiles.has(file(fuzzyRef)))
644+
.map(v => ({ ...v, badge: impreciseBadge })),
629645
]
630646
} else {
631647
const textDocumentUri = new URL(textDocument.uri)

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -801,10 +801,10 @@
801801
resolved "https://registry.npmjs.org/@sindresorhus/is/-/is-0.7.0.tgz#9a06f4f137ee84d7df0460c1fdb1135ffa6c50fd"
802802
integrity sha512-ONhaKPIufzzrlNbqtWFFd+jlnemX6lJAgq9ZeiZtS7I1PIf/la7CW4m83rTXRnVnsMbW2k56pGYu7AUFJD9Pow==
803803

804-
"@sourcegraph/basic-code-intel@^9.0.0":
805-
version "9.0.0"
806-
resolved "https://registry.npmjs.org/@sourcegraph/basic-code-intel/-/basic-code-intel-9.0.0.tgz#fb750d8b02a4dcb6eb1dab123ea547c3c8897203"
807-
integrity sha512-HChZ2dOlG2teKWwnTG72zZcK7eXpndCzp/z0nM+UmDgtUG7xAoO68xt1NMmko2mkD/aTqlya4ni9D9jMEN5oAA==
804+
"@sourcegraph/basic-code-intel@^10.0.0":
805+
version "10.0.0"
806+
resolved "https://registry.npmjs.org/@sourcegraph/basic-code-intel/-/basic-code-intel-10.0.0.tgz#b505f9c8dd2cd63b0bd98b3fd8ad4c7813464c65"
807+
integrity sha512-ZYFv3zMEOQK3LlSr5McevXWMbBZsuOLT3JWrr1T4bCZ4prQ3A5yvyIinsDWAK5y31obTrb+v0KZJ0i8ly7HbAg==
808808
dependencies:
809809
lodash "^4.17.11"
810810
rxjs "^6.3.3"

0 commit comments

Comments
 (0)