From d387841db2c16e183a71b9906e831d26b15a2682 Mon Sep 17 00:00:00 2001 From: Sam El-Husseini Date: Thu, 24 Oct 2019 19:13:51 -0400 Subject: [PATCH] Resolve remaining compiler warnings with visibility issues (#3335) --- core/block.js | 4 ++-- core/block_dragger.js | 2 +- core/block_svg.js | 8 ++++---- core/blockly.js | 4 ++-- core/contextmenu.js | 6 +++--- core/gesture.js | 2 +- core/touch.js | 4 ++-- core/workspace.js | 19 +++++++++++++++++++ core/workspace_comment_svg.js | 4 ++-- 9 files changed, 36 insertions(+), 17 deletions(-) diff --git a/core/block.js b/core/block.js index 15f106d3d..dd44dce1d 100644 --- a/core/block.js +++ b/core/block.js @@ -63,7 +63,7 @@ Blockly.Block = function(workspace, prototypeName, opt_id) { /** @type {string} */ this.id = (opt_id && !workspace.getBlockById(opt_id)) ? opt_id : Blockly.utils.genUid(); - workspace.blockDB_[this.id] = this; + workspace.setBlockById(this.id, this); /** @type {Blockly.Connection} */ this.outputConnection = null; /** @type {Blockly.Connection} */ @@ -343,7 +343,7 @@ Blockly.Block.prototype.dispose = function(healStack) { this.workspace.removeTopBlock(this); this.workspace.removeTypedBlock(this); // Remove from block database. - delete this.workspace.blockDB_[this.id]; + this.workspace.removeBlockById(this.id); this.workspace = null; } diff --git a/core/block_dragger.js b/core/block_dragger.js index 2eb62a60d..9e881c6b3 100644 --- a/core/block_dragger.js +++ b/core/block_dragger.js @@ -178,7 +178,7 @@ Blockly.BlockDragger.prototype.startBlockDrag = function(currentDragDeltaXY, // For future consideration: we may be able to put moveToDragSurface inside // the block dragger, which would also let the block not track the block drag // surface. - this.draggingBlock_.moveToDragSurface_(); + this.draggingBlock_.moveToDragSurface(); var toolbox = this.workspace_.getToolbox(); if (toolbox) { diff --git a/core/block_svg.js b/core/block_svg.js index 06bf90cd7..7119d7d23 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -485,9 +485,9 @@ Blockly.BlockSvg.prototype.translate = function(x, y) { * Move this block to its workspace's drag surface, accounting for positioning. * Generally should be called at the same time as setDragging_(true). * Does nothing if useDragSurface_ is false. - * @private + * @package */ -Blockly.BlockSvg.prototype.moveToDragSurface_ = function() { +Blockly.BlockSvg.prototype.moveToDragSurface = function() { if (!this.useDragSurface_) { return; } @@ -757,9 +757,9 @@ Blockly.BlockSvg.prototype.onMouseDown_ = function(e) { /** * Load the block's help page in a new window. - * @private + * @package */ -Blockly.BlockSvg.prototype.showHelp_ = function() { +Blockly.BlockSvg.prototype.showHelp = function() { var url = (typeof this.helpUrl == 'function') ? this.helpUrl() : this.helpUrl; if (url) { window.open(url); diff --git a/core/blockly.js b/core/blockly.js index e37078bb5..02966ed09 100644 --- a/core/blockly.js +++ b/core/blockly.js @@ -303,9 +303,9 @@ Blockly.copy_ = function(toCopy) { * Duplicate this block and its children, or a workspace comment. * @param {!Blockly.Block | !Blockly.WorkspaceComment} toDuplicate Block or * Workspace Comment to be copied. - * @private + * @package */ -Blockly.duplicate_ = function(toDuplicate) { +Blockly.duplicate = function(toDuplicate) { // Save the clipboard. var clipboardXml = Blockly.clipboardXml_; var clipboardSource = Blockly.clipboardSource_; diff --git a/core/contextmenu.js b/core/contextmenu.js index e1eee486b..10330e9ff 100644 --- a/core/contextmenu.js +++ b/core/contextmenu.js @@ -243,7 +243,7 @@ Blockly.ContextMenu.blockHelpOption = function(block) { enabled: !!url, text: Blockly.Msg['HELP'], callback: function() { - block.showHelp_(); + block.showHelp(); } }; return helpOption; @@ -261,7 +261,7 @@ Blockly.ContextMenu.blockDuplicateOption = function(block) { text: Blockly.Msg['DUPLICATE_BLOCK'], enabled: enabled, callback: function() { - Blockly.duplicate_(block); + Blockly.duplicate(block); } }; return duplicateOption; @@ -330,7 +330,7 @@ Blockly.ContextMenu.commentDuplicateOption = function(comment) { text: Blockly.Msg.DUPLICATE_COMMENT, enabled: true, callback: function() { - Blockly.duplicate_(comment); + Blockly.duplicate(comment); } }; return duplicateOption; diff --git a/core/gesture.js b/core/gesture.js index e7efa7fd9..ade6a2c86 100644 --- a/core/gesture.js +++ b/core/gesture.js @@ -509,7 +509,7 @@ Blockly.Gesture.prototype.doStart = function(e) { if ((e.type.toLowerCase() == 'touchstart' || e.type.toLowerCase() == 'pointerdown') && e.pointerType != 'mouse') { - Blockly.longStart_(e, this); + Blockly.longStart(e, this); } this.mouseDownXY_ = new Blockly.utils.Coordinate(e.clientX, e.clientY); diff --git a/core/touch.js b/core/touch.js index 7e6d097ea..2c5094ae6 100644 --- a/core/touch.js +++ b/core/touch.js @@ -92,9 +92,9 @@ Blockly.longPid_ = 0; * if the touch event terminates early. * @param {!Event} e Touch start event. * @param {Blockly.Gesture} gesture The gesture that triggered this longStart. - * @private + * @package */ -Blockly.longStart_ = function(e, gesture) { +Blockly.longStart = function(e, gesture) { Blockly.longStop_(); // Punt on multitouch events. if (e.changedTouches && e.changedTouches.length != 1) { diff --git a/core/workspace.js b/core/workspace.js index 10d5b11ab..59a5e845a 100644 --- a/core/workspace.js +++ b/core/workspace.js @@ -793,6 +793,25 @@ Blockly.Workspace.prototype.getBlockById = function(id) { return this.blockDB_[id] || null; }; +/** + * Set a block on this workspace with the specified ID. + * @param {string} id ID of block to set. + * @param {Blockly.Block} block The block to set. + * @package + */ +Blockly.Workspace.prototype.setBlockById = function(id, block) { + this.blockDB_[id] = block; +}; + +/** + * Delete a block off this workspace with the specified ID. + * @param {string} id ID of block to delete. + * @package + */ +Blockly.Workspace.prototype.removeBlockById = function(id) { + delete this.blockDB_[id]; +}; + /** * Find the comment on this workspace with the specified ID. * @param {string} id ID of comment to find. diff --git a/core/workspace_comment_svg.js b/core/workspace_comment_svg.js index c0382740c..7b9c41268 100644 --- a/core/workspace_comment_svg.js +++ b/core/workspace_comment_svg.js @@ -343,9 +343,9 @@ Blockly.WorkspaceCommentSvg.prototype.translate = function(x, y) { * Move this comment to its workspace's drag surface, accounting for * positioning. Generally should be called at the same time as * setDragging(true). Does nothing if useDragSurface_ is false. - * @private + * @package */ -Blockly.WorkspaceCommentSvg.prototype.moveToDragSurface_ = function() { +Blockly.WorkspaceCommentSvg.prototype.moveToDragSurface = function() { if (!this.useDragSurface_) { return; }