function updateShape_() {
    // If it's a method, add in the caller
    if (this.isMethod_ && !this.getInput('FUNC')) {
      var func = this.appendValueInput('FUNC'); // If there's a premessage, add it in

      if (this.premessage_ !== "") {
        func.appendField(this.premessage_);
      }
    } else if (!this.isMethod_ && this.getInput('FUNC')) {
      this.removeInput('FUNC');
    }

    var drawnArgumentCount = this.getDrawnArgumentCount_();
    var message = this.getInput('MESSAGE_AREA'); // Zero arguments, just do {message()}

    if (drawnArgumentCount === 0) {
      if (message) {
        message.removeField('MESSAGE');
      } else {
        message = this.appendDummyInput('MESSAGE_AREA').setAlign(Blockly.ALIGN_RIGHT);
      }

      message.appendField(new Blockly.FieldLabel(this.message_ + "\ ("), 'MESSAGE'); // One argument, no MESSAGE_AREA
    } else if (message) {
      this.removeInput('MESSAGE_AREA');
    } // Process arguments


    var i;

    for (i = 0; i < drawnArgumentCount; i++) {
      var argument = this.arguments_[i];
      var argumentName = this.parseArgument_(argument);

      if (i === 0) {
        argumentName = this.message_ + "\ (" + argumentName;
      }

      var field = this.getField('ARGNAME' + i);

      if (field) {
        // Ensure argument name is up to date.
        // The argument name field is deterministic based on the mutation,
        // no need to fire a change event.
        Blockly.Events.disable();

        try {
          field.setValue(argumentName);
        } finally {
          Blockly.Events.enable();
        }
      } else {
        // Add new input.
        field = new Blockly.FieldLabel(argumentName);
        this.appendValueInput('ARG' + i).setAlign(Blockly.ALIGN_RIGHT).appendField(field, 'ARGNAME' + i).init();
      }

      if (argumentName) {
        field.setVisible(true);
      } else {
        field.setVisible(false);
      }
    } // Closing parentheses


    if (!this.getInput('CLOSE_PAREN')) {
      this.appendDummyInput('CLOSE_PAREN').setAlign(Blockly.ALIGN_RIGHT).appendField(new Blockly.FieldLabel(")"));
    } // Move everything into place


    if (drawnArgumentCount === 0) {
      if (this.isMethod_) {
        this.moveInputBefore('FUNC', 'MESSAGE_AREA');
      }

      this.moveInputBefore('MESSAGE_AREA', 'CLOSE_PAREN');
    } else {
      if (this.isMethod_) {
        this.moveInputBefore('FUNC', 'CLOSE_PAREN');
      }
    }

    for (var j = 0; j < i; j++) {
      this.moveInputBefore('ARG' + j, 'CLOSE_PAREN');
    } // Set return state


    this.setReturn_(this.returns_, false); // Remove deleted inputs.

    while (this.getInput('ARG' + i)) {
      this.removeInput('ARG' + i);
      i++;
    }

    this.setColour(this.givenColour_);
  }
/**
   * Modify this block to have the correct number of arguments.
   * @private
   * @this Blockly.Block
   */
Modify this block to have the correct number of arguments.
Modify this block to have the correct number of arguments .
function updateShape_() {
    if (this.isMethod_ && !this.getInput('FUNC')) {
      var func = this.appendValueInput('FUNC'); 
      if (this.premessage_ !== "") {
        func.appendField(this.premessage_);
      }
    } else if (!this.isMethod_ && this.getInput('FUNC')) {
      this.removeInput('FUNC');
    }
    var drawnArgumentCount = this.getDrawnArgumentCount_();
    var message = this.getInput('MESSAGE_AREA'); 
    if (drawnArgumentCount === 0) {
      if (message) {
        message.removeField('MESSAGE');
      } else {
        message = this.appendDummyInput('MESSAGE_AREA').setAlign(Blockly.ALIGN_RIGHT);
      }
      message.appendField(new Blockly.FieldLabel(this.message_ + "\ ("), 'MESSAGE'); 
    } else if (message) {
      this.removeInput('MESSAGE_AREA');
    } 
    var i;
    for (i = 0; i < drawnArgumentCount; i++) {
      var argument = this.arguments_[i];
      var argumentName = this.parseArgument_(argument);
      if (i === 0) {
        argumentName = this.message_ + "\ (" + argumentName;
      }
      var field = this.getField('ARGNAME' + i);
      if (field) {
        Blockly.Events.disable();
        try {
          field.setValue(argumentName);
        } finally {
          Blockly.Events.enable();
        }
      } else {
        field = new Blockly.FieldLabel(argumentName);
        this.appendValueInput('ARG' + i).setAlign(Blockly.ALIGN_RIGHT).appendField(field, 'ARGNAME' + i).init();
      }
      if (argumentName) {
        field.setVisible(true);
      } else {
        field.setVisible(false);
      }
    } 
    if (!this.getInput('CLOSE_PAREN')) {
      this.appendDummyInput('CLOSE_PAREN').setAlign(Blockly.ALIGN_RIGHT).appendField(new Blockly.FieldLabel(")"));
    } 
    if (drawnArgumentCount === 0) {
      if (this.isMethod_) {
        this.moveInputBefore('FUNC', 'MESSAGE_AREA');
      }
      this.moveInputBefore('MESSAGE_AREA', 'CLOSE_PAREN');
    } else {
      if (this.isMethod_) {
        this.moveInputBefore('FUNC', 'CLOSE_PAREN');
      }
    }
    for (var j = 0; j < i; j++) {
      this.moveInputBefore('ARG' + j, 'CLOSE_PAREN');
    } 
    this.setReturn_(this.returns_, false); 
    while (this.getInput('ARG' + i)) {
      this.removeInput('ARG' + i);
      i++;
    }
    this.setColour(this.givenColour_);
  }
function updateShape_ ( ) { if ( this . isMethod_ && ! this . getInput ( 'FUNC' ) ) { var func = this . appendValueInput ( 'FUNC' ) ; if ( this . premessage_ !== "" ) { func . appendField ( this . premessage_ ) ; } } else if ( ! this . isMethod_ && this . getInput ( 'FUNC' ) ) { this . removeInput ( 'FUNC' ) ; } var drawnArgumentCount = this . getDrawnArgumentCount_ ( ) ; var message = this . getInput ( 'MESSAGE_AREA' ) ; if ( drawnArgumentCount === 0 ) { if ( message ) { message . removeField ( 'MESSAGE' ) ; } else { message = this . appendDummyInput ( 'MESSAGE_AREA' ) . setAlign ( Blockly . ALIGN_RIGHT ) ; } message . appendField ( new Blockly . FieldLabel ( this . message_ + "\ (" ) , 'MESSAGE' ) ; } else if ( message ) { this . removeInput ( 'MESSAGE_AREA' ) ; } var i ; for ( i = 0 ; i < drawnArgumentCount ; i ++ ) { var argument = this . arguments_ [ i ] ; var argumentName = this . parseArgument_ ( argument ) ; if ( i === 0 ) { argumentName = this . message_ + "\ (" + argumentName ; } var field = this . getField ( 'ARGNAME' + i ) ; if ( field ) { Blockly . Events . disable ( ) ; try { field . setValue ( argumentName ) ; } finally { Blockly . Events . enable ( ) ; } } else { field = new Blockly . FieldLabel ( argumentName ) ; this . appendValueInput ( 'ARG' + i ) . setAlign ( Blockly . ALIGN_RIGHT ) . appendField ( field , 'ARGNAME' + i ) . init ( ) ; } if ( argumentName ) { field . setVisible ( true ) ; } else { field . setVisible ( false ) ; } } if ( ! this . getInput ( 'CLOSE_PAREN' ) ) { this . appendDummyInput ( 'CLOSE_PAREN' ) . setAlign ( Blockly . ALIGN_RIGHT ) . appendField ( new Blockly . FieldLabel ( ")" ) ) ; } if ( drawnArgumentCount === 0 ) { if ( this . isMethod_ ) { this . moveInputBefore ( 'FUNC' , 'MESSAGE_AREA' ) ; } this . moveInputBefore ( 'MESSAGE_AREA' , 'CLOSE_PAREN' ) ; } else { if ( this . isMethod_ ) { this . moveInputBefore ( 'FUNC' , 'CLOSE_PAREN' ) ; } } for ( var j = 0 ; j < i ; j ++ ) { this . moveInputBefore ( 'ARG' + j , 'CLOSE_PAREN' ) ; } this . setReturn_ ( this . returns_ , false ) ; while ( this . getInput ( 'ARG' + i ) ) { this . removeInput ( 'ARG' + i ) ; i ++ ; } this . setColour ( this . givenColour_ ) ; }
Modify this block to have the correct number of arguments.
Modify this block to have the correct number of arguments .
// If it's a method, add in the caller // If there's a premessage, add it in // Zero arguments, just do {message()} // One argument, no MESSAGE_AREA // Process arguments // Ensure argument name is up to date. // The argument name field is deterministic based on the mutation, // no need to fire a change event. // Add new input. // Closing parentheses // Move everything into place // Set return state // Remove deleted inputs.