From dd36b7f7e945b4325ec9651d24df39786262961e Mon Sep 17 00:00:00 2001 From: TJ Kandala Date: Thu, 6 May 2021 13:46:06 -0400 Subject: [PATCH] feat: support extension API v25.2.0 (#137) --- package.json | 2 +- src/api.test.ts | 6 ++++++ src/api.ts | 6 ++++++ src/codeEditor.test.ts | 3 +++ src/codeEditor.ts | 4 ++++ src/util.test.ts | 2 +- yarn.lock | 16 ++++------------ 7 files changed, 25 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 8554f513..f1d066e0 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,6 @@ "@types/sinon": "9.0.4", "rxjs": "^6.5.1", "sinon": "^9.0.2", - "sourcegraph": "^25.0.0" + "sourcegraph": "^25.2.0" } } diff --git a/src/api.test.ts b/src/api.test.ts index 5ccd0003..a23f56bc 100644 --- a/src/api.test.ts +++ b/src/api.test.ts @@ -15,6 +15,12 @@ describe('createStubSourcegraphAPI()', () => { assert.deepStrictEqual(stub.app.createDecorationType(), { key: 'decorationType1' }) assert.deepStrictEqual(stub.app.createDecorationType(), { key: 'decorationType2' }) }) + it('should support creating unique statusBarItemTypes', () => { + const stub = createStubSourcegraphAPI() + assert.deepStrictEqual(stub.app.createStatusBarItemType(), { key: 'statusBarItemType0' }) + assert.deepStrictEqual(stub.app.createStatusBarItemType(), { key: 'statusBarItemType1' }) + assert.deepStrictEqual(stub.app.createStatusBarItemType(), { key: 'statusBarItemType2' }) + }) it('should support managing the active Window', () => { const stub = createStubSourcegraphAPI() const newWindow = {} as sourcegraph.Window diff --git a/src/api.ts b/src/api.ts index 2cd0a8c5..2ccb1a28 100644 --- a/src/api.ts +++ b/src/api.ts @@ -14,6 +14,7 @@ import * as sourcegraph from 'sourcegraph' import { notImplemented, subtypeOf } from './util' let decorationTypeCounter = 0 +let statusBarItemTypeCounter = 0 /** * Creates an object that (mostly) implements the Sourcegraph API, @@ -54,6 +55,10 @@ export const createStubSourcegraphAPI = () => { get versionContext() { return this.versionContextChanges.value }, + searchContextChanges: new BehaviorSubject(undefined), + get searchContext() { + return this.searchContextChanges.value + }, }, languages: { registerHoverProvider: sinon.spy( @@ -92,6 +97,7 @@ export const createStubSourcegraphAPI = () => { registerFileDecorationProvider: sinon.spy( (provider: sourcegraph.FileDecorationProvider) => new Subscription() ), + createStatusBarItemType: () => ({ key: `statusBarItemType${statusBarItemTypeCounter++}` }), }, configuration: Object.assign(configSubject.pipe(mapTo(undefined)), { get: (): sourcegraph.Configuration => ({ diff --git a/src/codeEditor.test.ts b/src/codeEditor.test.ts index 87f8a809..b061164a 100644 --- a/src/codeEditor.test.ts +++ b/src/codeEditor.test.ts @@ -20,5 +20,8 @@ describe('createStubCodeEditor()', () => { stub.setDecorations({ key: 'foo' }, [{ range: new Range(0, 1, 2, 3), border: 'red' }]) sinon.assert.calledOnce(stub.setDecorations) + + stub.setStatusBarItem({ key: 'foo' }, { text: 'status bar item' }) + sinon.assert.calledOnce(stub.setStatusBarItem) }) }) diff --git a/src/codeEditor.ts b/src/codeEditor.ts index 17e61d23..c564818f 100644 --- a/src/codeEditor.ts +++ b/src/codeEditor.ts @@ -23,6 +23,10 @@ export const createStubCodeEditor = ({ decorations: sourcegraph.TextDocumentDecoration[] ): void => undefined ), + setStatusBarItem: sinon.spy( + (statusBarItemType: sourcegraph.StatusBarItemType, statusBarItem: sourcegraph.StatusBarItem): void => + undefined + ), }) return codeEditor } diff --git a/src/util.test.ts b/src/util.test.ts index 63707ca7..1e8bb0c4 100644 --- a/src/util.test.ts +++ b/src/util.test.ts @@ -1,7 +1,7 @@ import assert from 'assert' import { notImplemented } from './util' -describe('notImplemted', () => { +describe('notImplemented', () => { it('throws', () => { assert.throws(notImplemented, /not implemented/i) }) diff --git a/yarn.lock b/yarn.lock index 23d7ac5c..b56ee39a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4839,7 +4839,6 @@ npm@^6.14.8: cmd-shim "^3.0.3" columnify "~1.5.4" config-chain "^1.1.12" - debuglog "*" detect-indent "~5.0.0" detect-newline "^2.1.0" dezalgo "~1.0.3" @@ -4854,7 +4853,6 @@ npm@^6.14.8: has-unicode "~2.0.1" hosted-git-info "^2.8.8" iferr "^1.0.2" - imurmurhash "*" infer-owner "^1.0.4" inflight "~1.0.6" inherits "^2.0.4" @@ -4873,14 +4871,8 @@ npm@^6.14.8: libnpx "^10.2.4" lock-verify "^2.1.0" lockfile "^1.0.4" - lodash._baseindexof "*" lodash._baseuniq "~4.6.0" - lodash._bindcallback "*" - lodash._cacheindexof "*" - lodash._createcache "*" - lodash._getnative "*" lodash.clonedeep "~4.5.0" - lodash.restparam "*" lodash.union "~4.6.0" lodash.uniq "~4.5.0" lodash.without "~4.4.0" @@ -6285,10 +6277,10 @@ source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: resolved "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== -sourcegraph@^25.0.0: - version "25.0.0" - resolved "https://registry.yarnpkg.com/sourcegraph/-/sourcegraph-25.0.0.tgz#5f16eb684ee23b59011e68d516df7755ebaa47f8" - integrity sha512-3deJcXdOdKoI5xZv4wiQXOnJw96I/BFLStwHHbUS1XlDP1yHHKQT3pKsTawm/YJ8CUirBYkIVsAA2rR/JYO4Ew== +sourcegraph@^25.2.0: + version "25.2.0" + resolved "https://registry.yarnpkg.com/sourcegraph/-/sourcegraph-25.2.0.tgz#7978b3ca154e2703828cd4bd2fdfbc3f7994bbe8" + integrity sha512-2yYJN8DMFrGesDfZvaYfXie86fHl3HtPRZ4XImQ6H4d7HuHHYEkVYxlbrOD4BUgMBsit5oVUPZ9Kspu0676QAA== spawn-error-forwarder@~1.0.0: version "1.0.0"