Skip to content
This repository was archived by the owner on Feb 22, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
"typescript": "^3.1.6"
},
"dependencies": {
"@sourcegraph/basic-code-intel": "7.0.9",
"@sourcegraph/basic-code-intel": "7.0.10",
"@sourcegraph/lsp-client": "^2.0.0-beta.2",
"@sourcegraph/vscode-ws-jsonrpc": "0.0.3-fork",
"prettier": "^1.16.4",
Expand Down
20 changes: 16 additions & 4 deletions src/lang-go.ts
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,10 @@ export async function initLSP(ctx: sourcegraph.ExtensionContext): Promise<MaybeP
}
}

export function isLSPEnabled(): boolean {
return Boolean(sourcegraph.configuration.get<Settings>().get('go.serverUrl'))
}

function repoName(url: string): string {
let pathname = url
pathname = pathname.slice('git://'.length)
Expand Down Expand Up @@ -826,10 +830,18 @@ export function activate(ctx: sourcegraph.ExtensionContext = DUMMY_CTX): void {
)
ctx.subscriptions.add(
sourcegraph.languages.registerReferenceProvider(goFiles, {
provideReferences: asyncFirst(
[lsif.references, lsp.references, wrapMaybe(basicCodeIntel.references)],
null
),
provideReferences: async (doc, pos) => {
if (isLSPEnabled()) {
const references = await lsp.references(doc, pos)
return references ? references.value : null
}

// Concatenates LSIF results (if present) with fuzzy results
// because LSIF data might be sparse.
const lsifReferences = await lsif.references(doc, pos)
const fuzzyReferences = (await basicCodeIntel.references(doc, pos)) || []
return [...(lsifReferences === undefined ? [] : lsifReferences.value), ...fuzzyReferences]
},
})
)
}
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -700,10 +700,10 @@
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.7.0.tgz#9a06f4f137ee84d7df0460c1fdb1135ffa6c50fd"
integrity sha512-ONhaKPIufzzrlNbqtWFFd+jlnemX6lJAgq9ZeiZtS7I1PIf/la7CW4m83rTXRnVnsMbW2k56pGYu7AUFJD9Pow==

"@sourcegraph/basic-code-intel@7.0.9":
version "7.0.9"
resolved "https://registry.yarnpkg.com/@sourcegraph/basic-code-intel/-/basic-code-intel-7.0.9.tgz#b137eac5fce738eaa739422d2c3d67ccc6a890e0"
integrity sha512-z/grKdwm33Zxf+UXgnbnHtE5dhTk53UFyTAQhNPzvAzCYhLbLEcjN6YxH2M3f4tmXH/XIwXzhS0VlkliBXqkeg==
"@sourcegraph/basic-code-intel@7.0.10":
version "7.0.10"
resolved "https://registry.yarnpkg.com/@sourcegraph/basic-code-intel/-/basic-code-intel-7.0.10.tgz#26d1af33f48075199e4ec0ca1cb53d64bdcb162f"
integrity sha512-lZNd90AJFRJIQM2V8tzxzVlXPRQMrdIJ81T8vzGKXPwRjkT+Qr4mCqoRJKERL6J3OOcb9ElfQ3KwzSNvawwL2g==
dependencies:
lodash "^4.17.11"
rxjs "^6.3.3"
Expand Down