-
Notifications
You must be signed in to change notification settings - Fork 30.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds timeline view & api providers (wip) — #84297
- Loading branch information
Eric Amodio
committed
Jan 24, 2020
1 parent
5d49873
commit f587cc7
Showing
13 changed files
with
770 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { MainContext, MainThreadTimelineShape, IExtHostContext, ExtHostTimelineShape, ExtHostContext } from 'vs/workbench/api/common/extHost.protocol'; | ||
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers'; | ||
import { ITimelineService, TimelineItem } from 'vs/workbench/contrib/timeline/common/timeline'; | ||
import { URI } from 'vs/base/common/uri'; | ||
import { CancellationToken } from 'vs/base/common/cancellation'; | ||
|
||
@extHostNamedCustomer(MainContext.MainThreadTimeline) | ||
export class MainThreadTimeline implements MainThreadTimelineShape { | ||
|
||
private readonly _proxy: ExtHostTimelineShape; | ||
|
||
constructor( | ||
context: IExtHostContext, | ||
@ITimelineService private readonly _timelineService: ITimelineService | ||
) { | ||
this._proxy = context.getProxy(ExtHostContext.ExtHostTimeline); | ||
} | ||
|
||
$getTimeline(uri: URI, since: number, token: CancellationToken): Promise<TimelineItem[]> { | ||
return this._timelineService.getTimeline(uri, since, token); | ||
} | ||
|
||
$registerTimelineProvider(key: string, id: string): void { | ||
console.log(`MainThreadTimeline#registerTimelineProvider: key=${key}`); | ||
|
||
const proxy = this._proxy; | ||
this._timelineService.registerTimelineProvider(key, { | ||
id: id, | ||
provideTimeline(uri: URI, since: number, token: CancellationToken) { | ||
return proxy.$getTimeline(key, uri, since, token); | ||
} | ||
}); | ||
} | ||
|
||
$unregisterTimelineProvider(key: string): void { | ||
console.log(`MainThreadTimeline#unregisterTimelineProvider: key=${key}`); | ||
this._timelineService.unregisterTimelineProvider(key); | ||
} | ||
|
||
dispose(): void { | ||
// noop | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import * as vscode from 'vscode'; | ||
import { UriComponents, URI } from 'vs/base/common/uri'; | ||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; | ||
import { ExtHostTimelineShape, MainThreadTimelineShape, IMainContext, MainContext } from 'vs/workbench/api/common/extHost.protocol'; | ||
import { TimelineItem, TimelineProvider, toKey } from 'vs/workbench/contrib/timeline/common/timeline'; | ||
import { IDisposable, toDisposable } from 'vs/base/common/lifecycle'; | ||
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions'; | ||
|
||
export interface IExtHostTimeline extends ExtHostTimelineShape { | ||
readonly _serviceBrand: undefined; | ||
$getTimeline(key: string, uri: UriComponents, since: number, token: vscode.CancellationToken): Promise<TimelineItem[]>; | ||
} | ||
|
||
export const IExtHostTimeline = createDecorator<IExtHostTimeline>('IExtHostTimeline'); | ||
|
||
export class ExtHostTimeline implements IExtHostTimeline { | ||
_serviceBrand: undefined; | ||
|
||
private _proxy: MainThreadTimelineShape; | ||
|
||
private _providers = new Map<string, TimelineProvider>(); | ||
|
||
constructor( | ||
mainContext: IMainContext, | ||
|
||
) { | ||
this._proxy = mainContext.getProxy(MainContext.MainThreadTimeline); | ||
|
||
this.registerTimelineProvider('bar', { | ||
id: 'baz', | ||
async provideTimeline(uri: URI, since: number, token: vscode.CancellationToken) { | ||
return [ | ||
{ | ||
id: '1', | ||
label: 'Bar Timeline1', | ||
description: uri.toString(true), | ||
detail: new Date().toString(), | ||
date: Date.now(), | ||
source: 'log' | ||
}, | ||
{ | ||
id: '2', | ||
label: 'Bar Timeline2', | ||
description: uri.toString(true), | ||
detail: new Date(Date.now() - 100).toString(), | ||
date: Date.now() - 100, | ||
source: 'log' | ||
} | ||
]; | ||
} | ||
}); | ||
} | ||
|
||
async $getTimeline(key: string, uri: UriComponents, since: number, token: vscode.CancellationToken): Promise<TimelineItem[]> { | ||
const provider = this._providers.get(key); | ||
return provider?.provideTimeline(URI.revive(uri), since, token) ?? []; | ||
} | ||
|
||
registerTimelineProvider(extension: ExtensionIdentifier | string, provider: TimelineProvider): IDisposable { | ||
console.log(`ExtHostTimeline#registerTimelineProvider: extension=${extension.toString()}, provider=${provider.id}`); | ||
|
||
const key = toKey(extension, provider.id); | ||
if (this._providers.has(key)) { | ||
throw new Error(`Timeline Provider ${key} already exists.`); | ||
} | ||
|
||
this._proxy.$registerTimelineProvider(key, provider.id); | ||
this._providers.set(key, provider); | ||
|
||
return toDisposable(() => { | ||
this._providers.delete(key); | ||
this._proxy.$unregisterTimelineProvider(key); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
src/vs/workbench/contrib/timeline/browser/media/timelinePane.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ |
Oops, something went wrong.