diff --git a/package.json b/package.json index 1420e3a08..63d61535a 100644 --- a/package.json +++ b/package.json @@ -211,7 +211,7 @@ "yarn-deduplicate": "^1.1.1" }, "dependencies": { - "@sourcegraph/basic-code-intel": "^9.0.0", + "@sourcegraph/basic-code-intel": "^10.0.0", "@sourcegraph/lightstep-tracer-webworker": "^0.20.14-fork.3", "@sourcegraph/typescript-language-server": "^0.3.7-fork", "@sourcegraph/vscode-ws-jsonrpc": "0.0.3-fork", diff --git a/src/extension/extension.ts b/src/extension/extension.ts index 1fc39266d..7d4aee422 100644 --- a/src/extension/extension.ts +++ b/src/extension/extension.ts @@ -6,7 +6,7 @@ import { URL as _URL, URLSearchParams as _URLSearchParams } from 'whatwg-url' Object.assign(_URL, self.URL) Object.assign(self, { URL: _URL, URLSearchParams: _URLSearchParams }) -import { initLSIF, mkIsLSIFAvailable } from '@sourcegraph/basic-code-intel' +import { initLSIF, mkIsLSIFAvailable, impreciseBadge } from '@sourcegraph/basic-code-intel' import { Tracer as LightstepTracer } from '@sourcegraph/lightstep-tracer-webworker' import { createMessageConnection, @@ -519,7 +519,12 @@ export async function activate(ctx: sourcegraph.ExtensionContext): Promise if (lsifResult) { yield lsifResult.value } else if (!config.value['typescript.serverUrl']) { - yield await basicCodeIntel.hover(textDocument, position) + const result = await basicCodeIntel.hover(textDocument, position) + if (result) { + yield { ...result, badge: impreciseBadge } + } else { + yield undefined + } } else { const textDocumentUri = new URL(textDocument.uri) const serverRootUri = resolveServerRootUri(textDocumentUri, serverSgEndpoint) @@ -568,7 +573,16 @@ export async function activate(ctx: sourcegraph.ExtensionContext): Promise if (lsifResult) { yield lsifResult.value } else if (!config.value['typescript.serverUrl']) { - yield await basicCodeIntel.definition(textDocument, position) + const result = await basicCodeIntel.definition(textDocument, position) + if (result) { + if (Array.isArray(result)) { + yield result.map(v => ({ ...v, badge: impreciseBadge })) + } else { + yield { ...result, badge: impreciseBadge } + } + } else { + yield undefined + } } else { const textDocumentUri = new URL(textDocument.uri) const serverRootUri = resolveServerRootUri(textDocumentUri, serverSgEndpoint) @@ -625,7 +639,9 @@ export async function activate(ctx: sourcegraph.ExtensionContext): Promise yield [ ...(lsifReferences === undefined ? [] : lsifReferences.value), - ...fuzzyReferences.filter(fuzzyRef => !lsifFiles.has(file(fuzzyRef))), + ...fuzzyReferences + .filter(fuzzyRef => !lsifFiles.has(file(fuzzyRef))) + .map(v => ({ ...v, badge: impreciseBadge })), ] } else { const textDocumentUri = new URL(textDocument.uri) diff --git a/yarn.lock b/yarn.lock index fa01d3b51..459ed8f44 100644 --- a/yarn.lock +++ b/yarn.lock @@ -801,10 +801,10 @@ resolved "https://registry.npmjs.org/@sindresorhus/is/-/is-0.7.0.tgz#9a06f4f137ee84d7df0460c1fdb1135ffa6c50fd" integrity sha512-ONhaKPIufzzrlNbqtWFFd+jlnemX6lJAgq9ZeiZtS7I1PIf/la7CW4m83rTXRnVnsMbW2k56pGYu7AUFJD9Pow== -"@sourcegraph/basic-code-intel@^9.0.0": - version "9.0.0" - resolved "https://registry.npmjs.org/@sourcegraph/basic-code-intel/-/basic-code-intel-9.0.0.tgz#fb750d8b02a4dcb6eb1dab123ea547c3c8897203" - integrity sha512-HChZ2dOlG2teKWwnTG72zZcK7eXpndCzp/z0nM+UmDgtUG7xAoO68xt1NMmko2mkD/aTqlya4ni9D9jMEN5oAA== +"@sourcegraph/basic-code-intel@^10.0.0": + version "10.0.0" + resolved "https://registry.npmjs.org/@sourcegraph/basic-code-intel/-/basic-code-intel-10.0.0.tgz#b505f9c8dd2cd63b0bd98b3fd8ad4c7813464c65" + integrity sha512-ZYFv3zMEOQK3LlSr5McevXWMbBZsuOLT3JWrr1T4bCZ4prQ3A5yvyIinsDWAK5y31obTrb+v0KZJ0i8ly7HbAg== dependencies: lodash "^4.17.11" rxjs "^6.3.3"