<commit_before>// Copyright 2012 Massachusetts Institute of Technology. All rights reserved.

/**
 * @fileoverview Visual blocks editor for App Inventor
 * Initialize the blocks editor workspace.
 * 
 * @author <EMAIL> (<NAME>)
 */

Blockly.BlocklyEditor = {};

Blockly.BlocklyEditor.startup = function(documentBody, formName) {
  Blockly.inject(documentBody);
  Blockly.Drawer.createDom();
  Blockly.Drawer.init();
  Blockly.BlocklyEditor.formName_ = formName;
  Blockly.bindEvent_(Blockly.mainWorkspace.getCanvas(), 'blocklyWorkspaceChange', this,
      function() { 
        window.parent.BlocklyPanel_blocklyWorkspaceChanged(Blockly.BlocklyEditor.formName_); 
      });
};

/**
 * Add a "Generate Yail" option to the context menu for every block. The generated yail will go in
 * the block's comment (if it has one) for now. 
 * TODO: eventually create a separate kind of bubble for the generated yail, which can morph into 
 * the bubble for "do it" output once we hook up to the REPL.
 */ 
Blockly.Block.prototype.customContextMenu = function(options) {
  var yailOption = {enabled: true};
  yailOption.text = "Generate Yail";
  var myBlock = this;
  yailOption.callback = function() {
    myBlock.setCommentText(Blockly.Yail.blockToCode1(myBlock));
  };
  options.push(yailOption);
};<commit_msg>Fix generate yail option on value blocks Yail generator returns arrays for value blocks instead of strings, now passing string to setCommentText<commit_after>// Copyright 2012 Massachusetts Institute of Technology. All rights reserved.

/**
 * @fileoverview Visual blocks editor for App Inventor
 * Initialize the blocks editor workspace.
 * 
 * @author <EMAIL> (<NAME>)
 */

Blockly.BlocklyEditor = {};

Blockly.BlocklyEditor.startup = function(documentBody, formName) {
  Blockly.inject(documentBody);
  Blockly.Drawer.createDom();
  Blockly.Drawer.init();
  Blockly.BlocklyEditor.formName_ = formName;
  Blockly.bindEvent_(Blockly.mainWorkspace.getCanvas(), 'blocklyWorkspaceChange', this,
      function() { 
        window.parent.BlocklyPanel_blocklyWorkspaceChanged(Blockly.BlocklyEditor.formName_); 
      });
};

/**
 * Add a "Generate Yail" option to the context menu for every block. The generated yail will go in
 * the block's comment (if it has one) for now. 
 * TODO: eventually create a separate kind of bubble for the generated yail, which can morph into 
 * the bubble for "do it" output once we hook up to the REPL.
 */ 
Blockly.Block.prototype.customContextMenu = function(options) {
  var yailOption = {enabled: true};
  yailOption.text = "Generate Yail";
  var myBlock = this;
  yailOption.callback = function() {
    var yailText;
    //Blockly.Yail.blockToCode1 returns a string if the block is a statement
    //and an array if the block is a value
    var yailTextOrArray = Blockly.Yail.blockToCode1(myBlock);
    if(yailTextOrArray instanceof Array){
    	yailText = yailTextOrArray[0];
    } else {
    	yailText = yailTextOrArray;
    }
    myBlock.setCommentText(yailText);
  };
  options.push(yailOption);
};
{'fraction_non_alphanumeric': 0.10062479447550148, 'fraction_numerical': 0.003946070371588293, 'mean_word_length': 4.15593220338983, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5992325', 'n_tokens_mistral': 906, 'n_tokens_neox': 898, 'n_words': 275}