Skip to content

Commit

Permalink
chore!: Add deprecation notices to values in blockly.js (google#5555)
Browse files Browse the repository at this point in the history
* Add deprecation warnings and reorganize blockly.js

* Update usages of deprecated properties

* chore: make dates consistent, remove extra function

* chore: run clang-format and fix lint

* chore: add more  tags

* chore: fix updated location of Align types

* chore: fix deprecated usages in tests

* chore: rebuild deps

* chore: fix moved Align types in demos and tests

* chore: update which properties are actually deprecated

* chore: don't deprecate Blockly.selected.
  • Loading branch information
maribethb authored Dec 9, 2021
1 parent 243d1e9 commit 7784eac
Show file tree
Hide file tree
Showing 9 changed files with 343 additions and 235 deletions.
444 changes: 272 additions & 172 deletions core/blockly.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ exports.setParentContainer = setParentContainer;
/**
* Size the SVG image to completely fill its container. Call this when the view
* actually changes sizes (e.g. on a window resize/device orientation change).
* See Blockly.resizeSvgContents to resize the workspace when the contents
* See workspace.resizeContents to resize the workspace when the contents
* change (e.g. when a block is added or removed).
* Record the height/width of the SVG image.
* @param {!WorkspaceSvg} workspace Any workspace in the SVG.
Expand Down
10 changes: 5 additions & 5 deletions tests/deps.mocha.js

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

10 changes: 6 additions & 4 deletions tests/mocha/block_json_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

goog.module('Blockly.test.blockJson');

const {Align} = goog.require('Blockly.Input');


suite('Block JSON initialization', function() {
suite('validateTokens_', function() {
Expand Down Expand Up @@ -564,7 +566,7 @@ suite('Block JSON initialization', function() {
'type': 'input_dummy',
'align': 'LEFT',
},
'input_dummy', undefined, Blockly.ALIGN_LEFT);
'input_dummy', undefined, Align.LEFT);
});

test('"Right" align', function() {
Expand All @@ -573,7 +575,7 @@ suite('Block JSON initialization', function() {
'type': 'input_dummy',
'align': 'RIGHT',
},
'input_dummy', undefined, Blockly.ALIGN_RIGHT);
'input_dummy', undefined, Align.RIGHT);
});

test('"Center" align', function() {
Expand All @@ -582,7 +584,7 @@ suite('Block JSON initialization', function() {
'type': 'input_dummy',
'align': 'CENTER',
},
'input_dummy', undefined, Blockly.ALIGN_CENTRE);
'input_dummy', undefined, Align.CENTRE);
});

test('"Centre" align', function() {
Expand All @@ -591,7 +593,7 @@ suite('Block JSON initialization', function() {
'type': 'input_dummy',
'align': 'CENTRE',
},
'input_dummy', undefined, Blockly.ALIGN_CENTRE);
'input_dummy', undefined, Align.CENTRE);
});
});
});
9 changes: 5 additions & 4 deletions tests/mocha/block_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ goog.module('Blockly.test.blocks');

const eventUtils = goog.require('Blockly.Events.utils');
const {Blocks} = goog.require('Blockly.blocks');
const {ConnectionType} = goog.require('Blockly.ConnectionType');
const {createDeprecationWarningStub, createRenderedBlock, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers');


Expand Down Expand Up @@ -397,19 +398,19 @@ suite('Blocks', function() {

this.getInputs = function() {
return this.workspace
.connectionDBList[Blockly.INPUT_VALUE].connections_;
.connectionDBList[ConnectionType.INPUT_VALUE].connections_;
};
this.getOutputs = function() {
return this.workspace
.connectionDBList[Blockly.OUTPUT_VALUE].connections_;
.connectionDBList[ConnectionType.OUTPUT_VALUE].connections_;
};
this.getNext = function() {
return this.workspace
.connectionDBList[Blockly.NEXT_STATEMENT].connections_;
.connectionDBList[ConnectionType.NEXT_STATEMENT].connections_;
};
this.getPrevious = function() {
return this.workspace
.connectionDBList[Blockly.PREVIOUS_STATEMENT].connections_;
.connectionDBList[ConnectionType.PREVIOUS_STATEMENT].connections_;
};

this.assertConnectionsEmpty = function() {
Expand Down
63 changes: 32 additions & 31 deletions tests/mocha/connection_checker_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

goog.module('Blockly.test.connectionChecker');

const {ConnectionType} = goog.require('Blockly.ConnectionType');
const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers');


Expand All @@ -27,7 +28,7 @@ suite('Connection checker', function() {
}

test('Target Null', function() {
const connection = new Blockly.Connection({}, Blockly.INPUT_VALUE);
const connection = new Blockly.Connection({}, ConnectionType.INPUT_VALUE);
assertReasonHelper(
this.checker,
connection,
Expand All @@ -36,8 +37,8 @@ suite('Connection checker', function() {
});
test('Target Self', function() {
const block = {workspace: 1};
const connection1 = new Blockly.Connection(block, Blockly.INPUT_VALUE);
const connection2 = new Blockly.Connection(block, Blockly.OUTPUT_VALUE);
const connection1 = new Blockly.Connection(block, ConnectionType.INPUT_VALUE);
const connection2 = new Blockly.Connection(block, ConnectionType.OUTPUT_VALUE);

assertReasonHelper(
this.checker,
Expand All @@ -47,9 +48,9 @@ suite('Connection checker', function() {
});
test('Different Workspaces', function() {
const connection1 = new Blockly.Connection(
{workspace: 1}, Blockly.INPUT_VALUE);
{workspace: 1}, ConnectionType.INPUT_VALUE);
const connection2 = new Blockly.Connection(
{workspace: 2}, Blockly.OUTPUT_VALUE);
{workspace: 2}, ConnectionType.OUTPUT_VALUE);

assertReasonHelper(
this.checker,
Expand All @@ -66,13 +67,13 @@ suite('Connection checker', function() {
const outBlock = {isShadow: function() {}};
const inBlock = {isShadow: function() {}};
this.previous = new Blockly.Connection(
prevBlock, Blockly.PREVIOUS_STATEMENT);
prevBlock, ConnectionType.PREVIOUS_STATEMENT);
this.next = new Blockly.Connection(
nextBlock, Blockly.NEXT_STATEMENT);
nextBlock, ConnectionType.NEXT_STATEMENT);
this.output = new Blockly.Connection(
outBlock, Blockly.OUTPUT_VALUE);
outBlock, ConnectionType.OUTPUT_VALUE);
this.input = new Blockly.Connection(
inBlock, Blockly.INPUT_VALUE);
inBlock, ConnectionType.INPUT_VALUE);
});
test('Previous, Next', function() {
assertReasonHelper(
Expand Down Expand Up @@ -163,8 +164,8 @@ suite('Connection checker', function() {
test('Previous Shadow', function() {
const prevBlock = {isShadow: function() {return true;}};
const nextBlock = {isShadow: function() {return false;}};
const prev = new Blockly.Connection(prevBlock, Blockly.PREVIOUS_STATEMENT);
const next = new Blockly.Connection(nextBlock, Blockly.NEXT_STATEMENT);
const prev = new Blockly.Connection(prevBlock, ConnectionType.PREVIOUS_STATEMENT);
const next = new Blockly.Connection(nextBlock, ConnectionType.NEXT_STATEMENT);

assertReasonHelper(
this.checker,
Expand All @@ -175,8 +176,8 @@ suite('Connection checker', function() {
test('Next Shadow', function() {
const prevBlock = {isShadow: function() {return false;}};
const nextBlock = {isShadow: function() {return true;}};
const prev = new Blockly.Connection(prevBlock, Blockly.PREVIOUS_STATEMENT);
const next = new Blockly.Connection(nextBlock, Blockly.NEXT_STATEMENT);
const prev = new Blockly.Connection(prevBlock, ConnectionType.PREVIOUS_STATEMENT);
const next = new Blockly.Connection(nextBlock, ConnectionType.NEXT_STATEMENT);

assertReasonHelper(
this.checker,
Expand All @@ -187,8 +188,8 @@ suite('Connection checker', function() {
test('Prev and Next Shadow', function() {
const prevBlock = {isShadow: function() {return true;}};
const nextBlock = {isShadow: function() {return true;}};
const prev = new Blockly.Connection(prevBlock, Blockly.PREVIOUS_STATEMENT);
const next = new Blockly.Connection(nextBlock, Blockly.NEXT_STATEMENT);
const prev = new Blockly.Connection(prevBlock, ConnectionType.PREVIOUS_STATEMENT);
const next = new Blockly.Connection(nextBlock, ConnectionType.NEXT_STATEMENT);

assertReasonHelper(
this.checker,
Expand All @@ -199,8 +200,8 @@ suite('Connection checker', function() {
test('Output Shadow', function() {
const outBlock = {isShadow: function() {return true;}};
const inBlock = {isShadow: function() {return false;}};
const outCon = new Blockly.Connection(outBlock, Blockly.OUTPUT_VALUE);
const inCon = new Blockly.Connection(inBlock, Blockly.INPUT_VALUE);
const outCon = new Blockly.Connection(outBlock, ConnectionType.OUTPUT_VALUE);
const inCon = new Blockly.Connection(inBlock, ConnectionType.INPUT_VALUE);

assertReasonHelper(
this.checker,
Expand All @@ -211,8 +212,8 @@ suite('Connection checker', function() {
test('Input Shadow', function() {
const outBlock = {isShadow: function() {return false;}};
const inBlock = {isShadow: function() {return true;}};
const outCon = new Blockly.Connection(outBlock, Blockly.OUTPUT_VALUE);
const inCon = new Blockly.Connection(inBlock, Blockly.INPUT_VALUE);
const outCon = new Blockly.Connection(outBlock, ConnectionType.OUTPUT_VALUE);
const inCon = new Blockly.Connection(inBlock, ConnectionType.INPUT_VALUE);

assertReasonHelper(
this.checker,
Expand All @@ -223,8 +224,8 @@ suite('Connection checker', function() {
test('Output and Input Shadow', function() {
const outBlock = {isShadow: function() {return true;}};
const inBlock = {isShadow: function() {return true;}};
const outCon = new Blockly.Connection(outBlock, Blockly.OUTPUT_VALUE);
const inCon = new Blockly.Connection(inBlock, Blockly.INPUT_VALUE);
const outCon = new Blockly.Connection(outBlock, ConnectionType.OUTPUT_VALUE);
const inCon = new Blockly.Connection(inBlock, ConnectionType.INPUT_VALUE);

assertReasonHelper(
this.checker,
Expand Down Expand Up @@ -255,17 +256,17 @@ suite('Connection checker', function() {
isShadow: function() {
},
};
const outCon = new Blockly.Connection(outBlock, Blockly.OUTPUT_VALUE);
const inCon = new Blockly.Connection(inBlock, Blockly.INPUT_VALUE);
const outCon = new Blockly.Connection(outBlock, ConnectionType.OUTPUT_VALUE);
const inCon = new Blockly.Connection(inBlock, ConnectionType.INPUT_VALUE);
outBlock.outputConnection = outCon;
inBlock.inputConnection = inCon;
connectReciprocally(inCon, outCon);
const prevCon = new Blockly.Connection(outBlock, Blockly.PREVIOUS_STATEMENT);
const prevCon = new Blockly.Connection(outBlock, ConnectionType.PREVIOUS_STATEMENT);
const nextBlock = {
isShadow: function() {
},
};
const nextCon = new Blockly.Connection(nextBlock, Blockly.NEXT_STATEMENT);
const nextCon = new Blockly.Connection(nextBlock, ConnectionType.NEXT_STATEMENT);

assertReasonHelper(
this.checker,
Expand All @@ -282,17 +283,17 @@ suite('Connection checker', function() {
isShadow: function() {
},
};
const prevCon = new Blockly.Connection(prevBlock, Blockly.PREVIOUS_STATEMENT);
const nextCon = new Blockly.Connection(nextBlock, Blockly.NEXT_STATEMENT);
const prevCon = new Blockly.Connection(prevBlock, ConnectionType.PREVIOUS_STATEMENT);
const nextCon = new Blockly.Connection(nextBlock, ConnectionType.NEXT_STATEMENT);
prevBlock.previousConnection = prevCon;
nextBlock.nextConnection = nextCon;
connectReciprocally(prevCon, nextCon);
const outCon = new Blockly.Connection(prevBlock, Blockly.OUTPUT_VALUE);
const outCon = new Blockly.Connection(prevBlock, ConnectionType.OUTPUT_VALUE);
const inBlock = {
isShadow: function() {
},
};
const inCon = new Blockly.Connection(inBlock, Blockly.INPUT_VALUE);
const inCon = new Blockly.Connection(inBlock, ConnectionType.INPUT_VALUE);

assertReasonHelper(
this.checker,
Expand All @@ -304,8 +305,8 @@ suite('Connection checker', function() {
});
suite('Check Types', function() {
setup(function() {
this.con1 = new Blockly.Connection({}, Blockly.PREVIOUS_STATEMENT);
this.con2 = new Blockly.Connection({}, Blockly.NEXT_STATEMENT);
this.con1 = new Blockly.Connection({}, ConnectionType.PREVIOUS_STATEMENT);
this.con2 = new Blockly.Connection({}, ConnectionType.NEXT_STATEMENT);
});
function assertCheckTypes(checker, one, two) {
chai.assert.isTrue(checker.doTypeChecks(one, two));
Expand Down
Loading

0 comments on commit 7784eac

Please sign in to comment.