mirror of
https://github.com/google/blockly.git
synced 2026-01-07 00:50:27 +01:00
refactor: make VariableModel implement IVariableModel. (#8381)
* refactor: make VariableModel implement IVariableModel. * chore: assauge the linter.
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user