chore: change return to returns and add some newlines

This commit is contained in:
Maribeth Bottorff
2022-08-16 16:13:39 -07:00
parent 169959bc08
commit d6d8656a45
172 changed files with 2752 additions and 772 deletions

View File

@@ -6,6 +6,7 @@
/**
* Object representing a map of variables and their types.
*
* @class
*/
import * as goog from '../closure/goog/goog.js';
@@ -31,6 +32,7 @@ import type {Workspace} from './workspace.js';
* Class for a variable map. This contains a dictionary data structure with
* variable types as keys and lists of variables as values. The list of
* variables are the type indicated by the key.
*
* @alias Blockly.VariableMap
*/
export class VariableMap {
@@ -51,6 +53,7 @@ export class VariableMap {
/* Begin functions for renaming variables. */
/**
* Rename the given variable by updating its name in the variable map.
*
* @param variable Variable to rename.
* @param newName New variable name.
* @internal
@@ -77,6 +80,7 @@ export class VariableMap {
/**
* Rename a variable by updating its name in the variable map. Identify the
* variable to rename with the given ID.
*
* @param id ID of the variable to rename.
* @param newName New variable name.
*/
@@ -92,6 +96,7 @@ export class VariableMap {
/**
* Update the name of the given variable and refresh all references to it.
* The new name must not conflict with any existing variable names.
*
* @param variable Variable to rename.
* @param newName New variable name.
* @param blocks The list of all blocks in the workspace.
@@ -111,6 +116,7 @@ export class VariableMap {
* variable. The two variables are coalesced into a single variable with the
* ID of the existing variable that was already using newName. Refresh all
* references to the variable.
*
* @param variable Variable to rename.
* @param newName New variable name.
* @param conflictVar The variable that was already using newName.
@@ -140,13 +146,14 @@ export class VariableMap {
/* End functions for renaming variables. */
/**
* Create a variable with a given name, optional type, and optional ID.
*
* @param name The name of the variable. This must be unique across variables
* and procedures.
* @param opt_type The type of the variable like 'int' or 'string'.
* Does not need to be unique. Field_variable can filter variables based
* on their type. This will default to '' which is a specific type.
* @param opt_id The unique ID of the variable. This will default to a UUID.
* @return The newly created variable.
* @returns The newly created variable.
*/
createVariable(name: string, opt_type?: string|null, opt_id?: string|null):
VariableModel {
@@ -182,6 +189,7 @@ export class VariableMap {
/* Begin functions for variable deletion. */
/**
* Delete a variable.
*
* @param variable Variable to delete.
*/
deleteVariable(variable: VariableModel) {
@@ -203,6 +211,7 @@ export class VariableMap {
/**
* Delete a variables by the passed in ID and all of its uses from this
* workspace. May prompt the user for confirmation.
*
* @param id ID of variable to delete.
*/
deleteVariableById(id: string) {
@@ -246,6 +255,7 @@ export class VariableMap {
/**
* Deletes a variable and all of its uses from this workspace without asking
* the user for confirmation.
*
* @param variable Variable to delete.
* @param uses An array of uses of the variable.
* @internal
@@ -270,10 +280,11 @@ export class VariableMap {
/**
* Find the variable by the given name and type and return it. Return null if
* it is not found.
*
* @param name The name to check for.
* @param opt_type The type of the variable. If not provided it defaults to
* the empty string, which is a specific type.
* @return The variable with the given name, or null if it was not found.
* @returns The variable with the given name, or null if it was not found.
*/
getVariable(name: string, opt_type?: string|null): VariableModel|null {
const type = opt_type || '';
@@ -290,8 +301,9 @@ export class VariableMap {
/**
* Find the variable by the given ID and return it. Return null if not found.
*
* @param id The ID to check for.
* @return The variable with the given ID.
* @returns The variable with the given ID.
*/
getVariableById(id: string): VariableModel|null {
for (const [_key, variables] of this.variableMap) {
@@ -307,8 +319,9 @@ export class VariableMap {
/**
* Get a list containing all of the variables of a specified type. If type is
* null, return list of variables with empty string type.
*
* @param type Type of the variables to find.
* @return The sought after variables of the passed in type. An empty array if
* @returns The sought after variables of the passed in type. An empty array if
* none are found.
*/
getVariablesOfType(type: string|null): VariableModel[] {
@@ -323,10 +336,11 @@ export class VariableMap {
/**
* Return all variable and potential variable types. This list always
* contains the empty string.
*
* @param ws The workspace used to look for potential variables. This can be
* different than the workspace stored on this object if the passed in ws
* is a flyout workspace.
* @return List of variable types.
* @returns List of variable types.
* @internal
*/
getVariableTypes(ws: Workspace|null): string[] {
@@ -344,7 +358,8 @@ export class VariableMap {
/**
* Return all variables of all types.
* @return List of variable models.
*
* @returns List of variable models.
*/
getAllVariables(): VariableModel[] {
let allVariables: VariableModel[] = [];
@@ -356,7 +371,8 @@ export class VariableMap {
/**
* Returns all of the variable names of all types.
* @return All of the variable names of all types.
*
* @returns All of the variable names of all types.
*/
getAllVariableNames(): string[] {
return Array.from(this.variableMap.values())
@@ -366,8 +382,9 @@ export class VariableMap {
/**
* Find all the uses of a named variable.
*
* @param id ID of the variable to find.
* @return Array of block usages.
* @returns Array of block usages.
*/
getVariableUsesById(id: string): Block[] {
const uses = [];