Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion core/variable_model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ 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.
* Holds information for the variable including name, ID, and type.
*
* @see {Blockly.FieldVariable}
*/
export class VariableModel {
export class VariableModel implements IVariableModel {
type: string;
private readonly id_: string;

Expand Down Expand Up @@ -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.
*
Expand Down