From 29c560dfbb225d702f95a30a9560baca65a4e457 Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Fri, 16 Jul 2021 14:26:36 -0700 Subject: [PATCH 1/5] Migrate core/connection_checker.js to ES6 const/let --- core/connection_checker.js | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/core/connection_checker.js b/core/connection_checker.js index 004d5e3f3..d0e4576c2 100644 --- a/core/connection_checker.js +++ b/core/connection_checker.js @@ -64,14 +64,14 @@ Blockly.ConnectionChecker.prototype.canConnect = function(a, b, */ Blockly.ConnectionChecker.prototype.canConnectWithReason = function( a, b, isDragging, opt_distance) { - var safety = this.doSafetyChecks(a, b); + const safety = this.doSafetyChecks(a, b); if (safety != Blockly.Connection.CAN_CONNECT) { return safety; } // If the safety checks passed, both connections are non-null. - var connOne = /** @type {!Blockly.Connection} **/ (a); - var connTwo = /** @type {!Blockly.Connection} **/ (b); + const connOne = /** @type {!Blockly.Connection} **/ (a); + const connTwo = /** @type {!Blockly.Connection} **/ (b); if (!this.doTypeChecks(connOne, connTwo)) { return Blockly.Connection.REASON_CHECKS_FAILED; } @@ -108,12 +108,13 @@ Blockly.ConnectionChecker.prototype.getErrorMessage = function(errorCode, return 'Attempt to connect incompatible types.'; case Blockly.Connection.REASON_TARGET_NULL: return 'Target connection is null.'; - case Blockly.Connection.REASON_CHECKS_FAILED: - var connOne = /** @type {!Blockly.Connection} **/ (a); - var connTwo = /** @type {!Blockly.Connection} **/ (b); - var msg = 'Connection checks failed. '; + case Blockly.Connection.REASON_CHECKS_FAILED: { + const connOne = /** @type {!Blockly.Connection} **/ (a); + const connTwo = /** @type {!Blockly.Connection} **/ (b); + let msg = 'Connection checks failed. '; msg += connOne + ' expected ' + connOne.getCheck() + ', found ' + connTwo.getCheck(); return msg; + } case Blockly.Connection.REASON_SHADOW_PARENT: return 'Connecting non-shadow to shadow block.'; case Blockly.Connection.REASON_DRAG_CHECKS_FAILED: @@ -135,12 +136,13 @@ Blockly.ConnectionChecker.prototype.doSafetyChecks = function(a, b) { if (!a || !b) { return Blockly.Connection.REASON_TARGET_NULL; } + let blockA, blockB; if (a.isSuperior()) { - var blockA = a.getSourceBlock(); - var blockB = b.getSourceBlock(); + blockA = a.getSourceBlock(); + blockB = b.getSourceBlock(); } else { - var blockB = a.getSourceBlock(); - var blockA = b.getSourceBlock(); + blockB = a.getSourceBlock(); + blockA = b.getSourceBlock(); } if (blockA == blockB) { return Blockly.Connection.REASON_SELF_CONNECTION; @@ -164,15 +166,15 @@ Blockly.ConnectionChecker.prototype.doSafetyChecks = function(a, b) { * @public */ Blockly.ConnectionChecker.prototype.doTypeChecks = function(a, b) { - var checkArrayOne = a.getCheck(); - var checkArrayTwo = b.getCheck(); + const checkArrayOne = a.getCheck(); + const checkArrayTwo = b.getCheck(); if (!checkArrayOne || !checkArrayTwo) { // One or both sides are promiscuous enough that anything will fit. return true; } // Find any intersection in the check lists. - for (var i = 0; i < checkArrayOne.length; i++) { + for (let i = 0; i < checkArrayOne.length; i++) { if (checkArrayTwo.indexOf(checkArrayOne[i]) != -1) { return true; } @@ -274,7 +276,7 @@ Blockly.ConnectionChecker.prototype.canConnectToPrevious_ = function(a, b) { return true; } - var targetBlock = b.targetBlock(); + const targetBlock = b.targetBlock(); // If it is connected to a real block, game over. if (!targetBlock.isInsertionMarker()) { return false; From 50793c20cb507eceb5385c4e9f298a8702824798 Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Fri, 16 Jul 2021 14:30:16 -0700 Subject: [PATCH 2/5] Migrate core/connection_checker.js to goog.module --- core/connection_checker.js | 23 +++++++++++++---------- tests/deps.js | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/core/connection_checker.js b/core/connection_checker.js index d0e4576c2..c4086a141 100644 --- a/core/connection_checker.js +++ b/core/connection_checker.js @@ -11,7 +11,8 @@ */ 'use strict'; -goog.provide('Blockly.ConnectionChecker'); +goog.module('Blockly.ConnectionChecker'); +goog.module.declareLegacyNamespace(); goog.require('Blockly.Connection'); goog.require('Blockly.connectionTypes'); @@ -28,7 +29,7 @@ goog.requireType('Blockly.RenderedConnection'); * @implements {Blockly.IConnectionChecker} * @constructor */ -Blockly.ConnectionChecker = function() { +const ConnectionChecker = function() { }; /** @@ -43,7 +44,7 @@ Blockly.ConnectionChecker = function() { * @return {boolean} Whether the connection is legal. * @public */ -Blockly.ConnectionChecker.prototype.canConnect = function(a, b, +ConnectionChecker.prototype.canConnect = function(a, b, isDragging, opt_distance) { return this.canConnectWithReason(a, b, isDragging, opt_distance) == Blockly.Connection.CAN_CONNECT; @@ -62,7 +63,7 @@ Blockly.ConnectionChecker.prototype.canConnect = function(a, b, * an error code otherwise. * @public */ -Blockly.ConnectionChecker.prototype.canConnectWithReason = function( +ConnectionChecker.prototype.canConnectWithReason = function( a, b, isDragging, opt_distance) { const safety = this.doSafetyChecks(a, b); if (safety != Blockly.Connection.CAN_CONNECT) { @@ -96,7 +97,7 @@ Blockly.ConnectionChecker.prototype.canConnectWithReason = function( * @return {string} A developer-readable error string. * @public */ -Blockly.ConnectionChecker.prototype.getErrorMessage = function(errorCode, +ConnectionChecker.prototype.getErrorMessage = function(errorCode, a, b) { switch (errorCode) { case Blockly.Connection.REASON_SELF_CONNECTION: @@ -132,7 +133,7 @@ Blockly.ConnectionChecker.prototype.getErrorMessage = function(errorCode, * @return {number} An enum with the reason this connection is safe or unsafe. * @public */ -Blockly.ConnectionChecker.prototype.doSafetyChecks = function(a, b) { +ConnectionChecker.prototype.doSafetyChecks = function(a, b) { if (!a || !b) { return Blockly.Connection.REASON_TARGET_NULL; } @@ -165,7 +166,7 @@ Blockly.ConnectionChecker.prototype.doSafetyChecks = function(a, b) { * @return {boolean} True if the connections share a type. * @public */ -Blockly.ConnectionChecker.prototype.doTypeChecks = function(a, b) { +ConnectionChecker.prototype.doTypeChecks = function(a, b) { const checkArrayOne = a.getCheck(); const checkArrayTwo = b.getCheck(); @@ -191,7 +192,7 @@ Blockly.ConnectionChecker.prototype.doTypeChecks = function(a, b) { * @return {boolean} True if the connection is allowed during a drag. * @public */ -Blockly.ConnectionChecker.prototype.doDragChecks = function(a, b, distance) { +ConnectionChecker.prototype.doDragChecks = function(a, b, distance) { if (a.distanceFrom(b) > distance) { return false; } @@ -260,7 +261,7 @@ Blockly.ConnectionChecker.prototype.doDragChecks = function(a, b, distance) { * @return {boolean} True if the connection is allowed, false otherwise. * @protected */ -Blockly.ConnectionChecker.prototype.canConnectToPrevious_ = function(a, b) { +ConnectionChecker.prototype.canConnectToPrevious_ = function(a, b) { if (a.targetConnection) { // This connection is already occupied. // A next connection will never disconnect itself mid-drag. @@ -288,4 +289,6 @@ Blockly.ConnectionChecker.prototype.canConnectToPrevious_ = function(a, b) { }; Blockly.registry.register(Blockly.registry.Type.CONNECTION_CHECKER, - Blockly.registry.DEFAULT, Blockly.ConnectionChecker); + Blockly.registry.DEFAULT, ConnectionChecker); + +exports = ConnectionChecker; diff --git a/tests/deps.js b/tests/deps.js index 5f5f93d89..328c3bee3 100644 --- a/tests/deps.js +++ b/tests/deps.js @@ -20,7 +20,7 @@ goog.addDependency('../../core/bubble_dragger.js', ['Blockly.BubbleDragger'], [' goog.addDependency('../../core/comment.js', ['Blockly.Comment'], ['Blockly.Bubble', 'Blockly.Css', 'Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.Events.BubbleOpen', 'Blockly.Icon', 'Blockly.Warning', 'Blockly.browserEvents', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.userAgent']); goog.addDependency('../../core/component_manager.js', ['Blockly.ComponentManager'], [], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/connection.js', ['Blockly.Connection'], ['Blockly.Events', 'Blockly.Events.BlockMove', 'Blockly.IASTNodeLocationWithBlock', 'Blockly.Xml', 'Blockly.connectionTypes', 'Blockly.constants', 'Blockly.utils.deprecation']); -goog.addDependency('../../core/connection_checker.js', ['Blockly.ConnectionChecker'], ['Blockly.Connection', 'Blockly.IConnectionChecker', 'Blockly.connectionTypes', 'Blockly.constants', 'Blockly.registry']); +goog.addDependency('../../core/connection_checker.js', ['Blockly.ConnectionChecker'], ['Blockly.Connection', 'Blockly.IConnectionChecker', 'Blockly.connectionTypes', 'Blockly.constants', 'Blockly.registry'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/connection_db.js', ['Blockly.ConnectionDB'], ['Blockly.RenderedConnection', 'Blockly.connectionTypes', 'Blockly.constants']); goog.addDependency('../../core/connection_types.js', ['Blockly.connectionTypes'], [], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/constants.js', ['Blockly.constants'], ['Blockly.connectionTypes']); From e23560343ed0d9ab3fc80ae4bd908fd23e12d576 Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Fri, 16 Jul 2021 14:45:35 -0700 Subject: [PATCH 3/5] Migrate core/connection_checker.js to named requires --- core/connection_checker.js | 103 ++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 52 deletions(-) diff --git a/core/connection_checker.js b/core/connection_checker.js index c4086a141..4c350fc9c 100644 --- a/core/connection_checker.js +++ b/core/connection_checker.js @@ -14,19 +14,18 @@ goog.module('Blockly.ConnectionChecker'); goog.module.declareLegacyNamespace(); -goog.require('Blockly.Connection'); -goog.require('Blockly.connectionTypes'); +const Connection = goog.require('Blockly.Connection'); +const connectionTypes = goog.require('Blockly.connectionTypes'); +const IConnectionChecker = goog.require('Blockly.IConnectionChecker'); +const registry = goog.require('Blockly.registry'); +const RenderedConnection = goog.requireType('Blockly.RenderedConnection'); /** @suppress {extraRequire} */ goog.require('Blockly.constants'); -goog.require('Blockly.IConnectionChecker'); -goog.require('Blockly.registry'); - -goog.requireType('Blockly.RenderedConnection'); /** * Class for connection type checking logic. - * @implements {Blockly.IConnectionChecker} + * @implements {IConnectionChecker} * @constructor */ const ConnectionChecker = function() { @@ -35,8 +34,8 @@ const ConnectionChecker = function() { /** * Check whether the current connection can connect with the target * connection. - * @param {Blockly.Connection} a Connection to check compatibility with. - * @param {Blockly.Connection} b Connection to check compatibility with. + * @param {Connection} a Connection to check compatibility with. + * @param {Connection} b Connection to check compatibility with. * @param {boolean} isDragging True if the connection is being made by dragging * a block. * @param {number=} opt_distance The max allowable distance between the @@ -47,52 +46,52 @@ const ConnectionChecker = function() { ConnectionChecker.prototype.canConnect = function(a, b, isDragging, opt_distance) { return this.canConnectWithReason(a, b, isDragging, opt_distance) == - Blockly.Connection.CAN_CONNECT; + Connection.CAN_CONNECT; }; /** * Checks whether the current connection can connect with the target * connection, and return an error code if there are problems. - * @param {Blockly.Connection} a Connection to check compatibility with. - * @param {Blockly.Connection} b Connection to check compatibility with. + * @param {Connection} a Connection to check compatibility with. + * @param {Connection} b Connection to check compatibility with. * @param {boolean} isDragging True if the connection is being made by dragging * a block. * @param {number=} opt_distance The max allowable distance between the * connections for drag checks. - * @return {number} Blockly.Connection.CAN_CONNECT if the connection is legal, + * @return {number} Connection.CAN_CONNECT if the connection is legal, * an error code otherwise. * @public */ ConnectionChecker.prototype.canConnectWithReason = function( a, b, isDragging, opt_distance) { const safety = this.doSafetyChecks(a, b); - if (safety != Blockly.Connection.CAN_CONNECT) { + if (safety != Connection.CAN_CONNECT) { return safety; } // If the safety checks passed, both connections are non-null. - const connOne = /** @type {!Blockly.Connection} **/ (a); - const connTwo = /** @type {!Blockly.Connection} **/ (b); + const connOne = /** @type {!Connection} **/ (a); + const connTwo = /** @type {!Connection} **/ (b); if (!this.doTypeChecks(connOne, connTwo)) { - return Blockly.Connection.REASON_CHECKS_FAILED; + return Connection.REASON_CHECKS_FAILED; } if (isDragging && !this.doDragChecks( - /** @type {!Blockly.RenderedConnection} **/ (a), - /** @type {!Blockly.RenderedConnection} **/ (b), + /** @type {!RenderedConnection} **/ (a), + /** @type {!RenderedConnection} **/ (b), opt_distance || 0)) { - return Blockly.Connection.REASON_DRAG_CHECKS_FAILED; + return Connection.REASON_DRAG_CHECKS_FAILED; } - return Blockly.Connection.CAN_CONNECT; + return Connection.CAN_CONNECT; }; /** * Helper method that translates a connection error code into a string. * @param {number} errorCode The error code. - * @param {Blockly.Connection} a One of the two connections being checked. - * @param {Blockly.Connection} b The second of the two connections being + * @param {Connection} a One of the two connections being checked. + * @param {Connection} b The second of the two connections being * checked. * @return {string} A developer-readable error string. * @public @@ -100,25 +99,25 @@ ConnectionChecker.prototype.canConnectWithReason = function( ConnectionChecker.prototype.getErrorMessage = function(errorCode, a, b) { switch (errorCode) { - case Blockly.Connection.REASON_SELF_CONNECTION: + case Connection.REASON_SELF_CONNECTION: return 'Attempted to connect a block to itself.'; - case Blockly.Connection.REASON_DIFFERENT_WORKSPACES: + case Connection.REASON_DIFFERENT_WORKSPACES: // Usually this means one block has been deleted. return 'Blocks not on same workspace.'; - case Blockly.Connection.REASON_WRONG_TYPE: + case Connection.REASON_WRONG_TYPE: return 'Attempt to connect incompatible types.'; - case Blockly.Connection.REASON_TARGET_NULL: + case Connection.REASON_TARGET_NULL: return 'Target connection is null.'; - case Blockly.Connection.REASON_CHECKS_FAILED: { - const connOne = /** @type {!Blockly.Connection} **/ (a); - const connTwo = /** @type {!Blockly.Connection} **/ (b); + case Connection.REASON_CHECKS_FAILED: { + const connOne = /** @type {!Connection} **/ (a); + const connTwo = /** @type {!Connection} **/ (b); let msg = 'Connection checks failed. '; msg += connOne + ' expected ' + connOne.getCheck() + ', found ' + connTwo.getCheck(); return msg; } - case Blockly.Connection.REASON_SHADOW_PARENT: + case Connection.REASON_SHADOW_PARENT: return 'Connecting non-shadow to shadow block.'; - case Blockly.Connection.REASON_DRAG_CHECKS_FAILED: + case Connection.REASON_DRAG_CHECKS_FAILED: return 'Drag checks failed.'; default: return 'Unknown connection failure: this should never happen!'; @@ -128,14 +127,14 @@ ConnectionChecker.prototype.getErrorMessage = function(errorCode, /** * Check that connecting the given connections is safe, meaning that it would * not break any of Blockly's basic assumptions (e.g. no self connections). - * @param {Blockly.Connection} a The first of the connections to check. - * @param {Blockly.Connection} b The second of the connections to check. + * @param {Connection} a The first of the connections to check. + * @param {Connection} b The second of the connections to check. * @return {number} An enum with the reason this connection is safe or unsafe. * @public */ ConnectionChecker.prototype.doSafetyChecks = function(a, b) { if (!a || !b) { - return Blockly.Connection.REASON_TARGET_NULL; + return Connection.REASON_TARGET_NULL; } let blockA, blockB; if (a.isSuperior()) { @@ -146,23 +145,23 @@ ConnectionChecker.prototype.doSafetyChecks = function(a, b) { blockA = b.getSourceBlock(); } if (blockA == blockB) { - return Blockly.Connection.REASON_SELF_CONNECTION; + return Connection.REASON_SELF_CONNECTION; } else if (b.type != Blockly.OPPOSITE_TYPE[a.type]) { - return Blockly.Connection.REASON_WRONG_TYPE; + return Connection.REASON_WRONG_TYPE; } else if (blockA.workspace !== blockB.workspace) { - return Blockly.Connection.REASON_DIFFERENT_WORKSPACES; + return Connection.REASON_DIFFERENT_WORKSPACES; } else if (blockA.isShadow() && !blockB.isShadow()) { - return Blockly.Connection.REASON_SHADOW_PARENT; + return Connection.REASON_SHADOW_PARENT; } - return Blockly.Connection.CAN_CONNECT; + return Connection.CAN_CONNECT; }; /** * Check whether this connection is compatible with another connection with * respect to the value type system. E.g. square_root("Hello") is not * compatible. - * @param {!Blockly.Connection} a Connection to compare. - * @param {!Blockly.Connection} b Connection to compare against. + * @param {!Connection} a Connection to compare. + * @param {!Connection} b Connection to compare against. * @return {boolean} True if the connections share a type. * @public */ @@ -186,8 +185,8 @@ ConnectionChecker.prototype.doTypeChecks = function(a, b) { /** * Check whether this connection can be made by dragging. - * @param {!Blockly.RenderedConnection} a Connection to compare. - * @param {!Blockly.RenderedConnection} b Connection to compare against. + * @param {!RenderedConnection} a Connection to compare. + * @param {!RenderedConnection} b Connection to compare against. * @param {number} distance The maximum allowable distance between connections. * @return {boolean} True if the connection is allowed during a drag. * @public @@ -203,9 +202,9 @@ ConnectionChecker.prototype.doDragChecks = function(a, b, distance) { } switch (b.type) { - case Blockly.connectionTypes.PREVIOUS_STATEMENT: + case connectionTypes.PREVIOUS_STATEMENT: return this.canConnectToPrevious_(a, b); - case Blockly.connectionTypes.OUTPUT_VALUE: { + case connectionTypes.OUTPUT_VALUE: { // Don't offer to connect an already connected left (male) value plug to // an available right (female) value plug. if ((b.isConnected() && @@ -215,7 +214,7 @@ ConnectionChecker.prototype.doDragChecks = function(a, b, distance) { } break; } - case Blockly.connectionTypes.INPUT_VALUE: { + case connectionTypes.INPUT_VALUE: { // Offering to connect the left (male) of a value block to an already // connected value pair is ok, we'll splice it in. // However, don't offer to splice into an immovable block. @@ -226,7 +225,7 @@ ConnectionChecker.prototype.doDragChecks = function(a, b, distance) { } break; } - case Blockly.connectionTypes.NEXT_STATEMENT: { + case connectionTypes.NEXT_STATEMENT: { // Don't let a block with no next connection bump other blocks out of the // stack. But covering up a shadow block or stack of shadow blocks is // fine. Similarly, replacing a terminal statement with another terminal @@ -254,9 +253,9 @@ ConnectionChecker.prototype.doDragChecks = function(a, b, distance) { /** * Helper function for drag checking. - * @param {!Blockly.Connection} a The connection to check, which must be a + * @param {!Connection} a The connection to check, which must be a * statement input or next connection. - * @param {!Blockly.Connection} b A nearby connection to check, which + * @param {!Connection} b A nearby connection to check, which * must be a previous connection. * @return {boolean} True if the connection is allowed, false otherwise. * @protected @@ -288,7 +287,7 @@ ConnectionChecker.prototype.canConnectToPrevious_ = function(a, b) { return !targetBlock.getPreviousBlock(); }; -Blockly.registry.register(Blockly.registry.Type.CONNECTION_CHECKER, - Blockly.registry.DEFAULT, ConnectionChecker); +registry.register(registry.Type.CONNECTION_CHECKER, + registry.DEFAULT, ConnectionChecker); exports = ConnectionChecker; From 5b9505802e4aea4e403cb1ef4fcc1adbd6a92f67 Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Fri, 16 Jul 2021 14:46:07 -0700 Subject: [PATCH 4/5] clang-format core/connection_checker.js --- core/connection_checker.js | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/core/connection_checker.js b/core/connection_checker.js index 4c350fc9c..3a405edcb 100644 --- a/core/connection_checker.js +++ b/core/connection_checker.js @@ -5,8 +5,8 @@ */ /** - * @fileoverview An object that encapsulates logic for checking whether a potential - * connection is safe and valid. + * @fileoverview An object that encapsulates logic for checking whether a + * potential connection is safe and valid. * @author fenichel@google.com (Rachel Fenichel) */ 'use strict'; @@ -28,8 +28,7 @@ goog.require('Blockly.constants'); * @implements {IConnectionChecker} * @constructor */ -const ConnectionChecker = function() { -}; +const ConnectionChecker = function() {}; /** * Check whether the current connection can connect with the target @@ -43,8 +42,8 @@ const ConnectionChecker = function() { * @return {boolean} Whether the connection is legal. * @public */ -ConnectionChecker.prototype.canConnect = function(a, b, - isDragging, opt_distance) { +ConnectionChecker.prototype.canConnect = function( + a, b, isDragging, opt_distance) { return this.canConnectWithReason(a, b, isDragging, opt_distance) == Connection.CAN_CONNECT; }; @@ -79,8 +78,7 @@ ConnectionChecker.prototype.canConnectWithReason = function( if (isDragging && !this.doDragChecks( /** @type {!RenderedConnection} **/ (a), - /** @type {!RenderedConnection} **/ (b), - opt_distance || 0)) { + /** @type {!RenderedConnection} **/ (b), opt_distance || 0)) { return Connection.REASON_DRAG_CHECKS_FAILED; } @@ -96,8 +94,7 @@ ConnectionChecker.prototype.canConnectWithReason = function( * @return {string} A developer-readable error string. * @public */ -ConnectionChecker.prototype.getErrorMessage = function(errorCode, - a, b) { +ConnectionChecker.prototype.getErrorMessage = function(errorCode, a, b) { switch (errorCode) { case Connection.REASON_SELF_CONNECTION: return 'Attempted to connect a block to itself.'; @@ -112,7 +109,8 @@ ConnectionChecker.prototype.getErrorMessage = function(errorCode, const connOne = /** @type {!Connection} **/ (a); const connTwo = /** @type {!Connection} **/ (b); let msg = 'Connection checks failed. '; - msg += connOne + ' expected ' + connOne.getCheck() + ', found ' + connTwo.getCheck(); + msg += connOne + ' expected ' + connOne.getCheck() + ', found ' + + connTwo.getCheck(); return msg; } case Connection.REASON_SHADOW_PARENT: @@ -207,8 +205,7 @@ ConnectionChecker.prototype.doDragChecks = function(a, b, distance) { case connectionTypes.OUTPUT_VALUE: { // Don't offer to connect an already connected left (male) value plug to // an available right (female) value plug. - if ((b.isConnected() && - !b.targetBlock().isInsertionMarker()) || + if ((b.isConnected() && !b.targetBlock().isInsertionMarker()) || a.isConnected()) { return false; } @@ -218,8 +215,7 @@ ConnectionChecker.prototype.doDragChecks = function(a, b, distance) { // Offering to connect the left (male) of a value block to an already // connected value pair is ok, we'll splice it in. // However, don't offer to splice into an immovable block. - if (b.isConnected() && - !b.targetBlock().isMovable() && + if (b.isConnected() && !b.targetBlock().isMovable() && !b.targetBlock().isShadow()) { return false; } @@ -230,10 +226,8 @@ ConnectionChecker.prototype.doDragChecks = function(a, b, distance) { // stack. But covering up a shadow block or stack of shadow blocks is // fine. Similarly, replacing a terminal statement with another terminal // statement is allowed. - if (b.isConnected() && - !a.getSourceBlock().nextConnection && - !b.targetBlock().isShadow() && - b.targetBlock().nextConnection) { + if (b.isConnected() && !a.getSourceBlock().nextConnection && + !b.targetBlock().isShadow() && b.targetBlock().nextConnection) { return false; } break; @@ -287,7 +281,7 @@ ConnectionChecker.prototype.canConnectToPrevious_ = function(a, b) { return !targetBlock.getPreviousBlock(); }; -registry.register(registry.Type.CONNECTION_CHECKER, - registry.DEFAULT, ConnectionChecker); +registry.register( + registry.Type.CONNECTION_CHECKER, registry.DEFAULT, ConnectionChecker); exports = ConnectionChecker; From bbdf5730f6aec7af34be3582d80e39e088ba61b8 Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Mon, 19 Jul 2021 08:10:47 -0700 Subject: [PATCH 5/5] Reordered core/connection_checker.js requires --- core/connection_checker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/connection_checker.js b/core/connection_checker.js index 3a405edcb..4bd7bd4e2 100644 --- a/core/connection_checker.js +++ b/core/connection_checker.js @@ -15,10 +15,10 @@ goog.module('Blockly.ConnectionChecker'); goog.module.declareLegacyNamespace(); const Connection = goog.require('Blockly.Connection'); -const connectionTypes = goog.require('Blockly.connectionTypes'); const IConnectionChecker = goog.require('Blockly.IConnectionChecker'); -const registry = goog.require('Blockly.registry'); const RenderedConnection = goog.requireType('Blockly.RenderedConnection'); +const connectionTypes = goog.require('Blockly.connectionTypes'); +const registry = goog.require('Blockly.registry'); /** @suppress {extraRequire} */ goog.require('Blockly.constants');