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

Commit b3c1124

Browse files
authored
Fallback from LSIF to others (#290)
1 parent e12870f commit b3c1124

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
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": "^7.0.9",
214+
"@sourcegraph/basic-code-intel": "^7.0.10",
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: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -513,9 +513,11 @@ export async function activate(ctx: sourcegraph.ExtensionContext): Promise<void>
513513
logger.log('Hover trace', span.generateTraceURL())
514514
}
515515

516-
if (await isLSIFAvailable(textDocument)) {
517-
const lsifResult = await lsif.hover(textDocument, position)
518-
yield lsifResult && lsifResult.value
516+
const lsifResult = (await isLSIFAvailable(textDocument))
517+
? await lsif.hover(textDocument, position)
518+
: undefined
519+
if (lsifResult) {
520+
yield lsifResult.value
519521
} else if (!config.value['typescript.serverUrl']) {
520522
yield await basicCodeIntel.hover(textDocument, position)
521523
} else {
@@ -560,9 +562,11 @@ export async function activate(ctx: sourcegraph.ExtensionContext): Promise<void>
560562
logger.log('Definition trace', span.generateTraceURL())
561563
}
562564

563-
if (await isLSIFAvailable(textDocument)) {
564-
const lsifResult = await lsif.definition(textDocument, position)
565-
yield lsifResult ? lsifResult.value : null
565+
const lsifResult = (await isLSIFAvailable(textDocument))
566+
? await lsif.definition(textDocument, position)
567+
: undefined
568+
if (lsifResult) {
569+
yield lsifResult.value
566570
} else if (!config.value['typescript.serverUrl']) {
567571
yield await basicCodeIntel.definition(textDocument, position)
568572
} else {
@@ -609,11 +613,10 @@ export async function activate(ctx: sourcegraph.ExtensionContext): Promise<void>
609613
logger.log('References trace', span.generateTraceURL())
610614
}
611615

612-
if (await isLSIFAvailable(textDocument)) {
613-
const lsifResult = await lsif.references(textDocument, position)
614-
yield (lsifResult && lsifResult.value) || []
615-
} else if (!config.value['typescript.serverUrl']) {
616-
yield (await basicCodeIntel.references(textDocument, position)) || []
616+
if (!config.value['typescript.serverUrl']) {
617+
const lsifReferences = await lsif.references(textDocument, position)
618+
const fuzzyReferences = (await basicCodeIntel.references(textDocument, position)) || []
619+
yield [...(lsifReferences === undefined ? [] : lsifReferences.value), ...fuzzyReferences]
617620
} else {
618621
const textDocumentUri = new URL(textDocument.uri)
619622
const serverRootUri = resolveServerRootUri(textDocumentUri, serverSgEndpoint)

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@^7.0.9":
805-
version "7.0.9"
806-
resolved "https://registry.npmjs.org/@sourcegraph/basic-code-intel/-/basic-code-intel-7.0.9.tgz#b137eac5fce738eaa739422d2c3d67ccc6a890e0"
807-
integrity sha512-z/grKdwm33Zxf+UXgnbnHtE5dhTk53UFyTAQhNPzvAzCYhLbLEcjN6YxH2M3f4tmXH/XIwXzhS0VlkliBXqkeg==
804+
"@sourcegraph/basic-code-intel@^7.0.10":
805+
version "7.0.10"
806+
resolved "https://registry.npmjs.org/@sourcegraph/basic-code-intel/-/basic-code-intel-7.0.10.tgz#26d1af33f48075199e4ec0ca1cb53d64bdcb162f"
807+
integrity sha512-lZNd90AJFRJIQM2V8tzxzVlXPRQMrdIJ81T8vzGKXPwRjkT+Qr4mCqoRJKERL6J3OOcb9ElfQ3KwzSNvawwL2g==
808808
dependencies:
809809
lodash "^4.17.11"
810810
rxjs "^6.3.3"

0 commit comments

Comments
 (0)