Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecate!: removes deprecated connection functions #5713

Merged
merged 2 commits into from
Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 0 additions & 83 deletions core/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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
Expand All @@ -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).
Expand Down Expand Up @@ -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
Expand Down
23 changes: 0 additions & 23 deletions core/rendered_connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/deps.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 0 additions & 42 deletions tests/mocha/connection_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down