Skip to content

Commit

Permalink
refactor!: Removed backwards compatibility for getDeveloperVars(). (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
gonfunko committed Aug 25, 2022
1 parent 3a36ed5 commit 3bc42c5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
15 changes: 1 addition & 14 deletions core/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ export function allUsedVarModels(ws: Workspace): VariableModel[] {
return Array.from(variables.values());
}

const ALL_DEVELOPER_VARS_WARNINGS_BY_BLOCK_TYPE: {[key: string]: boolean} = {};

/**
* Find all developer variables used by blocks in the workspace.
* Developer variables are never shown to the user, but are declared as global
Expand All @@ -81,18 +79,7 @@ export function allDeveloperVariables(workspace: Workspace): string[] {
const blocks = workspace.getAllBlocks(false);
const variables = new Set<string>();
for (let i = 0, block; block = blocks[i]; i++) {
let getDeveloperVariables = block.getDeveloperVariables;
if (!getDeveloperVariables && (block as any).getDeveloperVars) {
// August 2018: getDeveloperVars() was deprecated and renamed
// getDeveloperVariables().
getDeveloperVariables = (block as any).getDeveloperVars;
if (!ALL_DEVELOPER_VARS_WARNINGS_BY_BLOCK_TYPE[block.type]) {
console.warn(
'Function getDeveloperVars() deprecated. Use ' +
'getDeveloperVariables() (block type \'' + block.type + '\')');
ALL_DEVELOPER_VARS_WARNINGS_BY_BLOCK_TYPE[block.type] = true;
}
}
const getDeveloperVariables = block.getDeveloperVariables;
if (getDeveloperVariables) {
const devVars = getDeveloperVariables();
for (let j = 0; j < devVars.length; j++) {
Expand Down
8 changes: 4 additions & 4 deletions tests/generators/unittest.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Blockly.Blocks['unittest_main'] = {
this.setTooltip('Executes the enclosed unit tests,\n' +
'then prints a summary.');
},
getDeveloperVars: function() {
getDeveloperVariables: function() {
return ['unittestResults'];
}
};
Expand All @@ -40,7 +40,7 @@ Blockly.Blocks['unittest_assertequals'] = {
.appendField('expected');
this.setTooltip('Tests that "actual == expected".');
},
getDeveloperVars: function() {
getDeveloperVariables: function() {
return ['unittestResults'];
}
};
Expand All @@ -60,7 +60,7 @@ Blockly.Blocks['unittest_assertvalue'] = {
[['true', 'TRUE'], ['false', 'FALSE'], ['null', 'NULL']]), 'EXPECTED');
this.setTooltip('Tests that the value is true, false, or null.');
},
getDeveloperVars: function() {
getDeveloperVariables: function() {
return ['unittestResults'];
}
};
Expand All @@ -76,7 +76,7 @@ Blockly.Blocks['unittest_fail'] = {
.appendField('fail');
this.setTooltip('Records an error.');
},
getDeveloperVars: function() {
getDeveloperVariables: function() {
return ['unittestResults'];
}
};
Expand Down

0 comments on commit 3bc42c5

Please sign in to comment.