Skip to content

Commit

Permalink
Update arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Shougo committed Nov 12, 2024
1 parent 146cd0e commit dcf217d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 70 deletions.
28 changes: 15 additions & 13 deletions denops/ddc/base/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,28 @@ export type OnInitArguments<Params extends BaseParams> = {
filterParams: Params;
};

export type OnEventArguments<Params extends BaseParams> = {
type BaseFilterArguments<Params extends BaseParams> = {
denops: Denops;
context: Context;
onCallback: OnCallback;
options: DdcOptions;
filterOptions: FilterOptions;
filterParams: Params;
};

export type FilterArguments<Params extends BaseParams> = {
denops: Denops;
context: Context;
onCallback: OnCallback;
options: DdcOptions;
sourceOptions: SourceOptions;
filterOptions: FilterOptions;
filterParams: Params;
completeStr: string;
items: Item[];
};
export type OnEventArguments<Params extends BaseParams> =
& BaseFilterArguments<Params>
& {
onCallback: OnCallback;
};

export type FilterArguments<Params extends BaseParams> =
& BaseFilterArguments<Params>
& {
onCallback: OnCallback;
sourceOptions: SourceOptions;
completeStr: string;
items: Item[];
};

export abstract class BaseFilter<Params extends BaseParams> {
name = "";
Expand Down
55 changes: 22 additions & 33 deletions denops/ddc/base/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,62 +20,51 @@ export type OnInitArguments<Params extends BaseParams> = {
sourceParams: Params;
};

export type OnEventArguments<Params extends BaseParams> = {
type BaseSourceArguments<Params extends BaseParams> = {
denops: Denops;
context: Context;
onCallback: OnCallback;
options: DdcOptions;
sourceOptions: SourceOptions;
sourceParams: Params;
};

export type OnEventArguments<Params extends BaseParams> =
& BaseSourceArguments<Params>
& {
onCallback: OnCallback;
};

export type OnCompleteDoneArguments<
Params extends BaseParams,
UserData extends unknown = unknown,
> = {
denops: Denops;
context: Context;
> = BaseSourceArguments<Params> & {
onCallback: OnCallback;
options: DdcOptions;
sourceOptions: SourceOptions;
sourceParams: Params;
// To prevent users from accessing internal variables.
userData: UserData;
};

export type GetPreviewerArguments<
Params extends BaseParams,
UserData extends unknown = unknown,
> = {
denops: Denops;
context: Context;
options: DdcOptions;
sourceOptions: SourceOptions;
sourceParams: Params;
> = BaseSourceArguments<Params> & {
item: Item<UserData>;
previewContext: PreviewContext;
};

export type GetCompletePositionArguments<Params extends BaseParams> = {
denops: Denops;
context: Context;
onCallback: OnCallback;
options: DdcOptions;
sourceOptions: SourceOptions;
sourceParams: Params;
};
export type GetCompletePositionArguments<Params extends BaseParams> =
& BaseSourceArguments<Params>
& {
onCallback: OnCallback;
};

export type GatherArguments<Params extends BaseParams> = {
denops: Denops;
context: Context;
onCallback: OnCallback;
options: DdcOptions;
sourceOptions: SourceOptions;
sourceParams: Params;
completePos: number;
completeStr: string;
isIncomplete?: boolean;
};
export type GatherArguments<Params extends BaseParams> =
& BaseSourceArguments<Params>
& {
onCallback: OnCallback;
completePos: number;
completeStr: string;
isIncomplete?: boolean;
};

export abstract class BaseSource<
Params extends BaseParams,
Expand Down
38 changes: 14 additions & 24 deletions denops/ddc/base/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,29 @@ export type OnInitArguments<Params extends BaseParams> = {
uiParams: Params;
};

export type SkipCompletionArguments<Params extends BaseParams> = {
type BaseUiArguments<Params extends BaseParams> = {
denops: Denops;
context: Context;
options: DdcOptions;
uiOptions: UiOptions;
uiParams: Params;
};

export type ShowArguments<Params extends BaseParams> = {
denops: Denops;
context: Context;
options: DdcOptions;
completePos: number;
items: DdcItem[];
uiOptions: UiOptions;
uiParams: Params;
};
export type SkipCompletionArguments<Params extends BaseParams> =
BaseUiArguments<Params>;

export type HideArguments<Params extends BaseParams> = {
denops: Denops;
context: Context;
options: DdcOptions;
uiOptions: UiOptions;
uiParams: Params;
};
export type ShowArguments<Params extends BaseParams> =
& BaseUiArguments<Params>
& {
completePos: number;
items: DdcItem[];
};

export type VisibleArguments<Params extends BaseParams> = {
denops: Denops;
context: Context;
options: DdcOptions;
uiOptions: UiOptions;
uiParams: Params;
};
export type HideArguments<Params extends BaseParams> = BaseUiArguments<Params>;

export type VisibleArguments<Params extends BaseParams> = BaseUiArguments<
Params
>;

export abstract class BaseUi<Params extends BaseParams> {
name = "";
Expand Down

0 comments on commit dcf217d

Please sign in to comment.