deprecate!: removes deprecated connection functions (#5713)

This commit is contained in:
alschmiedt
2021-12-02 18:21:21 -08:00
committed by GitHub
parent 8b3635ab75
commit c93e1dfd30
4 changed files with 2 additions and 150 deletions

View File

@@ -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');
@@ -210,42 +209,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
@@ -256,20 +219,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).
@@ -485,38 +434,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

View File

@@ -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

View File

@@ -24,7 +24,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'], ['Blockly.blocks'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/component_manager.js', ['Blockly.ComponentManager'], ['Blockly.utils.array'], {'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'});
@@ -139,7 +139,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'});

View File

@@ -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,