Files
blockly/generators
Christopher Allen f9c865b1b3 refactor(generators)!: CodeGenerator per-block-type generator function dictionary (#7150)
* feat(generators): Add block generator function dictionary

  Add a dictionary of block generator functions, provisionally
  called .forBlock.  Look up generator functions there first, but
  fall back to looking up on 'this' (with deprecation notice)
  for backwards compatibility.

  Also tweak error message generation to use template literal.

* refactor(generators)!: Update generator definitions to use dictionary

* fix(tests): Have blockToCodeTest clean up after itself

  Have the blockToCodeTest helper function delete the block generator
  functions it adds to generator once the test is done.

* refactor(tests): Use generator dictionary in insertion marker test

  The use of generators in insertion_marker_test.js was overlooked
  in the earlier commit making such updates, and some test here
  were failing due to lack of cleanup in
  cleanup in the generator_test.js.

BREAKING CHANGE: this PR moves the generator functions we provide
from their previous location directly on the CodeGenerator instances
to the new .forBlock dictionary on each instance. This does not oblige
external developers to do the same for their custom generators, but
they will need to update any code that references the generator
functions we provide (in generators/*/*, i.e. on javascriptGenerator,
dartGenerator etc.) e.g. to replace the implementation or reuse the
implementation for a different block type.
2023-06-13 20:41:14 +01:00
..