diff --git a/blocks/logic.js b/blocks/logic.js index cad9f6c8e..484cdca71 100644 --- a/blocks/logic.js +++ b/blocks/logic.js @@ -483,10 +483,10 @@ Blockly.Constants.Logic.CONTROLS_IF_MUTATOR_MIXIN = { }, /** * Reconnects child blocks. - * @param {!Array} valueConnections List of value - * connectsions for if input. - * @param {!Array} statementConnections List of - * statement connections for do input. + * @param {!Array.} valueConnections List of + * value connections for 'if' input. + * @param {!Array.} statementConnections List of + * statement connections for 'do' input. * @param {?Blockly.RenderedConnection} elseStatementConnection Statement * connection for else input. * @this {Blockly.Block} diff --git a/core/block.js b/core/block.js index af7c620f4..f70f8e966 100644 --- a/core/block.js +++ b/core/block.js @@ -208,21 +208,7 @@ Blockly.Block = function(workspace, prototypeName, opt_id) { }; /** - * Obtain a newly created block. - * @param {!Blockly.Workspace} workspace The block's workspace. - * @param {?string} prototypeName Name of the language object containing - * type-specific functions for this block. - * @return {!Blockly.Block} The created block. - * @deprecated December 2015 - */ -Blockly.Block.obtain = function(workspace, prototypeName) { - console.warn('Deprecated call to Blockly.Block.obtain, ' + - 'use workspace.newBlock instead.'); - return workspace.newBlock(prototypeName); -}; - -/** - * Optional text data that round-trips beween blocks and XML. + * Optional text data that round-trips between blocks and XML. * Has no effect. May be used by 3rd parties for meta information. * @type {?string} */ diff --git a/core/blockly.js b/core/blockly.js index 212d655b6..b3b9f256d 100644 --- a/core/blockly.js +++ b/core/blockly.js @@ -377,21 +377,6 @@ Blockly.hideChaff = function(opt_allowToolbox) { } }; -/** - * When something in Blockly's workspace changes, call a function. - * @param {!Function} func Function to call. - * @return {!Array.} Opaque data that can be passed to - * removeChangeListener. - * @deprecated April 2015 - */ -Blockly.addChangeListener = function(func) { - // Backwards compatibility from before there could be multiple workspaces. - console.warn( - 'Deprecated call to Blockly.addChangeListener, ' + - 'use workspace.addChangeListener instead.'); - return Blockly.getMainWorkspace().addChangeListener(func); -}; - /** * Returns the main workspace. Returns the last used main workspace (based on * focus). Try not to use this function, particularly if there are multiple @@ -694,7 +679,7 @@ Blockly.checkBlockColourConstants = function() { * Checks for a constant in the Blockly namespace, verifying it is undefined or * has the old/original value. Prints a warning if this is not true. * @param {string} msgName The Msg constant identifier. - * @param {Array} blocklyNamePath The name parts of the tested + * @param {Array.} blocklyNamePath The name parts of the tested * constant. * @param {number|undefined} expectedValue The expected value of the constant. * @private diff --git a/core/components/component.js b/core/components/component.js index 6661187b2..3f893623e 100644 --- a/core/components/component.js +++ b/core/components/component.js @@ -234,14 +234,14 @@ Blockly.Component.prototype.setElementInternal = function(element) { Blockly.Component.prototype.setParent = function(parent) { if (this == parent) { // Attempting to add a child to itself is an error. - throw new Error(Blockly.Component.Error.PARENT_UNABLE_TO_BE_SET); + throw Error(Blockly.Component.Error.PARENT_UNABLE_TO_BE_SET); } if (parent && this.parent_ && this.id_ && this.parent_.getChild(this.id_) && this.parent_ != parent) { // This component is already the child of some parent, so it should be // removed using removeChild/removeChildAt first. - throw new Error(Blockly.Component.Error.PARENT_UNABLE_TO_BE_SET); + throw Error(Blockly.Component.Error.PARENT_UNABLE_TO_BE_SET); } this.parent_ = parent; @@ -328,7 +328,7 @@ Blockly.Component.prototype.renderBefore = function(sibling) { Blockly.Component.prototype.render_ = function( opt_parentElement, opt_beforeNode) { if (this.inDocument_) { - throw new Error(Blockly.Component.Error.ALREADY_RENDERED); + throw Error(Blockly.Component.Error.ALREADY_RENDERED); } if (!this.element_) { @@ -526,12 +526,12 @@ Blockly.Component.prototype.addChildAt = function(child, index, opt_render) { if (child.inDocument_ && (opt_render || !this.inDocument_)) { // Adding a child that's already in the document is an error, except if the // parent is also in the document and opt_render is false (e.g. decorate()). - throw new Error(Blockly.Component.Error.ALREADY_RENDERED); + throw Error(Blockly.Component.Error.ALREADY_RENDERED); } if (index < 0 || index > this.getChildCount()) { // Allowing sparse child arrays would lead to strange behavior, so we don't. - throw new Error(Blockly.Component.Error.CHILD_INDEX_OUT_OF_BOUNDS); + throw Error(Blockly.Component.Error.CHILD_INDEX_OUT_OF_BOUNDS); } // Create the index and the child array on first use. @@ -626,7 +626,7 @@ Blockly.Component.prototype.isRightToLeft = function() { */ Blockly.Component.prototype.setRightToLeft = function(rightToLeft) { if (this.inDocument_) { - throw new Error(Blockly.Component.Error.ALREADY_RENDERED); + throw Error(Blockly.Component.Error.ALREADY_RENDERED); } this.rightToLeft_ = rightToLeft; }; @@ -771,7 +771,7 @@ Blockly.Component.prototype.removeChild = function(child, opt_unrender) { } if (!child) { - throw new Error(Blockly.Component.Error.NOT_OUR_CHILD); + throw Error(Blockly.Component.Error.NOT_OUR_CHILD); } return /** @type {!Blockly.Component} */ (child); diff --git a/core/components/menu/menuitem.js b/core/components/menu/menuitem.js index 0cf2ad3fb..acb71d9fb 100644 --- a/core/components/menu/menuitem.js +++ b/core/components/menu/menuitem.js @@ -268,7 +268,7 @@ Blockly.MenuItem.prototype.setEnabled = function(enabled) { /** * Handles click events. If the component is enabled, trigger - * the action assosiated with this menu item. + * the action associated with this menu item. * @param {Event} _e Mouse event to handle. * @package */ diff --git a/core/components/tree/basenode.js b/core/components/tree/basenode.js index 5e3299d16..57975c693 100644 --- a/core/components/tree/basenode.js +++ b/core/components/tree/basenode.js @@ -786,7 +786,7 @@ Blockly.tree.BaseNode.prototype.getIconDom = function() { * @protected */ Blockly.tree.BaseNode.prototype.getCalculatedIconClass = function() { - throw new Error('unimplemented abstract method'); + throw Error('unimplemented abstract method'); }; /** diff --git a/core/components/tree/treecontrol.js b/core/components/tree/treecontrol.js index e4b7dfbe3..62f7607c4 100644 --- a/core/components/tree/treecontrol.js +++ b/core/components/tree/treecontrol.js @@ -70,7 +70,7 @@ Blockly.tree.TreeControl.prototype.getTree = function() { }; /** - * Returns the assosiated toolbox. + * Returns the associated toolbox. * @return {Blockly.Toolbox} The toolbox. * @package */ diff --git a/core/dragged_connection_manager.js b/core/dragged_connection_manager.js deleted file mode 100644 index 4b260c24f..000000000 --- a/core/dragged_connection_manager.js +++ /dev/null @@ -1,258 +0,0 @@ -/** - * @license - * Visual Blocks Editor - * - * Copyright 2017 Google Inc. - * https://developers.google.com/blockly/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @fileoverview Class that controls updates to connections during drags. - * @author fenichel@google.com (Rachel Fenichel) - */ -'use strict'; - -goog.provide('Blockly.DraggedConnectionManager'); - -goog.require('Blockly.blockAnimations'); -goog.require('Blockly.RenderedConnection'); - - -/** - * Class that controls updates to connections during drags. It is primarily - * responsible for finding the closest eligible connection and highlighting or - * unhiglighting it as needed during a drag. - * @deprecated July 2018. Use InsertionMarkerManager. - * @param {!Blockly.BlockSvg} block The top block in the stack being dragged. - * @constructor - */ -Blockly.DraggedConnectionManager = function(block) { - Blockly.selected = block; - - /** - * The top block in the stack being dragged. - * Does not change during a drag. - * @type {!Blockly.Block} - * @private - */ - this.topBlock_ = block; - - /** - * The workspace on which these connections are being dragged. - * Does not change during a drag. - * @type {!Blockly.WorkspaceSvg} - * @private - */ - this.workspace_ = block.workspace; - - /** - * The connections on the dragging blocks that are available to connect to - * other blocks. This includes all open connections on the top block, - * as well as the last connection on the block stack. - * Does not change during a drag. - * @type {!Array.} - * @private - */ - this.availableConnections_ = this.initAvailableConnections_(); - - /** - * The connection that this block would connect to if released immediately. - * Updated on every mouse move. - * @type {Blockly.RenderedConnection} - * @private - */ - this.closestConnection_ = null; - - /** - * The connection that would connect to this.closestConnection_ if this block - * were released immediately. - * Updated on every mouse move. - * @type {Blockly.RenderedConnection} - * @private - */ - this.localConnection_ = null; - - /** - * The distance between this.closestConnection_ and this.localConnection_, - * in workspace units. - * Updated on every mouse move. - * @type {number} - * @private - */ - this.radiusConnection_ = 0; - - /** - * Whether the block would be deleted if it were dropped immediately. - * Updated on every mouse move. - * @type {boolean} - * @private - */ - this.wouldDeleteBlock_ = false; -}; - -/** - * Sever all links from this object. - * @package - */ -Blockly.DraggedConnectionManager.prototype.dispose = function() { - this.topBlock_ = null; - this.workspace_ = null; - this.availableConnections_.length = 0; - this.closestConnection_ = null; - this.localConnection_ = null; -}; - -/** - * Return whether the block would be deleted if dropped immediately, based on - * information from the most recent move event. - * @return {boolean} True if the block would be deleted if dropped immediately. - * @package - */ -Blockly.DraggedConnectionManager.prototype.wouldDeleteBlock = function() { - return this.wouldDeleteBlock_; -}; - -/** - * Return whether the block would be connected if dropped immediately, based on - * information from the most recent move event. - * @return {boolean} True if the block would be connected if dropped - * immediately. - * @package - */ -Blockly.DraggedConnectionManager.prototype.wouldConnectBlock = function() { - return !!this.closestConnection_; -}; - -/** - * Connect to the closest connection and render the results. - * This should be called at the end of a drag. - * @package - */ -Blockly.DraggedConnectionManager.prototype.applyConnections = function() { - if (this.closestConnection_) { - // Connect two blocks together. - this.localConnection_.connect(this.closestConnection_); - if (this.topBlock_.rendered) { - // Trigger a connection animation. - // Determine which connection is inferior (lower in the source stack). - var inferiorConnection = this.localConnection_.isSuperior() ? - this.closestConnection_ : this.localConnection_; - Blockly.blockAnimations.connectionUiEffect( - inferiorConnection.getSourceBlock()); - // Bring the just-edited stack to the front. - var rootBlock = this.topBlock_.getRootBlock(); - rootBlock.bringToFront(); - } - this.removeHighlighting_(); - } -}; - -/** - * Update highlighted connections based on the most recent move location. - * @param {!Blockly.utils.Coordinate} dxy Position relative to drag start, - * in workspace units. - * @param {?number} deleteArea One of {@link Blockly.DELETE_AREA_TRASH}, - * {@link Blockly.DELETE_AREA_TOOLBOX}, or {@link Blockly.DELETE_AREA_NONE}. - * @package - */ -Blockly.DraggedConnectionManager.prototype.update = function(dxy, deleteArea) { - var oldClosestConnection = this.closestConnection_; - var closestConnectionChanged = this.updateClosest_(dxy); - - if (closestConnectionChanged && oldClosestConnection) { - oldClosestConnection.unhighlight(); - } - - // Prefer connecting over dropping into the trash can, but prefer dragging to - // the toolbox over connecting to other blocks. - var wouldConnect = !!this.closestConnection_ && - deleteArea != Blockly.DELETE_AREA_TOOLBOX; - var wouldDelete = !!deleteArea && !this.topBlock_.getParent() && - this.topBlock_.isDeletable(); - this.wouldDeleteBlock_ = wouldDelete && !wouldConnect; - - // Get rid of highlighting so we don't sent mixed messages. - if (wouldDelete && this.closestConnection_) { - this.closestConnection_.unhighlight(); - this.closestConnection_ = null; - } - - if (!this.wouldDeleteBlock_ && closestConnectionChanged && - this.closestConnection_) { - this.addHighlighting_(); - } -}; - -/** - * Remove highlighting from the currently highlighted connection, if it exists. - * @private - */ -Blockly.DraggedConnectionManager.prototype.removeHighlighting_ = function() { - if (this.closestConnection_) { - this.closestConnection_.unhighlight(); - } -}; - -/** - * Add highlighting to the closest connection, if it exists. - * @private - */ -Blockly.DraggedConnectionManager.prototype.addHighlighting_ = function() { - if (this.closestConnection_) { - this.closestConnection_.highlight(); - } -}; - -/** - * Populate the list of available connections on this block stack. This should - * only be called once, at the beginning of a drag. - * @return {!Array.} A list of available - * connections. - * @private - */ -Blockly.DraggedConnectionManager.prototype.initAvailableConnections_ = function() { - var available = this.topBlock_.getConnections_(false); - // Also check the last connection on this stack - var lastOnStack = this.topBlock_.lastConnectionInStack(); - if (lastOnStack && lastOnStack != this.topBlock_.nextConnection) { - available.push(lastOnStack); - } - return available; -}; - -/** - * Find the new closest connection, and update internal state in response. - * @param {!Blockly.utils.Coordinate} dxy Position relative to the drag start, - * in workspace units. - * @return {boolean} Whether the closest connection has changed. - * @private - */ -Blockly.DraggedConnectionManager.prototype.updateClosest_ = function(dxy) { - var oldClosestConnection = this.closestConnection_; - - this.closestConnection_ = null; - this.localConnection_ = null; - this.radiusConnection_ = Blockly.SNAP_RADIUS; - for (var i = 0; i < this.availableConnections_.length; i++) { - var myConnection = this.availableConnections_[i]; - var neighbour = myConnection.closest(this.radiusConnection_, dxy); - if (neighbour.connection) { - this.closestConnection_ = neighbour.connection; - this.localConnection_ = myConnection; - this.radiusConnection_ = neighbour.radius; - } - } - return oldClosestConnection != this.closestConnection_; -}; diff --git a/core/field.js b/core/field.js index 6739e435e..e78d9d10e 100644 --- a/core/field.js +++ b/core/field.js @@ -668,7 +668,7 @@ Blockly.Field.prototype.getText = function() { * @deprecated 2019 setText should not be used directly. Use setValue instead. */ Blockly.Field.prototype.setText = function(_newText) { - throw new Error('setText method is deprecated'); + throw Error('setText method is deprecated'); }; /** diff --git a/core/generator.js b/core/generator.js index 4241e2440..5f33b5a89 100644 --- a/core/generator.js +++ b/core/generator.js @@ -194,7 +194,7 @@ Blockly.Generator.prototype.blockToCode = function(block, opt_thisOnly) { } // First argument to func.call is the value of 'this' in the generator. // Prior to 24 September 2013 'this' was the only way to access the block. - // The current prefered method of accessing the block is through the second + // The current preferred method of accessing the block is through the second // argument to func.call, which becomes the first parameter to the generator. var code = func.call(block, block); if (Array.isArray(code)) { diff --git a/core/inject.js b/core/inject.js index 4c5bd2eea..5885201bf 100644 --- a/core/inject.js +++ b/core/inject.js @@ -528,14 +528,3 @@ Blockly.inject.loadSounds_ = function(pathToMedia, workspace) { Blockly.bindEventWithChecks_(document, 'touchstart', null, unbindSounds, true)); }; - -/** - * Modify the block tree on the existing toolbox. - * @param {Node|string} tree DOM tree of blocks, or text representation of same. - * @deprecated April 2015 - */ -Blockly.updateToolbox = function(tree) { - console.warn('Deprecated call to Blockly.updateToolbox, ' + - 'use workspace.updateToolbox instead.'); - Blockly.getMainWorkspace().updateToolbox(tree); -}; diff --git a/core/keyboard_nav/ast_node.js b/core/keyboard_nav/ast_node.js index ff6ff1423..c48df37d5 100644 --- a/core/keyboard_nav/ast_node.js +++ b/core/keyboard_nav/ast_node.js @@ -32,7 +32,7 @@ goog.provide('Blockly.ASTNode'); * It is recommended that you use one of the createNode methods instead of * creating a node directly. * @constructor - * @param {!string} type The type of the location. + * @param {string} type The type of the location. * Must be in Bockly.ASTNode.types. * @param {Blockly.Block|Blockly.Connection|Blockly.Field|Blockly.Workspace} * location The position in the AST. diff --git a/core/keyboard_nav/key_map.js b/core/keyboard_nav/key_map.js index 6c6c40aee..c53d02291 100644 --- a/core/keyboard_nav/key_map.js +++ b/core/keyboard_nav/key_map.js @@ -50,7 +50,7 @@ Blockly.user.keyMap.modifierKeys = { /** * Update the key map to contain the new action. - * @param {!string} keyCode The key code serialized by the serializeKeyEvent. + * @param {string} keyCode The key code serialized by the serializeKeyEvent. * @param {!Blockly.Action} action The action to be executed when the keys * corresponding to the serialized key code is pressed. * @package @@ -116,7 +116,7 @@ Blockly.user.keyMap.getKeyByAction = function(action) { /** * Serialize the key event. * @param {!Event} e A key up event holding the key code. - * @return {!string} A string containing the serialized key event. + * @return {string} A string containing the serialized key event. */ Blockly.user.keyMap.serializeKeyEvent = function(e) { var modifiers = Blockly.utils.object.values(Blockly.user.keyMap.modifierKeys); @@ -132,8 +132,8 @@ Blockly.user.keyMap.serializeKeyEvent = function(e) { /** * Create the serialized key code that will be used in the key map. - * @param {!number} keyCode Number code representing the key. - * @param {!Array} modifiers List of modifiers to be used with the key. + * @param {number} keyCode Number code representing the key. + * @param {!Array.} modifiers List of modifiers to be used with the key. * All valid modifiers can be found in the Blockly.user.keyMap.modifierKeys. * @return {string} The serialized key code for the given modifiers and key. */ diff --git a/core/keyboard_nav/navigation.js b/core/keyboard_nav/navigation.js index 73969c15b..f2922f239 100644 --- a/core/keyboard_nav/navigation.js +++ b/core/keyboard_nav/navigation.js @@ -770,7 +770,7 @@ Blockly.navigation.moveCursorOnBlockMutation = function(mutatedBlock) { /** * Handler for all the keyboard navigation events. * @param {Event} e The keyboard event. - * @return {!boolean} True if the key was handled false otherwise. + * @return {boolean} True if the key was handled false otherwise. */ Blockly.navigation.onKeyPress = function(e) { var key = Blockly.user.keyMap.serializeKeyEvent(e); @@ -1070,7 +1070,7 @@ Blockly.navigation.ACTION_TOGGLE_KEYBOARD_NAV = new Blockly.Action( /** * List of actions that can be performed in read only mode. - * @type {!Array} + * @type {!Array.} */ Blockly.navigation.READONLY_ACTION_LIST = [ Blockly.navigation.ACTION_PREVIOUS, diff --git a/core/renderers/common/constants.js b/core/renderers/common/constants.js index c7039b632..f2dad7b80 100644 --- a/core/renderers/common/constants.js +++ b/core/renderers/common/constants.js @@ -373,6 +373,6 @@ Blockly.blockRendering.ConstantProvider.prototype.shapeFor = function( case Blockly.NEXT_STATEMENT: return this.NOTCH; default: - throw new Error('Unknown connection type'); + throw Error('Unknown connection type'); } }; diff --git a/core/renderers/zelos/constants.js b/core/renderers/zelos/constants.js index 7f77250e5..d9d34efcd 100644 --- a/core/renderers/zelos/constants.js +++ b/core/renderers/zelos/constants.js @@ -165,7 +165,7 @@ Blockly.zelos.ConstantProvider.prototype.shapeFor = function( case Blockly.NEXT_STATEMENT: return this.NOTCH; default: - throw new Error('Unknown type'); + throw Error('Unknown type'); } }; diff --git a/core/utils/aria.js b/core/utils/aria.js index 84b67b72a..08a55976d 100644 --- a/core/utils/aria.js +++ b/core/utils/aria.js @@ -448,7 +448,7 @@ Blockly.utils.aria.removeRole = function(element) { * @param {!(Blockly.utils.aria.State|string)} stateName State attribute being set. * Automatically adds prefix 'aria-' to the state name if the attribute is * not an extra attribute. - * @param {string|boolean|number|!Array} value Value + * @param {string|boolean|number|!Array.} value Value * for the state attribute. */ Blockly.utils.aria.setState = function(element, stateName, value) { diff --git a/demos/blockfactory/block_definition_extractor.js b/demos/blockfactory/block_definition_extractor.js index 05ab81d70..f684c75df 100644 --- a/demos/blockfactory/block_definition_extractor.js +++ b/demos/blockfactory/block_definition_extractor.js @@ -323,7 +323,7 @@ BlockDefinitionExtractor.input_ = function(input, align) { /** * Constructs a sequence elements representing the field definition. - * @param {Array} fieldRow A list of fields in a Blockly.Input. + * @param {Array.} fieldRow A list of fields in a Blockly.Input. * @return {Element} The fist element of the sequence * (and the root of the constructed DOM). * @private @@ -476,7 +476,7 @@ BlockDefinitionExtractor.buildFieldDropdown_ = function(dropdown) { } else if (Array.isArray(menuGenerator)) { var options = menuGenerator; } else { - throw new Error('Unrecognized type of menuGenerator: ' + menuGenerator); + throw Error('Unrecognized type of menuGenerator: ' + menuGenerator); } var fieldDropdown = BlockDefinitionExtractor.newDomElement_( @@ -600,7 +600,7 @@ BlockDefinitionExtractor.buildFieldImage_ = /** * Creates a element a group of allowed connection constraint types. * - * @param {Array} types List of type names in this group. + * @param {Array.} types List of type names in this group. * @return {Element} The element representing the group, with child * types attached. * @private diff --git a/demos/blockfactory/factory_utils.js b/demos/blockfactory/factory_utils.js index bfcd66b00..f222edf56 100644 --- a/demos/blockfactory/factory_utils.js +++ b/demos/blockfactory/factory_utils.js @@ -767,7 +767,7 @@ FactoryUtils.getBlockTypeFromJsDefinition = function(blockDef) { if (indexOfStartBracket != -1 && indexOfEndBracket != -1) { return blockDef.substring(indexOfStartBracket + 2, indexOfEndBracket); } else { - throw new Error ('Could not parse block type out of JavaScript block ' + + throw Error('Could not parse block type out of JavaScript block ' + 'definition. Brackets normally enclosing block type not found.'); } }; @@ -921,7 +921,7 @@ FactoryUtils.sameBlockXml = function(blockXml1, blockXml2) { // Each XML element should contain a single child element with a 'block' tag if (blockXml1.tagName.toLowerCase() != 'xml' || blockXml2.tagName.toLowerCase() != 'xml') { - throw new Error('Expected two XML elements, received elements with tag ' + + throw Error('Expected two XML elements, received elements with tag ' + 'names: ' + blockXml1.tagName + ' and ' + blockXml2.tagName + '.'); } @@ -931,7 +931,7 @@ FactoryUtils.sameBlockXml = function(blockXml1, blockXml2) { var blockElement2 = blockXml2.getElementsByTagName('block')[0]; if (!(blockElement1 && blockElement2)) { - throw new Error('Could not get find block element in XML.'); + throw Error('Could not get find block element in XML.'); } var cleanBlockXml1 = FactoryUtils.cleanXml(blockElement1); diff --git a/demos/blockfactory/workspacefactory/wfactory_controller.js b/demos/blockfactory/workspacefactory/wfactory_controller.js index 9f53cf1e3..bdfab3bed 100644 --- a/demos/blockfactory/workspacefactory/wfactory_controller.js +++ b/demos/blockfactory/workspacefactory/wfactory_controller.js @@ -340,7 +340,7 @@ WorkspaceFactoryController.prototype.exportXmlFile = function(exportMode) { // Unknown mode. Throw error. var msg = 'Unknown export mode: ' + exportMode; BlocklyDevTools.Analytics.onError(msg); - throw new Error(msg); + throw Error(msg); } // Unpack self-closing tags. These tags fail when embedded in HTML. @@ -760,7 +760,7 @@ WorkspaceFactoryController.prototype.importFile = function(file, importMode) { BlocklyDevTools.Analytics.onImport('WorkspaceContents.xml'); } else { // Throw error if invalid mode. - throw new Error('Unknown import mode: ' + importMode); + throw Error('Unknown import mode: ' + importMode); } } catch(e) { var msg = 'Cannot load XML from file.'; diff --git a/demos/blockfactory/workspacefactory/wfactory_generator.js b/demos/blockfactory/workspacefactory/wfactory_generator.js index 18578cd01..f2b2ca73c 100644 --- a/demos/blockfactory/workspacefactory/wfactory_generator.js +++ b/demos/blockfactory/workspacefactory/wfactory_generator.js @@ -71,7 +71,7 @@ WorkspaceFactoryGenerator.prototype.generateToolboxXml = function() { // Toolbox has categories. // Assert that selected != null if (!this.model.getSelected()) { - throw new Error('Selected is null when the toolbox is empty.'); + throw Error('Selected is null when the toolbox is empty.'); } var xml = this.model.getSelectedXml(); diff --git a/demos/blockfactory/workspacefactory/wfactory_model.js b/demos/blockfactory/workspacefactory/wfactory_model.js index d7f982d76..700d457ac 100644 --- a/demos/blockfactory/workspacefactory/wfactory_model.js +++ b/demos/blockfactory/workspacefactory/wfactory_model.js @@ -164,7 +164,7 @@ WorkspaceFactoryModel.prototype.moveElementToIndex = function(element, newIndex, // Check that indexes are in bounds. if (newIndex < 0 || newIndex >= this.toolboxList.length || oldIndex < 0 || oldIndex >= this.toolboxList.length) { - throw new Error('Index out of bounds when moving element in the model.'); + throw Error('Index out of bounds when moving element in the model.'); } this.deleteElementFromList(oldIndex); this.toolboxList.splice(newIndex, 0, element); diff --git a/demos/blockfactory/workspacefactory/wfactory_view.js b/demos/blockfactory/workspacefactory/wfactory_view.js index 7a33292a4..ec95ad6ad 100644 --- a/demos/blockfactory/workspacefactory/wfactory_view.js +++ b/demos/blockfactory/workspacefactory/wfactory_view.js @@ -201,7 +201,7 @@ WorkspaceFactoryView.prototype.moveTabToIndex = // Check that indexes are in bounds. if (newIndex < 0 || newIndex >= table.rows.length || oldIndex < 0 || oldIndex >= table.rows.length) { - throw new Error('Index out of bounds when moving tab in the view.'); + throw Error('Index out of bounds when moving tab in the view.'); } if (newIndex < oldIndex) { diff --git a/tests/jsunit/test_utilities.js b/tests/jsunit/test_utilities.js index 06944e54f..6c072097b 100644 --- a/tests/jsunit/test_utilities.js +++ b/tests/jsunit/test_utilities.js @@ -59,8 +59,8 @@ function isEqualArrays(array1, array2) { * the parameters if any exist. * @param {!Object} scope The scope of the method to be mocked out. * @param {!string} funcName The name of the function we're going to mock. - * @param {Array} parameters The parameters to call the mock with. - * @param {Array} return_values The values to return when called. + * @param {Array.} parameters The parameters to call the mock with. + * @param {Array.} return_values The values to return when called. * @return {!sinon.SinonStub} The stub method. */ function setUpMockMethod(scope, funcName, parameters, return_values) { diff --git a/tests/mocha/test_helpers.js b/tests/mocha/test_helpers.js index 022e7eadd..084967d0b 100644 --- a/tests/mocha/test_helpers.js +++ b/tests/mocha/test_helpers.js @@ -23,7 +23,7 @@ function _nonCommentArg(desiredNonCommentArgIndex, expectedNumberOfNonCommentArg function _validateArguments(expectedNumberOfNonCommentArgs, args) { if (!( args.length == expectedNumberOfNonCommentArgs || (args.length == expectedNumberOfNonCommentArgs + 1 && (typeof(args[0]) == 'string') || args[0] == null))) { - throw new Error('Incorrect arguments passed to assert function'); + throw Error('Incorrect arguments passed to assert function'); } } /** @@ -56,7 +56,7 @@ function assertTrue() { var commentArg = _commentArg(1, arguments); var booleanValue = _nonCommentArg(1, 1, arguments); if (typeof(booleanValue) != 'boolean') { - throw new Error('Bad argument to assertTrue(boolean)'); + throw Error('Bad argument to assertTrue(boolean)'); } chai.assert.isTrue(booleanValue, commentArg); @@ -71,7 +71,7 @@ function assertFalse() { var booleanValue = _nonCommentArg(1, 1, arguments); if (typeof(booleanValue) != 'boolean') { - throw new Error('Bad argument to assertFalse(boolean)'); + throw Error('Bad argument to assertFalse(boolean)'); } chai.assert.isNotTrue(booleanValue, commentArg); @@ -175,4 +175,3 @@ function defineStatementBlock() { "helpUrl": "" }]); } -