Skip to content

Commit f0c9821

Browse files
authored
Cleanup deprecated types (#332)
Ensure that deprecated types are isolated and don't leak into non-deprecated definitions. => Consistently use definitions from sprotty protocol in non-deprecated classes,functions or type definitions.
1 parent 584a701 commit f0c9821

File tree

22 files changed

+94
-82
lines changed

22 files changed

+94
-82
lines changed

packages/sprotty/src/base/actions/action-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { TYPES } from "../types";
1919
import { MultiInstanceRegistry } from "../../utils/registry";
2020
import { isInjectable } from "../../utils/inversify";
2121
import { ICommand } from "../commands/command";
22-
import { Action } from "./action";
22+
import { Action } from "sprotty-protocol";
2323

2424
/**
2525
* An action handler accepts an action and reacts to it by returning either a command to be

packages/sprotty/src/base/actions/action.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
1515
********************************************************************************/
1616

17-
import { generateRequestId as generateRequestId2 } from 'sprotty-protocol/lib/actions';
17+
import { generateRequestId as generateRequestId2, Action as ProtocolAction} from 'sprotty-protocol/lib/actions';
1818
import { JsonAny } from 'sprotty-protocol/lib/utils/json';
1919
import { hasOwnProperty } from 'sprotty-protocol/lib/utils/object';
2020

@@ -99,7 +99,7 @@ export class RejectAction implements ResponseAction {
9999
* to define an entry in the command palette or in the context menu.
100100
*/
101101
export class LabeledAction {
102-
constructor(readonly label: string, readonly actions: Action[], readonly icon?: string) { }
102+
constructor(readonly label: string, readonly actions: ProtocolAction[], readonly icon?: string) { }
103103
}
104104

105105
export function isLabeledAction(element: unknown): element is LabeledAction {

packages/sprotty/src/base/features/set-model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { InitializeCanvasBoundsCommand } from './initialize-canvas';
3333
*
3434
* @deprecated Use the declaration from `sprotty-protocol` instead.
3535
*/
36-
export class RequestModelAction implements RequestAction<SetModelAction>, ProtocolRequestModelAction {
36+
export class RequestModelAction implements ProtocolRequestModelAction {
3737
static readonly KIND = 'requestModel';
3838
readonly kind = RequestModelAction.KIND;
3939

packages/sprotty/src/base/model/smodel.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
********************************************************************************/
1616

1717
import { Bounds, isBounds, Point } from "sprotty-protocol/lib/utils/geometry";
18+
import { SModelElement as ProtocolSModelElement } from "sprotty-protocol";
1819
import { mapIterable, FluentIterable } from "../../utils/iterable";
1920

2021
/**
@@ -81,8 +82,8 @@ export interface FeatureSet {
8182
has(feature: symbol): boolean
8283
}
8384

84-
export function isParent(element: SModelElementSchema | SModelElement):
85-
element is SModelElementSchema & { children: SModelElementSchema[] } {
85+
export function isParent(element: ProtocolSModelElement | SModelElement):
86+
element is ProtocolSModelElement & { children: ProtocolSModelElement[] } {
8687
const children = (element as any).children;
8788
return children !== undefined && children.constructor === Array;
8889
}
@@ -213,10 +214,10 @@ export function createRandomId(length: number = 8): string {
213214
* Used to speed up model element lookup by id.
214215
*/
215216
export interface IModelIndex {
216-
add(element: SModelElementSchema): void
217-
remove(element: SModelElementSchema): void
218-
contains(element: SModelElementSchema): boolean
219-
getById(id: string): SModelElementSchema | undefined
217+
add(element: ProtocolSModelElement): void
218+
remove(element: ProtocolSModelElement): void
219+
contains(element: ProtocolSModelElement): boolean
220+
getById(id: string): ProtocolSModelElement | undefined
220221
}
221222

222223
/**

packages/sprotty/src/base/ui-extensions/ui-extension.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
1515
********************************************************************************/
1616
import { inject, injectable } from "inversify";
17+
import { hasOwnProperty } from "sprotty-protocol";
1718
import { ILogger } from "../../utils/logging";
1819
import { SModelRoot } from "../model/smodel";
1920
import { TYPES } from "../types";
@@ -26,6 +27,13 @@ export interface IUIExtension {
2627
id(): string;
2728
show(root: Readonly<SModelRoot>, ...contextElementIds: string[]): void;
2829
hide(): void;
30+
enableOnStartup?: boolean
31+
}
32+
33+
export function isUIExtension(object: unknown): object is IUIExtension {
34+
return hasOwnProperty<string, Function>(object, 'id', 'function')
35+
&& hasOwnProperty<string, Function>(object, 'show', 'function')
36+
&& hasOwnProperty<string, Function>(object, 'hide', 'function');
2937
}
3038

3139
/**

packages/sprotty/src/features/bounds/bounds-manipulation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { inject, injectable } from "inversify";
1818
import {
19-
Action, generateRequestId, RequestAction, ResponseAction} from 'sprotty-protocol/lib/actions';
19+
Action, generateRequestId, RequestAction, ResponseAction, ComputedBoundsAction as ProtocolComputedBoundsAction} from 'sprotty-protocol/lib/actions';
2020
import * as protocol from "sprotty-protocol/lib/actions";
2121
import { SModelRoot as SModelRootSchema } from 'sprotty-protocol/lib/model';
2222
import { Bounds, Dimension, Point } from "sprotty-protocol/lib/utils/geometry";
@@ -198,6 +198,6 @@ export class RequestBoundsCommand extends HiddenCommand {
198198
}
199199

200200
get blockUntil(): (action: Action) => boolean {
201-
return action => action.kind === ComputedBoundsAction.KIND;
201+
return action => action.kind === ProtocolComputedBoundsAction.KIND;
202202
}
203203
}

packages/sprotty/src/features/button/model.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
1515
********************************************************************************/
1616

17-
import { boundsFeature, layoutableChildFeature, SShapeElement, SShapeElementSchema } from '../bounds/model';
17+
import { boundsFeature, layoutableChildFeature, SShapeElement } from '../bounds/model';
1818
import { fadeFeature } from '../fade/model';
19+
import { SShapeElement as SShapeElementSchema } from 'sprotty-protocol';
1920

2021
export interface SButtonSchema extends SShapeElementSchema {
2122
pressed: boolean

packages/sprotty/src/features/edit/create.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
********************************************************************************/
1616

1717
import { inject, injectable } from 'inversify';
18-
import { Action } from 'sprotty-protocol/lib/actions';
18+
import { Action, CreateElementAction as ProtocolCreateElementAction } from 'sprotty-protocol/lib/actions';
1919
import { SModelElement as SModelElementSchema } from 'sprotty-protocol/lib/model';
2020
import { Command, CommandExecutionContext, CommandReturn } from '../../base/commands/command';
2121
import { SParentElement, SChildElement } from '../../base/model/smodel';
@@ -45,12 +45,12 @@ export namespace CreateElementAction {
4545

4646
@injectable()
4747
export class CreateElementCommand extends Command {
48-
static readonly KIND = CreateElementAction.KIND;
48+
static readonly KIND = ProtocolCreateElementAction.KIND;
4949

5050
container: SParentElement;
5151
newElement: SChildElement;
5252

53-
constructor(@inject(TYPES.Action) protected readonly action: CreateElementAction) {
53+
constructor(@inject(TYPES.Action) protected readonly action: ProtocolCreateElementAction) {
5454
super();
5555
}
5656

packages/sprotty/src/features/edit/delete.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
********************************************************************************/
1616

1717
import { inject, injectable } from 'inversify';
18-
import { Action } from 'sprotty-protocol/lib/actions';
18+
import { Action, DeleteElementAction as ProtocolDeleteElementAction} from 'sprotty-protocol/lib/actions';
1919
import { Command, CommandExecutionContext, CommandReturn } from '../../base/commands/command';
2020
import { SModelElement, SParentElement, SChildElement } from '../../base/model/smodel';
2121
import { SModelExtension } from '../../base/model/smodel-extension';
@@ -57,11 +57,11 @@ export class ResolvedDelete {
5757

5858
@injectable()
5959
export class DeleteElementCommand extends Command {
60-
static readonly KIND = DeleteElementAction.KIND;
60+
static readonly KIND = ProtocolDeleteElementAction.KIND;
6161

6262
resolvedDeletes: ResolvedDelete[] = [];
6363

64-
constructor(@inject(TYPES.Action) protected readonly action: DeleteElementAction) {
64+
constructor(@inject(TYPES.Action) protected readonly action: ProtocolDeleteElementAction) {
6565
super();
6666
}
6767

packages/sprotty/src/features/edit/edit-label.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
********************************************************************************/
1616

1717
import { inject } from 'inversify';
18-
import { Action, isAction } from 'sprotty-protocol/lib/actions';
18+
import { Action, isAction, ApplyLabelEditAction as ProtocolApplyLabelEditAction } from 'sprotty-protocol/lib/actions';
1919
import { CommandExecutionContext, CommandReturn, Command } from '../../base/commands/command';
2020
import { SModelElement } from '../../base/model/smodel';
2121
import { TYPES } from '../../base/types';
@@ -66,8 +66,8 @@ export namespace ApplyLabelEditAction {
6666
}
6767
}
6868

69-
export function isApplyLabelEditAction(element?: any): element is ApplyLabelEditAction {
70-
return isAction(element) && element.kind === ApplyLabelEditAction.KIND && 'labelId' in element && 'text' in element;
69+
export function isApplyLabelEditAction(element?: any): element is ProtocolApplyLabelEditAction {
70+
return isAction(element) && element.kind === ProtocolApplyLabelEditAction.KIND && 'labelId' in element && 'text' in element;
7171
}
7272

7373

@@ -78,11 +78,11 @@ export class ResolvedLabelEdit {
7878
}
7979

8080
export class ApplyLabelEditCommand extends Command {
81-
static readonly KIND = ApplyLabelEditAction.KIND;
81+
static readonly KIND = ProtocolApplyLabelEditAction.KIND;
8282

8383
protected resolvedLabelEdit: ResolvedLabelEdit;
8484

85-
constructor(@inject(TYPES.Action) protected readonly action: ApplyLabelEditAction) {
85+
constructor(@inject(TYPES.Action) protected readonly action: ProtocolApplyLabelEditAction) {
8686
super();
8787
}
8888

0 commit comments

Comments
 (0)