* Set whether this block can chain onto the bottom of another block. * * @param newBoolean True if there can be a previous statement. * @param opt_check Statement type or list of statement types. Null/undefined * if any type could be connected.
(
newBoolean: boolean,
opt_check?: string | string[] | null,
)
| 1249 | * if any type could be connected. |
| 1250 | */ |
| 1251 | setPreviousStatement( |
| 1252 | newBoolean: boolean, |
| 1253 | opt_check?: string | string[] | null, |
| 1254 | ) { |
| 1255 | if (newBoolean) { |
| 1256 | if (opt_check === undefined) { |
| 1257 | opt_check = null; |
| 1258 | } |
| 1259 | if (!this.previousConnection) { |
| 1260 | this.previousConnection = this.makeConnection_( |
| 1261 | ConnectionType.PREVIOUS_STATEMENT, |
| 1262 | ); |
| 1263 | } |
| 1264 | this.previousConnection.setCheck(opt_check); |
| 1265 | } else { |
| 1266 | if (this.previousConnection) { |
| 1267 | if (this.previousConnection.isConnected()) { |
| 1268 | throw Error( |
| 1269 | 'Must disconnect previous statement before removing ' + |
| 1270 | 'connection.', |
| 1271 | ); |
| 1272 | } |
| 1273 | this.previousConnection.dispose(); |
| 1274 | this.previousConnection = null; |
| 1275 | } |
| 1276 | } |
| 1277 | } |
| 1278 | |
| 1279 | /** |
| 1280 | * Set whether another block can chain onto the bottom of this block. |
no test coverage detected