Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 21fec02

Browse files
committed
wip
1 parent 77bbca5 commit 21fec02

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

client/browser/config/esbuild.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export function esbuildBuildOptions(mode: 'dev' | 'prod', extraPlugins: esbuild.
3838
plugins: [stylePlugin, ...extraPlugins],
3939
define: {
4040
'process.env.NODE_ENV': JSON.stringify(mode === 'dev' ? 'development' : 'production'),
41+
'process.env.NODE_DEBUG': 'false',
4142
'process.env.BUNDLE_UID': JSON.stringify(generateBundleUID()),
4243
},
4344
bundle: true,

client/browser/src/shared/code-hosts/shared/codeHost.tsx

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ import {
6060
import type { WorkspaceRoot } from '@sourcegraph/extension-api-types'
6161
import { gql, isHTTPAuthError } from '@sourcegraph/http-client'
6262
import type { ActionItemAction } from '@sourcegraph/shared/src/actions/ActionItem'
63-
import { wrapRemoteObservable } from '@sourcegraph/shared/src/api/client/api/common'
6463
import type { CodeEditorData, CodeEditorWithPartialModel } from '@sourcegraph/shared/src/api/viewerTypes'
6564
import { isRepoNotFoundErrorLike } from '@sourcegraph/shared/src/backend/errors'
65+
import { createCodeIntelAPI } from '@sourcegraph/shared/src/codeintel/api'
66+
import type { CodeIntelContext } from '@sourcegraph/shared/src/codeintel/legacy-extensions/api'
6667
import type { Controller } from '@sourcegraph/shared/src/extensions/controller'
6768
import { getHoverActions, registerHoverContributions } from '@sourcegraph/shared/src/hover/actions'
6869
import {
@@ -354,6 +355,13 @@ function initCodeIntelligence({
354355
})
355356
)
356357

358+
const codeintelContext: CodeIntelContext = { ...platformContext, telemetryRecorder, settings: () => undefined }
359+
const codeintelAPI = createCodeIntelAPI(codeintelContext)
360+
361+
function thenMaybeLoadingResult<T>(result: T): MaybeLoadingResult<T> {
362+
return { isLoading: false, result }
363+
}
364+
357365
// Code views come and go, but there is always a single hoverifier on the page
358366
const hoverifier = createHoverifier<
359367
RepoSpec & RevisionSpec & FileSpec & ResolvedRevisionSpec,
@@ -369,17 +377,22 @@ function initCodeIntelligence({
369377
getHover: ({ line, character, part, ...rest }) =>
370378
concat(
371379
[{ isLoading: true, result: null }],
372-
from(extensionsController.extHostAPI)
380+
of(true /* TODO!(sqs) */)
373381
.pipe(
374382
withLatestFrom(repoSyncErrors),
375-
switchMap(([extensionHost, hasRepoSyncError]) =>
383+
switchMap(([, hasRepoSyncError]) =>
376384
// Prevent GraphQL requests that we know will result in error/null when the repo is private (and not added to Cloud)
377385
hasRepoSyncError
378386
? of({ isLoading: true, result: null })
379-
: wrapRemoteObservable(
380-
extensionHost.getHover(
381-
toTextDocumentPositionParameters({ ...rest, position: { line, character } })
382-
)
387+
: from(
388+
codeintelAPI
389+
.getHover(
390+
toTextDocumentPositionParameters({
391+
...rest,
392+
position: { line, character },
393+
})
394+
)
395+
.then(thenMaybeLoadingResult)
383396
)
384397
)
385398
)
@@ -393,19 +406,20 @@ function initCodeIntelligence({
393406
)
394407
),
395408
getDocumentHighlights: ({ line, character, part, ...rest }) =>
396-
from(extensionsController.extHostAPI).pipe(
409+
of(true /* TODO!(sqs) */).pipe(
397410
withLatestFrom(repoSyncErrors),
398-
switchMap(([extensionHost, hasRepoSyncError]) =>
411+
switchMap(([, hasRepoSyncError]) =>
399412
// Prevent GraphQL requests that we know will result in error/null when the repo is private (and not added to Cloud)
400413
hasRepoSyncError
401414
? of([])
402-
: wrapRemoteObservable(
403-
extensionHost.getDocumentHighlights(
415+
: from(
416+
codeintelAPI.getDocumentHighlights(
404417
toTextDocumentPositionParameters({ ...rest, position: { line, character } })
405418
)
406419
)
407420
)
408421
),
422+
// TODO!(sqs): just gotta make it so the actions are determined programmatically AND we only trigger it on supported languages
409423
getActions: context =>
410424
// Prevent GraphQL requests that we know will result in error/null when the repo is private (and not added to Cloud)
411425
repoSyncErrors.pipe(

0 commit comments

Comments
 (0)