Skip to content

Commit d2e8150

Browse files
committed
Merge branch 'main' of github.com:wpilibsuite/systemcore-blocks-interface into pr_myArray
2 parents 73bf35b + cf4f33c commit d2e8150

13 files changed

+57
-175
lines changed

src/blocks/mrc_call_python_function.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,6 @@ type CallPythonFunctionExtraState = {
150150
* The mechanism class name. Specified only if the function kind is INSTANCE_MECHANISM.
151151
*/
152152
mechanismClassName?: string,
153-
154-
// The following fields allow Alan and Liz to load older projects.
155-
// TODO(lizlooney): Remove these fields.
156-
otherBlockId?: string,
157-
mechanismBlockId?: string,
158153
}
159154

160155
const CALL_PYTHON_FUNCTION = {
@@ -303,7 +298,6 @@ const CALL_PYTHON_FUNCTION = {
303298
this: CallPythonFunctionBlock,
304299
extraState: CallPythonFunctionExtraState
305300
): void {
306-
fixOldExtraState(extraState);
307301
this.mrcFunctionKind = extraState.functionKind as FunctionKind;
308302
this.mrcReturnType = extraState.returnType;
309303
this.mrcArgs = [];
@@ -1276,26 +1270,3 @@ function createFireEventBlock(event: storageModuleContent.Event): toolboxItems.B
12761270
processArgs(args, extraState, inputs);
12771271
return createBlock(extraState, fields, inputs);
12781272
}
1279-
1280-
// The following function allows Alan and Liz to load older projects.
1281-
// TODO(lizlooney): Remove this function.
1282-
function fixOldExtraState(extraState: CallPythonFunctionExtraState): void {
1283-
if (extraState.otherBlockId) {
1284-
switch (extraState.functionKind as FunctionKind) {
1285-
case FunctionKind.INSTANCE_WITHIN:
1286-
case FunctionKind.INSTANCE_ROBOT:
1287-
case FunctionKind.INSTANCE_MECHANISM:
1288-
extraState.methodId = extraState.otherBlockId;
1289-
break;
1290-
case FunctionKind.INSTANCE_COMPONENT:
1291-
extraState.componentId = extraState.otherBlockId;
1292-
break;
1293-
case FunctionKind.EVENT:
1294-
extraState.eventId = extraState.otherBlockId;
1295-
break;
1296-
}
1297-
}
1298-
if (extraState.mechanismBlockId) {
1299-
extraState.mechanismId = extraState.mechanismBlockId;
1300-
}
1301-
}

src/blocks/mrc_event_handler.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,6 @@ export interface EventHandlerExtraState {
7373
* Specified only if the sender type is MECHANISM.
7474
*/
7575
mechanismId?: string,
76-
77-
// The following fields allow Alan and Liz to load older projects.
78-
// TODO(lizlooney): Remove these fields.
79-
otherBlockId?: string,
80-
mechanismBlockId?: string,
8176
}
8277

8378
const EVENT_HANDLER = {
@@ -126,7 +121,6 @@ const EVENT_HANDLER = {
126121
* Applies the given state to this block.
127122
*/
128123
loadExtraState(this: EventHandlerBlock, extraState: EventHandlerExtraState): void {
129-
fixOldExtraState(extraState);
130124
this.mrcSenderType = extraState.senderType;
131125
this.mrcParameters = [];
132126
this.mrcEventId = extraState.eventId;
@@ -508,14 +502,3 @@ export function renameMechanismName(workspace: Blockly.Workspace, mechanismId: s
508502
(block as EventHandlerBlock).renameMechanismName(mechanismId, newName);
509503
});
510504
}
511-
512-
// The following function allows Alan and Liz to load older projects.
513-
// TODO(lizlooney): Remove this function.
514-
function fixOldExtraState(extraState: EventHandlerExtraState): void {
515-
if (extraState.otherBlockId) {
516-
extraState.eventId = extraState.otherBlockId;
517-
}
518-
if (extraState.mechanismBlockId) {
519-
extraState.mechanismId = extraState.mechanismBlockId;
520-
}
521-
}

src/blocks/mrc_get_python_variable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import * as toolboxItems from '../toolbox/items';
4040

4141
export const BLOCK_NAME = 'mrc_get_python_variable';
4242

43-
enum VariableKind {
43+
export enum VariableKind {
4444
MODULE = 'module',
4545
CLASS = 'class',
4646
INSTANCE = 'instance',

src/blocks/mrc_list_add_item.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
/**
19-
* @fileoverview Miscellaneous blocks.
19+
* @fileoverview Block to add an item to the end of a list.
2020
* @author [email protected] (Liz Looney)
2121
*/
2222

src/blocks/mrc_math_min_max.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
/**
19-
* @fileoverview Miscellaneous blocks.
19+
* @fileoverview Blocks for math min and max.
2020
* @author [email protected] (Liz Looney)
2121
*/
2222

src/blocks/mrc_misc_comment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
/**
19-
* @fileoverview Miscellaneous blocks.
19+
* @fileoverview Block for a comment.
2020
* @author [email protected] (Liz Looney)
2121
*/
2222

src/blocks/mrc_misc_evaluate_but_ignore_result.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
/**
19-
* @fileoverview Miscellaneous blocks.
19+
* @fileoverview Blocks for evaluating something, but ignoring the result.
2020
* @author [email protected] (Liz Looney)
2121
*/
2222

src/blocks/mrc_set_python_variable.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import * as Blockly from 'blockly';
2424
import { Order } from 'blockly/python';
2525

26+
import { VariableKind } from './mrc_get_python_variable';
2627
import { getAllowedTypesForSetCheck } from './utils/python';
2728
import * as variable from './utils/variable';
2829
import { ExtendedPythonGenerator } from '../editor/extended_python_generator';
@@ -36,14 +37,6 @@ import * as toolboxItems from '../toolbox/items';
3637

3738
export const BLOCK_NAME = 'mrc_set_python_variable';
3839

39-
// TODO(lizlooney): Consider combining VariableKind here with VariableKind in
40-
// mrc_get_python_variable.ts. They are identical.
41-
enum VariableKind {
42-
MODULE = 'module',
43-
CLASS = 'class',
44-
INSTANCE = 'instance',
45-
}
46-
4740
const FIELD_MODULE_OR_CLASS_NAME = 'MODULE_OR_CLASS';
4841
const FIELD_VARIABLE_NAME = 'VAR';
4942

src/blocks/tokens.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function customTokens(t: (key: string) => string): typeof Blockly.Msg {
4141
EVENTS: t('BLOCKLY.EVENTS'),
4242
EVALUATE_BUT_IGNORE_RESULT: t('BLOCKLY.EVALUATE_BUT_IGNORE_RESULT'),
4343
EVALUATE_BUT_IGNORE_RESULT_TOOLTIP:
44-
t('BLOCKLY.EVALUATE_BUT_IGNORE_RESULT_TOOLTIP'),
44+
t('BLOCKLY.TOOLTIP.EVALUATE_BUT_IGNORE_RESULT'),
4545
AUTO: t('BLOCKLY.AUTO'),
4646
TELEOP: t('BLOCKLY.TELEOP'),
4747
TEST: t('BLOCKLY.TEST'),
@@ -50,10 +50,10 @@ export function customTokens(t: (key: string) => string): typeof Blockly.Msg {
5050
DISPLAY_NAME: t('BLOCKLY.DISPLAY_NAME'),
5151
DISPLAY_GROUP: t('BLOCKLY.DISPLAY_GROUP'),
5252
NO_MECHANISM_CONTENTS: t('BLOCKLY.NO_MECHANISM_CONTENTS'),
53-
OPMODE_TYPE_TOOLTIP: t('BLOCKLY.TOOLTIP.OPMODE_TYPE_TOOLTIP'),
54-
OPMODE_ENABLED_TOOLTIP: t('BLOCKLY.TOOLTIP.OPMODE_ENABLED_TOOLTIP'),
55-
OPMODE_NAME_TOOLTIP: t('BLOCKLY.TOOLTIP.OPMODE_NAME_TOOLTIP'),
56-
OPMODE_GROUP_TOOLTIP: t('BLOCKLY.TOOLTIP.OPMODE_GROUP_TOOLTIP'),
53+
OPMODE_TYPE_TOOLTIP: t('BLOCKLY.TOOLTIP.OPMODE_TYPE'),
54+
OPMODE_ENABLED_TOOLTIP: t('BLOCKLY.TOOLTIP.OPMODE_ENABLED'),
55+
OPMODE_NAME_TOOLTIP: t('BLOCKLY.TOOLTIP.OPMODE_NAME'),
56+
OPMODE_GROUP_TOOLTIP: t('BLOCKLY.TOOLTIP.OPMODE_GROUP'),
5757
MRC_CATEGORY_HARDWARE: t('BLOCKLY.CATEGORY.HARDWARE'),
5858
MRC_CATEGORY_ROBOT: t('BLOCKLY.CATEGORY.ROBOT'),
5959
MRC_CATEGORY_COMPONENTS: t('BLOCKLY.CATEGORY.COMPONENTS'),

src/storage/client_side_storage.ts

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
*/
2121

2222
import * as commonStorage from './common_storage';
23-
import * as storageModuleContent from './module_content';
24-
import * as storageNames from './names';
2523

2624
// Functions for saving blocks files to client side storage.
2725

@@ -58,62 +56,7 @@ export async function openClientSideStorage(): Promise<commonStorage.Storage> {
5856
};
5957
openRequest.onsuccess = () => {
6058
const db = openRequest.result;
61-
fixOldModules(db).then(() => {
62-
resolve(ClientSideStorage.create(db));
63-
})
64-
};
65-
});
66-
}
67-
68-
// The following function allows Alan and Liz to load older projects.
69-
// TODO(lizlooney): Remove this function.
70-
async function fixOldModules(db: IDBDatabase): Promise<void> {
71-
return new Promise((resolve, reject) => {
72-
const transaction = db.transaction([FILES_STORE_NAME], 'readwrite');
73-
transaction.oncomplete = () => {
74-
resolve();
75-
};
76-
transaction.onabort = () => {
77-
console.log('IndexedDB transaction aborted.');
78-
reject(new Error('IndexedDB transaction aborted.'));
79-
};
80-
const filesObjectStore = transaction.objectStore(FILES_STORE_NAME);
81-
const openCursorRequest = filesObjectStore.openCursor();
82-
openCursorRequest.onerror = () => {
83-
console.log('IndexedDB openCursor request failed. openCursorRequest.error is...');
84-
console.log(openCursorRequest.error);
85-
reject(new Error('IndexedDB openCursor request failed.'));
86-
};
87-
openCursorRequest.onsuccess = () => {
88-
const cursor = openCursorRequest.result;
89-
if (cursor) {
90-
const value = cursor.value;
91-
const regexForOldModulePath = new RegExp('^([A-Z][A-Za-z0-9]*)/([A-Z][A-Za-z0-9]*).json$');
92-
const result = regexForOldModulePath.exec(value.path);
93-
if (result) {
94-
const oldModulePath = value.path;
95-
const projectName = result[1];
96-
const className = result[2];
97-
const moduleType = storageModuleContent.parseModuleContentText(value.content).getModuleType();
98-
value.path = storageNames.makeModulePath(projectName, className, moduleType);
99-
const putRequest = filesObjectStore.put(value);
100-
putRequest.onerror = () => {
101-
console.log('IndexedDB put request failed. putRequest.error is...');
102-
console.log(putRequest.error);
103-
throw new Error('IndexedDB put request failed.');
104-
};
105-
const deleteRequest = filesObjectStore.delete(oldModulePath);
106-
deleteRequest.onerror = () => {
107-
console.log('IndexedDB delete request failed. deleteRequest.error is...');
108-
console.log(deleteRequest.error);
109-
throw new Error('IndexedDB delete request failed.');
110-
};
111-
}
112-
cursor.continue();
113-
} else {
114-
// The cursor is done. We have finished reading all the files.
115-
resolve();
116-
}
59+
resolve(ClientSideStorage.create(db));
11760
};
11861
});
11962
}

0 commit comments

Comments
 (0)