feat: add interface definitions for procedure stuff (#6488)

* feat: add interface definitions for procedure stuff

* fix: signature of insertParameter

* fix: remove declareModuleId

* fix: remove variable-ness from the parameter interface

* chore: types -> type

* chore: PR comments

* fix: update interfaces to use this return type

* chore: format
This commit is contained in:
Beka Westberg
2022-10-13 11:21:37 -07:00
committed by GitHub
parent 7147813693
commit 1162a660a0
2 changed files with 105 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
/**
* @license
* Copyright 2022 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
/**
* The interface for the data model of a procedure parameter.
*
* @namespace Blockly.IParameterModel
*/
/**
* A data model for a procedure.
*/
export interface IParameterModel {
/**
* Sets the name of this parameter to the given name.
*/
setName(name: string): this;
/**
* Sets the types of this parameter to the given type.
*/
setTypes(types: string[]): this;
/**
* Returns the unique language-neutral ID for the parameter.
*
* This represents the identify of the variable model which does not change
* over time.
*/
getId(): string;
}

View File

@@ -0,0 +1,70 @@
/**
* @license
* Copyright 2022 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
/**
* The interface for the data model of a procedure.
*
* @namespace Blockly.IProcedureModel
*/
import {IParameterModel} from './i_parameter_model.js';
/**
* A data model for a procedure.
*/
export interface IProcedureModel {
/** Sets the human-readable name of the procedure. */
setName(name: string): this;
/**
* Inserts a parameter into the list of parameters.
*
* To move a parameter, first delete it, and then re-insert.
*/
insertParameter(parameterModel: IParameterModel, index: number): this;
/** Removes the parameter at the given index from the parameter list. */
deleteParameter(index: number): this;
/**
* Sets the return type(s) of the procedure.
*
* Pass null to represent a procedure that does not return.
*/
setReturnTypes(types: string[]|null): this;
/**
* Sets whether this procedure is enabled/disabled. If a procedure is disabled
* all procedure caller blocks should be disabled as well.
*/
setEnabled(enabled: boolean): this;
/** Returns the unique language-neutral ID for the procedure. */
getId(): string;
/** Returns the human-readable name of the procedure. */
getName(): string;
/** Returns the parameter at the given index in the parameter list. */
getParameter(index: number): IParameterModel;
/** Returns an array of all of the parameters in the parameter list. */
getParameters(): IParameterModel[];
/**
* Returns the return type(s) of the procedure.
*
* Null represents a procedure that does not return a value.
*/
getReturnTypes(): string[]|null;
/**
* Returns whether the procedure is enabled/disabled. If a procedure is
* disabled, all procedure caller blocks should be disabled as well.
*/
getEnabled(): boolean;
}