From b1a595774b980365b6c8948d5e212174c7cea197 Mon Sep 17 00:00:00 2001 From: alschmiedt Date: Mon, 15 Nov 2021 17:09:54 -0800 Subject: [PATCH] chore: removes deprecated connection functions --- core/connection.js | 83 ---------------------------------- core/rendered_connection.js | 23 ---------- tests/deps.js | 4 +- tests/deps.mocha.js | 4 +- tests/mocha/connection_test.js | 42 ----------------- 5 files changed, 4 insertions(+), 152 deletions(-) diff --git a/core/connection.js b/core/connection.js index bd8fef43bde..7a694521779 100644 --- a/core/connection.js +++ b/core/connection.js @@ -17,7 +17,6 @@ goog.module('Blockly.Connection'); const Xml = goog.require('Blockly.Xml'); const blocks = goog.require('Blockly.serialization.blocks'); -const deprecation = goog.require('Blockly.utils.deprecation'); const eventUtils = goog.require('Blockly.Events.utils'); /* eslint-disable-next-line no-unused-vars */ const {Block} = goog.requireType('Blockly.Block'); @@ -209,42 +208,6 @@ Connection.prototype.isConnected = function() { return !!this.targetConnection; }; -/** - * Checks whether the current connection can connect with the target - * connection. - * @param {Connection} target Connection to check compatibility with. - * @return {number} Connection.CAN_CONNECT if the connection is legal, - * an error code otherwise. - * @deprecated July 2020. Will be deleted July 2021. Use the workspace's - * connectionChecker instead. - */ -Connection.prototype.canConnectWithReason = function(target) { - deprecation.warn( - 'Connection.prototype.canConnectWithReason', 'July 2020', 'July 2021', - 'the workspace\'s connection checker'); - return this.getConnectionChecker().canConnectWithReason(this, target, false); -}; - -/** - * Checks whether the current connection and target connection are compatible - * and throws an exception if they are not. - * @param {Connection} target The connection to check compatibility - * with. - * @package - * @deprecated July 2020. Will be deleted July 2021. Use the workspace's - * connectionChecker instead. - */ -Connection.prototype.checkConnection = function(target) { - deprecation.warn( - 'Connection.prototype.checkConnection', 'July 2020', 'July 2021', - 'the workspace\'s connection checker'); - const checker = this.getConnectionChecker(); - const reason = checker.canConnectWithReason(this, target, false); - if (reason !== Connection.CAN_CONNECT) { - throw new Error(checker.getErrorMessage(reason, this, target)); - } -}; - /** * Get the workspace's connection type checker object. * @return {!IConnectionChecker} The connection type checker for the @@ -255,20 +218,6 @@ Connection.prototype.getConnectionChecker = function() { return this.sourceBlock_.workspace.connectionChecker; }; -/** - * Check if the two connections can be dragged to connect to each other. - * @param {!Connection} candidate A nearby connection to check. - * @return {boolean} True if the connection is allowed, false otherwise. - * @deprecated July 2020. Will be deleted July 2021. Use the workspace's - * connectionChecker instead. - */ -Connection.prototype.isConnectionAllowed = function(candidate) { - deprecation.warn( - 'Connection.prototype.isConnectionAllowed', 'July 2020', 'July 2021', - 'the workspace\'s connection checker'); - return this.getConnectionChecker().canConnect(this, candidate, true); -}; - /** * Called when an attempted connection fails. NOP by default (i.e. for headless * workspaces). @@ -484,38 +433,6 @@ Connection.prototype.targetBlock = function() { return null; }; -/** - * Is this connection compatible with another connection with respect to the - * value type system. E.g. square_root("Hello") is not compatible. - * @param {!Connection} otherConnection Connection to compare against. - * @return {boolean} True if the connections share a type. - * @deprecated July 2020. Will be deleted July 2021. Use the workspace's - * connectionChecker instead. - */ -Connection.prototype.checkType = function(otherConnection) { - deprecation.warn( - 'Connection.prototype.checkType', 'October 2019', 'January 2021', - 'the workspace\'s connection checker'); - return this.getConnectionChecker().canConnect(this, otherConnection, false); -}; - -/** - * Is this connection compatible with another connection with respect to the - * value type system. E.g. square_root("Hello") is not compatible. - * @param {!Connection} otherConnection Connection to compare against. - * @return {boolean} True if the connections share a type. - * @private - * @deprecated October 2019. Will be deleted January 2021. Use the workspace's - * connectionChecker instead. - * @suppress {unusedPrivateMembers} - */ -Connection.prototype.checkType_ = function(otherConnection) { - deprecation.warn( - 'Connection.prototype.checkType_', 'October 2019', 'January 2021', - 'the workspace\'s connection checker'); - return this.checkType(otherConnection); -}; - /** * Function to be called when this connection's compatible types have changed. * @protected diff --git a/core/rendered_connection.js b/core/rendered_connection.js index ca326a23052..69bdae550c7 100644 --- a/core/rendered_connection.js +++ b/core/rendered_connection.js @@ -16,7 +16,6 @@ goog.module('Blockly.RenderedConnection'); const common = goog.require('Blockly.common'); -const deprecation = goog.require('Blockly.utils.deprecation'); const dom = goog.require('Blockly.utils.dom'); const eventUtils = goog.require('Blockly.Events.utils'); const internalConstants = goog.require('Blockly.internalConstants'); @@ -429,28 +428,6 @@ RenderedConnection.prototype.startTrackingAll = function() { return renderList; }; -/** - * Check if the two connections can be dragged to connect to each other. - * @param {!Connection} candidate A nearby connection to check. - * @param {number=} maxRadius The maximum radius allowed for connections, in - * workspace units. - * @return {boolean} True if the connection is allowed, false otherwise. - * @deprecated July 2020 - */ -RenderedConnection.prototype.isConnectionAllowed = function( - candidate, maxRadius) { - deprecation.warn( - 'RenderedConnection.prototype.isConnectionAllowed', 'July 2020', - 'July 2021', - 'Blockly.Workspace.prototype.getConnectionChecker().canConnect'); - if (this.distanceFrom(candidate) > maxRadius) { - return false; - } - - return RenderedConnection.superClass_.isConnectionAllowed.call( - this, candidate); -}; - /** * Behavior after a connection attempt fails. * Bumps this connection away from the other connection. Called when an diff --git a/tests/deps.js b/tests/deps.js index d69b7acca84..27978955a55 100644 --- a/tests/deps.js +++ b/tests/deps.js @@ -23,7 +23,7 @@ goog.addDependency('../../core/clipboard.js', ['Blockly.clipboard'], ['Blockly.E goog.addDependency('../../core/comment.js', ['Blockly.Comment'], ['Blockly.Bubble', 'Blockly.Css', 'Blockly.Events.BlockChange', 'Blockly.Events.BubbleOpen', 'Blockly.Events.utils', 'Blockly.Icon', 'Blockly.Warning', 'Blockly.browserEvents', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/common.js', ['Blockly.common'], [], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/component_manager.js', ['Blockly.ComponentManager'], ['Blockly.utils'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../core/connection.js', ['Blockly.Connection'], ['Blockly.ConnectionType', 'Blockly.Events.BlockMove', 'Blockly.Events.utils', 'Blockly.IASTNodeLocationWithBlock', 'Blockly.Xml', 'Blockly.constants', 'Blockly.serialization.blocks', 'Blockly.utils.deprecation'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../core/connection.js', ['Blockly.Connection'], ['Blockly.ConnectionType', 'Blockly.Events.BlockMove', 'Blockly.Events.utils', 'Blockly.IASTNodeLocationWithBlock', 'Blockly.Xml', 'Blockly.constants', 'Blockly.serialization.blocks'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/connection_checker.js', ['Blockly.ConnectionChecker'], ['Blockly.Connection', 'Blockly.ConnectionType', 'Blockly.IConnectionChecker', 'Blockly.common', 'Blockly.internalConstants', 'Blockly.registry'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/connection_db.js', ['Blockly.ConnectionDB'], ['Blockly.ConnectionType', 'Blockly.constants'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/connection_type.js', ['Blockly.ConnectionType'], [], {'lang': 'es6', 'module': 'goog'}); @@ -138,7 +138,7 @@ goog.addDependency('../../core/options.js', ['Blockly.Options'], ['Blockly.Theme goog.addDependency('../../core/positionable_helpers.js', ['Blockly.uiPosition'], ['Blockly.Scrollbar', 'Blockly.utils.Rect', 'Blockly.utils.toolbox'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/procedures.js', ['Blockly.Procedures'], ['Blockly.Events.BlockChange', 'Blockly.Events.utils', 'Blockly.Msg', 'Blockly.Names', 'Blockly.Variables', 'Blockly.Workspace', 'Blockly.Xml', 'Blockly.blocks', 'Blockly.utils.xml'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/registry.js', ['Blockly.registry'], [], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../core/rendered_connection.js', ['Blockly.RenderedConnection'], ['Blockly.Connection', 'Blockly.ConnectionType', 'Blockly.Events.utils', 'Blockly.common', 'Blockly.internalConstants', 'Blockly.utils.Coordinate', 'Blockly.utils.Svg', 'Blockly.utils.deprecation', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.svgMath', 'Blockly.utils.svgPaths'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../core/rendered_connection.js', ['Blockly.RenderedConnection'], ['Blockly.Connection', 'Blockly.ConnectionType', 'Blockly.Events.utils', 'Blockly.common', 'Blockly.internalConstants', 'Blockly.utils.Coordinate', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.svgMath', 'Blockly.utils.svgPaths'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/renderers/common/block_rendering.js', ['Blockly.blockRendering'], ['Blockly.blockRendering.BottomRow', 'Blockly.blockRendering.Connection', 'Blockly.blockRendering.ConstantProvider', 'Blockly.blockRendering.Debug', 'Blockly.blockRendering.Drawer', 'Blockly.blockRendering.ExternalValueInput', 'Blockly.blockRendering.Field', 'Blockly.blockRendering.Hat', 'Blockly.blockRendering.IPathObject', 'Blockly.blockRendering.Icon', 'Blockly.blockRendering.InRowSpacer', 'Blockly.blockRendering.InlineInput', 'Blockly.blockRendering.InputConnection', 'Blockly.blockRendering.InputRow', 'Blockly.blockRendering.JaggedEdge', 'Blockly.blockRendering.MarkerSvg', 'Blockly.blockRendering.Measurable', 'Blockly.blockRendering.NextConnection', 'Blockly.blockRendering.OutputConnection', 'Blockly.blockRendering.PathObject', 'Blockly.blockRendering.PreviousConnection', 'Blockly.blockRendering.RenderInfo', 'Blockly.blockRendering.Renderer', 'Blockly.blockRendering.RoundCorner', 'Blockly.blockRendering.Row', 'Blockly.blockRendering.SpacerRow', 'Blockly.blockRendering.SquareCorner', 'Blockly.blockRendering.StatementInput', 'Blockly.blockRendering.TopRow', 'Blockly.blockRendering.Types', 'Blockly.blockRendering.debug', 'Blockly.registry', 'Blockly.utils.deprecation'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/renderers/common/constants.js', ['Blockly.blockRendering.ConstantProvider'], ['Blockly.ConnectionType', 'Blockly.utils.Svg', 'Blockly.utils.colour', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.parsing', 'Blockly.utils.svgPaths', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/renderers/common/debug.js', ['Blockly.blockRendering.debug'], [], {'lang': 'es6', 'module': 'goog'}); diff --git a/tests/deps.mocha.js b/tests/deps.mocha.js index ca6c6037aa7..540c5df2d12 100644 --- a/tests/deps.mocha.js +++ b/tests/deps.mocha.js @@ -23,7 +23,7 @@ goog.addDependency('../../core/clipboard.js', ['Blockly.clipboard'], ['Blockly.E goog.addDependency('../../core/comment.js', ['Blockly.Comment'], ['Blockly.Bubble', 'Blockly.Css', 'Blockly.Events.BlockChange', 'Blockly.Events.BubbleOpen', 'Blockly.Events.utils', 'Blockly.Icon', 'Blockly.Warning', 'Blockly.browserEvents', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/common.js', ['Blockly.common'], [], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/component_manager.js', ['Blockly.ComponentManager'], ['Blockly.utils'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../core/connection.js', ['Blockly.Connection'], ['Blockly.ConnectionType', 'Blockly.Events.BlockMove', 'Blockly.Events.utils', 'Blockly.IASTNodeLocationWithBlock', 'Blockly.Xml', 'Blockly.constants', 'Blockly.serialization.blocks', 'Blockly.utils.deprecation'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../core/connection.js', ['Blockly.Connection'], ['Blockly.ConnectionType', 'Blockly.Events.BlockMove', 'Blockly.Events.utils', 'Blockly.IASTNodeLocationWithBlock', 'Blockly.Xml', 'Blockly.constants', 'Blockly.serialization.blocks'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/connection_checker.js', ['Blockly.ConnectionChecker'], ['Blockly.Connection', 'Blockly.ConnectionType', 'Blockly.IConnectionChecker', 'Blockly.common', 'Blockly.internalConstants', 'Blockly.registry'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/connection_db.js', ['Blockly.ConnectionDB'], ['Blockly.ConnectionType', 'Blockly.constants'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/connection_type.js', ['Blockly.ConnectionType'], [], {'lang': 'es6', 'module': 'goog'}); @@ -138,7 +138,7 @@ goog.addDependency('../../core/options.js', ['Blockly.Options'], ['Blockly.Theme goog.addDependency('../../core/positionable_helpers.js', ['Blockly.uiPosition'], ['Blockly.Scrollbar', 'Blockly.utils.Rect', 'Blockly.utils.toolbox'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/procedures.js', ['Blockly.Procedures'], ['Blockly.Events.BlockChange', 'Blockly.Events.utils', 'Blockly.Msg', 'Blockly.Names', 'Blockly.Variables', 'Blockly.Workspace', 'Blockly.Xml', 'Blockly.blocks', 'Blockly.utils.xml'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/registry.js', ['Blockly.registry'], [], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../core/rendered_connection.js', ['Blockly.RenderedConnection'], ['Blockly.Connection', 'Blockly.ConnectionType', 'Blockly.Events.utils', 'Blockly.common', 'Blockly.internalConstants', 'Blockly.utils.Coordinate', 'Blockly.utils.Svg', 'Blockly.utils.deprecation', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.svgMath', 'Blockly.utils.svgPaths'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../core/rendered_connection.js', ['Blockly.RenderedConnection'], ['Blockly.Connection', 'Blockly.ConnectionType', 'Blockly.Events.utils', 'Blockly.common', 'Blockly.internalConstants', 'Blockly.utils.Coordinate', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.svgMath', 'Blockly.utils.svgPaths'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/renderers/common/block_rendering.js', ['Blockly.blockRendering'], ['Blockly.blockRendering.BottomRow', 'Blockly.blockRendering.Connection', 'Blockly.blockRendering.ConstantProvider', 'Blockly.blockRendering.Debug', 'Blockly.blockRendering.Drawer', 'Blockly.blockRendering.ExternalValueInput', 'Blockly.blockRendering.Field', 'Blockly.blockRendering.Hat', 'Blockly.blockRendering.IPathObject', 'Blockly.blockRendering.Icon', 'Blockly.blockRendering.InRowSpacer', 'Blockly.blockRendering.InlineInput', 'Blockly.blockRendering.InputConnection', 'Blockly.blockRendering.InputRow', 'Blockly.blockRendering.JaggedEdge', 'Blockly.blockRendering.MarkerSvg', 'Blockly.blockRendering.Measurable', 'Blockly.blockRendering.NextConnection', 'Blockly.blockRendering.OutputConnection', 'Blockly.blockRendering.PathObject', 'Blockly.blockRendering.PreviousConnection', 'Blockly.blockRendering.RenderInfo', 'Blockly.blockRendering.Renderer', 'Blockly.blockRendering.RoundCorner', 'Blockly.blockRendering.Row', 'Blockly.blockRendering.SpacerRow', 'Blockly.blockRendering.SquareCorner', 'Blockly.blockRendering.StatementInput', 'Blockly.blockRendering.TopRow', 'Blockly.blockRendering.Types', 'Blockly.blockRendering.debug', 'Blockly.registry', 'Blockly.utils.deprecation'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/renderers/common/constants.js', ['Blockly.blockRendering.ConstantProvider'], ['Blockly.ConnectionType', 'Blockly.utils.Svg', 'Blockly.utils.colour', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.parsing', 'Blockly.utils.svgPaths', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/renderers/common/debug.js', ['Blockly.blockRendering.debug'], [], {'lang': 'es6', 'module': 'goog'}); diff --git a/tests/mocha/connection_test.js b/tests/mocha/connection_test.js index f7dd29dcd20..24e763683a5 100644 --- a/tests/mocha/connection_test.js +++ b/tests/mocha/connection_test.js @@ -28,48 +28,6 @@ suite('Connection', function() { sharedTestTeardown.call(this); }); - test('Deprecated - canConnectWithReason passes', function() { - const deprecateWarnSpy = createDeprecationWarningStub(); - const conn1 = this.createConnection(Blockly.PREVIOUS_NAME); - const conn2 = this.createConnection(Blockly.NEXT_NAME); - chai.assert.equal(conn1.canConnectWithReason(conn2), - Blockly.Connection.CAN_CONNECT); - assertSingleDeprecationWarningCall(deprecateWarnSpy, - 'Connection.prototype.canConnectWithReason'); - }); - - test('Deprecated - canConnectWithReason fails', function() { - const deprecateWarnSpy = createDeprecationWarningStub(); - const conn1 = this.createConnection(Blockly.PREVIOUS_NAME); - const conn2 = this.createConnection(Blockly.OUTPUT_VALUE); - chai.assert.equal(conn1.canConnectWithReason(conn2), - Blockly.Connection.REASON_WRONG_TYPE); - assertSingleDeprecationWarningCall(deprecateWarnSpy, - 'Connection.prototype.canConnectWithReason'); - }); - - test('Deprecated - checkConnection passes', function() { - const deprecateWarnSpy = createDeprecationWarningStub(); - const conn1 = this.createConnection(Blockly.PREVIOUS_NAME); - const conn2 = this.createConnection(Blockly.NEXT_NAME); - chai.assert.doesNotThrow(function() { - conn1.checkConnection(conn2); - }); - assertSingleDeprecationWarningCall(deprecateWarnSpy, - 'Connection.prototype.checkConnection'); - }); - - test('Deprecated - checkConnection fails', function() { - const deprecateWarnSpy = createDeprecationWarningStub(); - const conn1 = this.createConnection(Blockly.PREVIOUS_NAME); - const conn2 = this.createConnection(Blockly.OUTPUT_VALUE); - chai.assert.throws(function() { - conn1.checkConnection(conn2); - }); - assertSingleDeprecationWarningCall(deprecateWarnSpy, - 'Connection.prototype.checkConnection'); - }); - suite('Set Shadow', function() { function assertBlockMatches(block, isShadow, opt_id) { chai.assert.equal(block.isShadow(), isShadow,