From bef8d8319d3cfb2ce9514ec84fae5a81a3f17389 Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Tue, 16 Jul 2024 15:47:43 -0700 Subject: [PATCH] refactor: make VariableModel implement IVariableModel. (#8381) * refactor: make VariableModel implement IVariableModel. * chore: assauge the linter. --- core/variable_model.ts | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/core/variable_model.ts b/core/variable_model.ts index 0728a3d56..c4ec05367 100644 --- a/core/variable_model.ts +++ b/core/variable_model.ts @@ -16,6 +16,7 @@ import './events/events_var_create.js'; import * as idGenerator from './utils/idgenerator.js'; import type {Workspace} from './workspace.js'; +import {IVariableModel} from './interfaces/i_variable_model.js'; /** * Class for a variable model. @@ -23,7 +24,7 @@ import type {Workspace} from './workspace.js'; * * @see {Blockly.FieldVariable} */ -export class VariableModel { +export class VariableModel implements IVariableModel { type: string; private readonly id_: string; @@ -64,6 +65,36 @@ export class VariableModel { return this.id_; } + /** @returns The name of this variable. */ + getName(): string { + return this.name; + } + + /** + * Updates the user-visible name of this variable. + * + * @returns The newly-updated variable. + */ + setName(newName: string): this { + this.name = newName; + return this; + } + + /** @returns The type of this variable. */ + getType(): string { + return this.type; + } + + /** + * Updates the type of this variable. + * + * @returns The newly-updated variable. + */ + setType(newType: string): this { + this.type = newType; + return this; + } + /** * A custom compare function for the VariableModel objects. *