mirror of
https://github.com/google/blockly.git
synced 2026-01-07 17:10:11 +01:00
fix: Made workspace non-nullable. (#6300)
* Made workspace non-nullable. * chore: clang-format files. * fix: Fixed incorrect block disposal check in connection.ts
This commit is contained in:
@@ -139,7 +139,7 @@ export class FieldVariable extends FieldDropdown {
|
||||
return; // Initialization already happened.
|
||||
}
|
||||
const variable = Variables.getOrCreateVariablePackage(
|
||||
this.sourceBlock_.workspace!, null, this.defaultVariableName,
|
||||
this.sourceBlock_.workspace, null, this.defaultVariableName,
|
||||
this.defaultType_);
|
||||
// Don't call setValue because we don't want to cause a rerender.
|
||||
this.doValueUpdate_(variable.getId());
|
||||
@@ -167,7 +167,7 @@ export class FieldVariable extends FieldDropdown {
|
||||
// AnyDuringMigration because: Argument of type 'string | null' is not
|
||||
// assignable to parameter of type 'string | undefined'.
|
||||
const variable = Variables.getOrCreateVariablePackage(
|
||||
this.sourceBlock_.workspace!, id, variableName as AnyDuringMigration,
|
||||
this.sourceBlock_.workspace, id, variableName as AnyDuringMigration,
|
||||
variableType);
|
||||
|
||||
// This should never happen :)
|
||||
@@ -234,7 +234,7 @@ export class FieldVariable extends FieldDropdown {
|
||||
}
|
||||
// This is necessary so that blocks in the flyout can have custom var names.
|
||||
const variable = Variables.getOrCreateVariablePackage(
|
||||
this.sourceBlock_.workspace!, state['id'] || null, state['name'],
|
||||
this.sourceBlock_.workspace, state['id'] || null, state['name'],
|
||||
state['type'] || '');
|
||||
this.setValue(variable.getId());
|
||||
}
|
||||
@@ -306,7 +306,7 @@ export class FieldVariable extends FieldDropdown {
|
||||
return null;
|
||||
}
|
||||
const newId = opt_newValue as string;
|
||||
const variable = Variables.getVariable(this.sourceBlock_.workspace!, newId);
|
||||
const variable = Variables.getVariable(this.sourceBlock_.workspace, newId);
|
||||
if (!variable) {
|
||||
console.warn(
|
||||
'Variable id doesn\'t point to a real variable! ' +
|
||||
@@ -332,7 +332,7 @@ export class FieldVariable extends FieldDropdown {
|
||||
*/
|
||||
protected override doValueUpdate_(newId: AnyDuringMigration) {
|
||||
this.variable_ =
|
||||
Variables.getVariable(this.sourceBlock_.workspace!, newId as string);
|
||||
Variables.getVariable(this.sourceBlock_.workspace, newId as string);
|
||||
super.doValueUpdate_(newId);
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ export class FieldVariable extends FieldDropdown {
|
||||
let variableTypes = this.variableTypes;
|
||||
if (variableTypes === null) {
|
||||
// If variableTypes is null, return all variable types.
|
||||
if (this.sourceBlock_ && this.sourceBlock_.workspace) {
|
||||
if (this.sourceBlock_ && !this.sourceBlock_.disposed) {
|
||||
return this.sourceBlock_.workspace.getVariableTypes();
|
||||
}
|
||||
}
|
||||
@@ -440,7 +440,7 @@ export class FieldVariable extends FieldDropdown {
|
||||
protected override onItemSelected_(menu: Menu, menuItem: MenuItem) {
|
||||
const id = menuItem.getValue();
|
||||
// Handle special cases.
|
||||
if (this.sourceBlock_ && this.sourceBlock_.workspace) {
|
||||
if (this.sourceBlock_ && !this.sourceBlock_.disposed) {
|
||||
if (id === internalConstants.RENAME_VARIABLE_ID) {
|
||||
// Rename variable.
|
||||
Variables.renameVariable(
|
||||
@@ -495,7 +495,7 @@ export class FieldVariable extends FieldDropdown {
|
||||
}
|
||||
const name = this.getText();
|
||||
let variableModelList: AnyDuringMigration[] = [];
|
||||
if (this.sourceBlock_ && this.sourceBlock_.workspace) {
|
||||
if (this.sourceBlock_ && !this.sourceBlock_.disposed) {
|
||||
const variableTypes = this.getVariableTypes_();
|
||||
// Get a copy of the list, so that adding rename and new variable options
|
||||
// doesn't modify the workspace's list.
|
||||
|
||||
Reference in New Issue
Block a user