Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge internal options to timeline options #147304

Merged
merged 1 commit into from Apr 12, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/vs/workbench/api/browser/mainThreadTimeline.ts
Expand Up @@ -9,7 +9,7 @@ import { URI } from 'vs/base/common/uri';
import { ILogService } from 'vs/platform/log/common/log';
import { MainContext, MainThreadTimelineShape, ExtHostTimelineShape, ExtHostContext } from 'vs/workbench/api/common/extHost.protocol';
import { extHostNamedCustomer, IExtHostContext } from 'vs/workbench/services/extensions/common/extHostCustomers';
import { TimelineChangeEvent, TimelineOptions, TimelineProviderDescriptor, ITimelineService, InternalTimelineOptions, Timeline } from 'vs/workbench/contrib/timeline/common/timeline';
import { TimelineChangeEvent, TimelineOptions, TimelineProviderDescriptor, ITimelineService, Timeline } from 'vs/workbench/contrib/timeline/common/timeline';
import { revive } from 'vs/base/common/marshalling';

@extHostNamedCustomer(MainContext.MainThreadTimeline)
Expand Down Expand Up @@ -40,8 +40,8 @@ export class MainThreadTimeline implements MainThreadTimelineShape {
this._timelineService.registerTimelineProvider({
...provider,
onDidChange: onDidChange.event,
async provideTimeline(uri: URI, options: TimelineOptions, token: CancellationToken, internalOptions?: InternalTimelineOptions) {
return revive<Timeline>(await proxy.$getTimeline(provider.id, uri, options, token, internalOptions));
async provideTimeline(uri: URI, options: TimelineOptions, token: CancellationToken) {
return revive<Timeline>(await proxy.$getTimeline(provider.id, uri, options, token));
},
dispose() {
emitters.delete(provider.id);
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/api/common/extHost.protocol.ts
Expand Up @@ -58,7 +58,7 @@ import { InputValidationType } from 'vs/workbench/contrib/scm/common/scm';
import { IWorkspaceSymbol } from 'vs/workbench/contrib/search/common/search';
import { ISerializableEnvironmentVariableCollection } from 'vs/workbench/contrib/terminal/common/environmentVariable';
import { CoverageDetails, ExtensionRunTestsRequest, IFileCoverage, ISerializedTestResults, ITestItem, ITestMessage, ITestRunProfile, ITestRunTask, ResolvedTestRunRequest, RunTestForControllerRequest, TestResultState, TestsDiffOp } from 'vs/workbench/contrib/testing/common/testTypes';
import { InternalTimelineOptions, Timeline, TimelineChangeEvent, TimelineOptions, TimelineProviderDescriptor } from 'vs/workbench/contrib/timeline/common/timeline';
import { Timeline, TimelineChangeEvent, TimelineOptions, TimelineProviderDescriptor } from 'vs/workbench/contrib/timeline/common/timeline';
import { TypeHierarchyItem } from 'vs/workbench/contrib/typeHierarchy/common/typeHierarchy';
import { AuthenticationProviderInformation, AuthenticationSession, AuthenticationSessionsChangeEvent } from 'vs/workbench/services/authentication/common/authentication';
import { EditorGroupColumn } from 'vs/workbench/services/editor/common/editorGroupColumn';
Expand Down Expand Up @@ -2138,7 +2138,7 @@ export interface ExtHostTunnelServiceShape {
}

export interface ExtHostTimelineShape {
$getTimeline(source: string, uri: UriComponents, options: TimelineOptions, token: CancellationToken, internalOptions?: InternalTimelineOptions): Promise<Dto<Timeline> | undefined>;
$getTimeline(source: string, uri: UriComponents, options: TimelineOptions, token: CancellationToken): Promise<Dto<Timeline> | undefined>;
}

export const enum ExtHostTestingResource {
Expand Down
16 changes: 8 additions & 8 deletions src/vs/workbench/api/common/extHostTimeline.ts
Expand Up @@ -7,7 +7,7 @@ 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 { Timeline, TimelineItem, TimelineOptions, TimelineProvider, InternalTimelineOptions } from 'vs/workbench/contrib/timeline/common/timeline';
import { Timeline, TimelineItem, TimelineOptions, TimelineProvider } from 'vs/workbench/contrib/timeline/common/timeline';
import { IDisposable, toDisposable, DisposableStore } from 'vs/base/common/lifecycle';
import { CancellationToken } from 'vs/base/common/cancellation';
import { CommandsConverter, ExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
Expand All @@ -19,7 +19,7 @@ import { isString } from 'vs/base/common/types';

export interface IExtHostTimeline extends ExtHostTimelineShape {
readonly _serviceBrand: undefined;
$getTimeline(id: string, uri: UriComponents, options: vscode.TimelineOptions, token: vscode.CancellationToken, internalOptions?: InternalTimelineOptions): Promise<Timeline | undefined>;
$getTimeline(id: string, uri: UriComponents, options: vscode.TimelineOptions, token: vscode.CancellationToken): Promise<Timeline | undefined>;
}

export const IExtHostTimeline = createDecorator<IExtHostTimeline>('IExtHostTimeline');
Expand Down Expand Up @@ -51,9 +51,9 @@ export class ExtHostTimeline implements IExtHostTimeline {
});
}

async $getTimeline(id: string, uri: UriComponents, options: vscode.TimelineOptions, token: vscode.CancellationToken, internalOptions?: InternalTimelineOptions): Promise<Timeline | undefined> {
async $getTimeline(id: string, uri: UriComponents, options: vscode.TimelineOptions, token: vscode.CancellationToken): Promise<Timeline | undefined> {
const provider = this._providers.get(id);
return provider?.provideTimeline(URI.revive(uri), options, token, internalOptions);
return provider?.provideTimeline(URI.revive(uri), options, token);
}

registerTimelineProvider(scheme: string | string[], provider: vscode.TimelineProvider, _extensionId: ExtensionIdentifier, commandConverter: CommandsConverter): IDisposable {
Expand All @@ -71,8 +71,8 @@ export class ExtHostTimeline implements IExtHostTimeline {
...provider,
scheme: scheme,
onDidChange: undefined,
async provideTimeline(uri: URI, options: TimelineOptions, token: CancellationToken, internalOptions?: InternalTimelineOptions) {
if (internalOptions?.resetCache) {
async provideTimeline(uri: URI, options: TimelineOptions, token: CancellationToken) {
if (options?.resetCache) {
timelineDisposables.clear();

// For now, only allow the caching of a single Uri
Expand All @@ -87,7 +87,7 @@ export class ExtHostTimeline implements IExtHostTimeline {

// TODO: Should we bother converting all the data if we aren't caching? Meaning it is being requested by an extension?

const convertItem = convertTimelineItem(uri, internalOptions);
const convertItem = convertTimelineItem(uri, options);
return {
...result,
source: provider.id,
Expand All @@ -106,7 +106,7 @@ export class ExtHostTimeline implements IExtHostTimeline {
}

private convertTimelineItem(source: string, commandConverter: CommandsConverter, disposables: DisposableStore) {
return (uri: URI, options?: InternalTimelineOptions) => {
return (uri: URI, options?: TimelineOptions) => {
let items: Map<string, vscode.TimelineItem> | undefined;
if (options?.cacheResults) {
let itemsByUri = this._itemsBySourceAndUriMap.get(source);
Expand Down
Expand Up @@ -8,7 +8,7 @@ import { Emitter } from 'vs/base/common/event';
import { CancellationToken } from 'vs/base/common/cancellation';
import { Disposable, MutableDisposable } from 'vs/base/common/lifecycle';
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { InternalTimelineOptions, ITimelineService, Timeline, TimelineChangeEvent, TimelineItem, TimelineOptions, TimelineProvider } from 'vs/workbench/contrib/timeline/common/timeline';
import { ITimelineService, Timeline, TimelineChangeEvent, TimelineItem, TimelineOptions, TimelineProvider } from 'vs/workbench/contrib/timeline/common/timeline';
import { IWorkingCopyHistoryEntry, IWorkingCopyHistoryService } from 'vs/workbench/services/workingCopy/common/workingCopyHistory';
import { URI } from 'vs/base/common/uri';
import { IPathService } from 'vs/workbench/services/path/common/pathService';
Expand Down Expand Up @@ -102,7 +102,7 @@ export class LocalHistoryTimeline extends Disposable implements IWorkbenchContri
});
}

async provideTimeline(uri: URI, options: TimelineOptions, token: CancellationToken, internalOptions?: InternalTimelineOptions): Promise<Timeline> {
async provideTimeline(uri: URI, options: TimelineOptions, token: CancellationToken): Promise<Timeline> {
const items: TimelineItem[] = [];

// Try to convert the provided `uri` into a form that is likely
Expand Down
5 changes: 3 additions & 2 deletions src/vs/workbench/contrib/timeline/browser/timelinePane.ts
Expand Up @@ -571,9 +571,10 @@ export class TimelinePane extends ViewPane {
}
}
request?.tokenSource.dispose(true);

options.cacheResults = true;
options.resetCache = reset;
request = this.timelineService.getTimeline(
source, uri, options, new CancellationTokenSource(), { cacheResults: true, resetCache: reset }
source, uri, options, new CancellationTokenSource()
);

if (request === undefined) {
Expand Down
11 changes: 4 additions & 7 deletions src/vs/workbench/contrib/timeline/common/timeline.ts
Expand Up @@ -77,11 +77,8 @@ export interface TimelineChangeEvent {
export interface TimelineOptions {
cursor?: string;
limit?: number | { timestamp: number; id?: string };
}

export interface InternalTimelineOptions {
cacheResults: boolean;
resetCache: boolean;
resetCache?: boolean;
cacheResults?: boolean;
}

export interface Timeline {
Expand All @@ -101,7 +98,7 @@ export interface Timeline {
export interface TimelineProvider extends TimelineProviderDescriptor, IDisposable {
onDidChange?: Event<TimelineChangeEvent>;

provideTimeline(uri: URI, options: TimelineOptions, token: CancellationToken, internalOptions?: InternalTimelineOptions): Promise<Timeline | undefined>;
provideTimeline(uri: URI, options: TimelineOptions, token: CancellationToken): Promise<Timeline | undefined>;
}

export interface TimelineSource {
Expand Down Expand Up @@ -152,7 +149,7 @@ export interface ITimelineService {

getSources(): TimelineSource[];

getTimeline(id: string, uri: URI, options: TimelineOptions, tokenSource: CancellationTokenSource, internalOptions?: InternalTimelineOptions): TimelineRequest | undefined;
getTimeline(id: string, uri: URI, options: TimelineOptions, tokenSource: CancellationTokenSource): TimelineRequest | undefined;

setUri(uri: URI): void;
}
Expand Down
6 changes: 3 additions & 3 deletions src/vs/workbench/contrib/timeline/common/timelineService.ts
Expand Up @@ -8,7 +8,7 @@ import { Event, Emitter } from 'vs/base/common/event';
import { IDisposable } from 'vs/base/common/lifecycle';
import { URI } from 'vs/base/common/uri';
import { ILogService } from 'vs/platform/log/common/log';
import { ITimelineService, TimelineChangeEvent, TimelineOptions, TimelineProvidersChangeEvent, TimelineProvider, InternalTimelineOptions, TimelinePaneId } from './timeline';
import { ITimelineService, TimelineChangeEvent, TimelineOptions, TimelineProvidersChangeEvent, TimelineProvider, TimelinePaneId } from './timeline';
import { IViewsService } from 'vs/workbench/common/views';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
Expand Down Expand Up @@ -44,7 +44,7 @@ export class TimelineService implements ITimelineService {
return [...this.providers.values()].map(p => ({ id: p.id, label: p.label }));
}

getTimeline(id: string, uri: URI, options: TimelineOptions, tokenSource: CancellationTokenSource, internalOptions?: InternalTimelineOptions) {
getTimeline(id: string, uri: URI, options: TimelineOptions, tokenSource: CancellationTokenSource) {
this.logService.trace(`TimelineService#getTimeline(${id}): uri=${uri.toString()}`);

const provider = this.providers.get(id);
Expand All @@ -61,7 +61,7 @@ export class TimelineService implements ITimelineService {
}

return {
result: provider.provideTimeline(uri, options, tokenSource.token, internalOptions)
result: provider.provideTimeline(uri, options, tokenSource.token)
.then(result => {
if (result === undefined) {
return undefined;
Expand Down