text:
<?php

require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php');

/**
 * Generates a Propel module for a route definition.
 *
 * @package    symfony
 * @subpackage propel
 * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
 * @version    SVN: $Id: sfPropelGenerateModuleForRouteTask.class.php 23194 2009-10-19 16:37:13Z fabien $
 */
class sfPropelGenerateModuleForRouteTask extends sfPropelBaseTask
{
  /**
   * @see sfTask
   */
  protected function configure()
  {
    $this->addArguments(array(
      new sfCommandArgument('application', sfCommandArgument::REQUIRED, 'The application name'),
      new sfCommandArgument('route', sfCommandArgument::REQUIRED, 'The route name'),
    ));

    $this->addOptions(array(
      new sfCommandOption('theme', null, sfCommandOption::PARAMETER_REQUIRED, 'The theme name', 'default'),
      new sfCommandOption('non-verbose-templates', null, sfCommandOption::PARAMETER_NONE, 'Generate non verbose templates'),
      new sfCommandOption('singular', null, sfCommandOption::PARAMETER_REQUIRED, 'The singular name', null),
      new sfCommandOption('plural', null, sfCommandOption::PARAMETER_REQUIRED, 'The plural name', null),
      new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'),
      new sfCommandOption('actions-base-class', null, sfCommandOption::PARAMETER_REQUIRED, 'The base class for the actions', 'sfActions'),
    ));

    $this->namespace = 'propel';
    $this->name = 'generate-module-for-route';
    $this->briefDescription = 'Generates a Propel module for a route definition';

    $this->detailedDescription = <<<EOF
The [propel:generate-module-for-route|INFO] task generates a Propel module for a route definition:

  [./symfony propel:generate-module-for-route frontend article|INFO]

The task creates a module in the [%frontend%|COMMENT] application for the
[%article%|COMMENT] route definition found in [routing.yml|COMMENT].
EOF;
  }

  /**
   * @see sfTask
   */
  protected function execute($arguments = array(), $options = array())
  {
    // get configuration for the given route
    $config = new sfRoutingConfigHandler();
    $routes = $config->evaluate($this->configuration->getConfigPaths('config/routing.yml'));

    if (!isset($routes[$arguments['route']]))
    {
      throw new sfCommandException(sprintf('The route "%s" does not exist.', $arguments['route']));
    }

    $routeOptions = $routes[$arguments['route']]->getOptions();

    if (!$routes[$arguments['route']] instanceof sfPropelRouteCollection)
    {
      throw new sfCommandException(sprintf('The route "%s" is not a Propel collection route.', $arguments['route']));
    }

    $module = $routeOptions['module'];
    $model = $routeOptions['model'];

    // execute the propel:generate-module task
    $task = new sfPropelGenerateModuleTask($this->dispatcher, $this->formatter);
    $task->setCommandApplication($this->commandApplication);
    $task->setConfiguration($this->configuration);

    $this->logSection('app', sprintf('Generating module "%s" for model "%s"', $module, $model));

    return $task->run(array($arguments['application'], $module, $model), array(
      'theme'                 => $options['theme'],
      'route-prefix'          => $routeOptions['name'],
      'with-propel-route'     => true,
      'with-show'             => $routeOptions['with_show'],
      'non-verbose-templates' => $options['non-verbose-templates'],
      'singular'              => $options['singular'],
      'plural'                => $options['plural'],
      'actions-base-class'    => $options['actions-base-class'],
    ));
  }
}


text:
'use strict';

var ReactNativeFeatureFlags = require('ReactNativeFeatureFlags');
var describeStack = ReactNativeFeatureFlags.useFiber ? describe.skip : describe;

// These tests are only relevant for the Stack version of the tree hook.
// This file is for RN. There is a sibling file that has some tree hook
// tests that are still relevant in Fiber.
// TODO: remove this file when we delete Stack.

describeStack('ReactComponentTreeHook', () => {
  var React;
  var ReactNative;
  var ReactInstanceMap;
  var ReactComponentTreeHook;
  var ReactComponentTreeTestUtils;
  var createReactNativeComponentClass;
  var View;
  var Image;
  var Text;
  var PropTypes;

  beforeEach(() => {
    jest.resetModules();

    PropTypes = require('prop-types');
    React = require('react');
    ReactNative = require('react-native');
    ReactInstanceMap = require('ReactInstanceMap');
    ReactComponentTreeHook = require('ReactComponentTreeHook');
    ReactComponentTreeTestUtils = require('ReactComponentTreeTestUtils');
    View = require('View');
    createReactNativeComponentClass = require('createReactNativeComponentClass');
    Image = createReactNativeComponentClass({
      validAttributes: {},
      uiViewClassName: 'Image',
    });
    var RCText = createReactNativeComponentClass({
      validAttributes: {},
      uiViewClassName: 'RCText',
    });
    Text = class extends React.Component {
      static childContextTypes = {
        isInAParentText: PropTypes.bool,
      };

      getChildContext() {
        return {isInAParentText: true};
      }

      render() {
        return <RCText {...this.props} />;
      }
    };
  });

  function assertTreeMatches(pairs, options) {
    if (!Array.isArray(pairs[0])) {
      pairs = [pairs];
    }

    var currentElement;
    var rootInstance;

    class Wrapper extends React.Component {
      render() {
        rootInstance = ReactInstanceMap.get(this);
        return currentElement;
      }
    }

    function expectWrapperTreeToEqual(expectedTree, andStayMounted) {
      ReactComponentTreeTestUtils.expectTree(rootInstance._debugID, {
        displayName: 'Wrapper',
        children: expectedTree ? [expectedTree] : [],
      });
      var rootDisplayNames = ReactComponentTreeTestUtils.getRootDisplayNames();
      var registeredDisplayNames = ReactComponentTreeTestUtils.getRegisteredDisplayNames();
      if (!expectedTree) {
        expectDev(rootDisplayNames).toEqual([]);
        expectDev(registeredDisplayNames).toEqual([]);
      } else if (andStayMounted) {
        expectDev(rootDisplayNames).toContain('Wrapper');
        expectDev(registeredDisplayNames).toContain('Wrapper');
      }
    }

    // Mount once, render updates, then unmount.
    // Ensure the tree is correct on every step.
    pairs.forEach(([element, expectedTree]) => {
      currentElement = element;

      // Mount a new tree or update the existing tree.
      ReactNative.render(<Wrapper />, 1);
      expectWrapperTreeToEqual(expectedTree, true);

      // Purging should have no effect
      // on the tree we expect to see.
      ReactComponentTreeHook.purgeUnmountedComponents();
      expectWrapperTreeToEqual(expectedTree, true);
    });

    // Unmounting the root node should purge
    // the whole subtree automatically.
    ReactNative.unmountComponentAtNode(1);
    expectWrapperTreeToEqual(null);

    // Mount and unmount for every pair.
    // Ensure the tree is correct on every step.
    pairs.forEach(([element, expectedTree]) => {
      currentElement = element;

      // Mount a new tree.
      ReactNative.render(<Wrapper />, 1);
      expectWrapperTreeToEqual(expectedTree);

      // Unmounting should clean it up.
      ReactNative.unmountComponentAtNode(1);
      expectWrapperTreeToEqual(null);
    });
  }

  describe('mount', () => {
    it('uses displayName or Unknown for classic components', () => {
      class Foo extends React.Component {
        render() {
          return null;
        }
      }

      Foo.displayName = 'Bar';

      class Baz extends React.Component {
        render() {
          return null;
        }
      }

      class Qux extends React.Component {
        render() {
          return null;
        }
      }

      delete Qux.displayName;

      var element = <View><Foo /><Baz /><Qux /></View>;
      var tree = {
        displayName: 'View',
        element,
        children: [
          {
            displayName: 'Bar',
            children: [],
          },
          {
            displayName: 'Baz',
            children: [],
          },
          {
            displayName: 'Unknown',
            children: [],
          },
        ],
      };
      assertTreeMatches([element, tree]);
    });

    it('uses displayName, name, or ReactComponent for modern components', () => {
      class Foo extends React.Component {
        render() {
          return null;
        }
      }
      Foo.displayName = 'Bar';
      class Baz extends React.Component {
        render() {
          return null;
        }
      }
      class Qux extends React.Component {
        render() {
          return null;
        }
      }
      delete Qux.name;

      var element = <View><Foo /><Baz /><Qux /></View>;
      var tree = {
        displayName: 'View',
        children: [
          {
            displayName: 'Bar',
            children: [],
          },
          {
            displayName: 'Baz',
            children: [],
          },
          {
            // Note: Ideally fallback name should be consistent (e.g. "Unknown")
            displayName: 'ReactComponent',
            children: [],
          },
        ],
      };
      assertTreeMatches([element, tree]);
    });

    it('uses displayName, name, or Object for factory components', () => {
      function Foo() {
        return {
          render() {
            return null;
          },
        };
      }
      Foo.displayName = 'Bar';
      function Baz() {
        return {
          render() {
            return null;
          },
        };
      }
      function Qux() {
        return {
          render() {
            return null;
          },
        };
      }
      delete Qux.name;

      var element = <View><Foo /><Baz /><Qux /></View>;
      var tree = {
        displayName: 'View',
        children: [
          {
            displayName: 'Bar',
            children: [],
          },
          {
            displayName: 'Baz',
            children: [],
          },
          {
            displayName: 'Unknown',
            children: [],
          },
        ],
      };
      assertTreeMatches([element, tree]);
    });

    it('uses displayName, name, or StatelessComponent for functional components', () => {
      function Foo() {
        return null;
      }
      Foo.displayName = 'Bar';
      function Baz() {
        return null;
      }
      function Qux() {
        return null;
      }
      delete Qux.name;

      var element = <View><Foo /><Baz /><Qux /></View>;
      var tree = {
        displayName: 'View',
        children: [
          {
            displayName: 'Bar',
            children: [],
          },
          {
            displayName: 'Baz',
            children: [],
          },
          {
            displayName: 'Unknown',
            children: [],
          },
        ],
      };
      assertTreeMatches([element, tree]);
    });

    it('reports a host tree correctly', () => {
      var element = (
        <View>
          <View>
            <Text>
              Hi!
            </Text>
          </View>
          <Image />
        </View>
      );
      var tree = {
        displayName: 'View',
        element,
        children: [
          {
            displayName: 'View',
            children: [
              {
                displayName: 'Text',
                children: [
                  {
                    displayName: 'RCText',
                    children: [
                      {
                        displayName: '#text',
                        element: 'Hi!',
                        text: 'Hi!',
                      },
                    ],
                  },
                ],
              },
            ],
          },
          {
            displayName: 'Image',
            element: <Image />,
            children: [],
          },
        ],
      };
      assertTreeMatches([element, tree]);
    });

    it('reports a simple tree with composites correctly', () => {
      class Foo extends React.Component {
        render() {
          return <Image />;
        }
      }

      var element = <Foo />;
      var tree = {
        displayName: 'Foo',
        element,
        children: [
          {
            displayName: 'Image',
            element: <Image />,
            children: [],
          },
        ],
      };
      assertTreeMatches([element, tree]);
    });

    it('reports a tree with composites correctly', () => {
      class Qux extends React.Component {
        render() {
          return null;
        }
      }

      function Foo() {
        return {
          render() {
            return <Qux />;
          },
        };
      }
      function Bar({children}) {
        return <View>{children}</View>;
      }
      class Baz extends React.Component {
        render() {
          return (
            <View>
              <Foo />
              <Bar>
                <Text>Hi,</Text>
              </Bar>
              <Image />
            </View>
          );
        }
      }

      var element = <Baz />;
      var tree = {
        displayName: 'Baz',
        element,
        children: [
          {
            displayName: 'View',
            children: [
              {
                displayName: 'Foo',
                element: <Foo />,
                children: [
                  {
                    displayName: 'Qux',
                    element: <Qux />,
                    children: [],
                  },
                ],
              },
              {
                displayName: 'Bar',
                children: [
                  {
                    displayName: 'View',
                    children: [
                      {
                        displayName: 'Text',
                        children: [
                          {
                            displayName: 'RCText',
                            children: [
                              {
                                displayName: '#text',
                                element: 'Hi,',
                                text: 'Hi,',
                              },
                            ],
                          },
                        ],
                      },
                    ],
                  },
                ],
              },
              {
                displayName: 'Image',
                element: <Image />,
                children: [],
              },
            ],
          },
        ],
      };
      assertTreeMatches([element, tree]);
    });

    it('ignores null children', () => {
      class Foo extends React.Component {
        render() {
          return null;
        }
      }
      var element = <Foo />;
      var tree = {
        displayName: 'Foo',
        children: [],
      };
      assertTreeMatches([element, tree]);
    });

    it('ignores false children', () => {
      class Foo extends React.Component {
        render() {
          return false;
        }
      }
      var element = <Foo />;
      var tree = {
        displayName: 'Foo',
        children: [],
      };
      assertTreeMatches([element, tree]);
    });

    it('reports text nodes as children', () => {
      var element = <Text>{'1'}{2}</Text>;
      var tree = {
        displayName: 'Text',
        children: [
          {
            displayName: 'RCText',
            children: [
              {
                displayName: '#text',
                text: '1',
              },
              {
                displayName: '#text',
                text: '2',
              },
            ],
          },
        ],
      };
      assertTreeMatches([element, tree]);
    });

    it('reports a single text node as a child', () => {
      var element = <Text>{'1'}</Text>;
      var tree = {
        displayName: 'Text',
        children: [
          {
            displayName: 'RCText',
            children: [
              {
                displayName: '#text',
                text: '1',
              },
            ],
          },
        ],
      };
      assertTreeMatches([element, tree]);
    });

    it('reports a single number node as a child', () => {
      var element = <Text>{42}</Text>;
      var tree = {
        displayName: 'Text',
        children: [
          {
            displayName: 'RCText',
            children: [
              {
                displayName: '#text',
                text: '42',
              },
            ],
          },
        ],
      };
      assertTreeMatches([element, tree]);
    });

    it('reports a zero as a child', () => {
      var element = <Text>{0}</Text>;
      var tree = {
        displayName: 'Text',
        children: [
          {
            displayName: 'RCText',
            children: [
              {
                displayName: '#text',
                text: '0',
              },
            ],
          },
        ],
      };
      assertTreeMatches([element, tree]);
    });

    it('skips empty nodes for multiple children', () => {
      function Foo() {
        return <Image />;
      }
      var element = (
        <View>
          {false}
          <Foo />
          {null}
          <Foo />
        </View>
      );
      var tree = {
        displayName: 'View',
        element,
        children: [
          {
            displayName: 'Foo',
            element: <Foo />,
            children: [
              {
                displayName: 'Image',
                element: <Image />,
                children: [],
              },
            ],
          },
          {
            displayName: 'Foo',
            element: <Foo />,
            children: [
              {
                displayName: 'Image',
                element: <Image />,
                children: [],
              },
            ],
          },
        ],
      };
      assertTreeMatches([element, tree]);
    });
  });

  describe('update', () => {
    describe('host component', () => {
      it('updates text of a single text child', () => {
        var elementBefore = <Text>Hi.</Text>;
        var treeBefore = {
          displayName: 'Text',
          children: [
            {
              displayName: 'RCText',
              children: [
                {
                  displayName: '#text',
                  text: 'Hi.',
                },
              ],
            },
          ],
        };

        var elementAfter = <Text>Bye.</Text>;
        var treeAfter = {
          displayName: 'Text',
          children: [
            {
              displayName: 'RCText',
              children: [
                {
                  displayName: '#text',
                  text: 'Bye.',
                },
              ],
            },
          ],
        };

        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });

      it('updates from no children to a single text child', () => {
        var elementBefore = <Text />;
        var treeBefore = {
          displayName: 'Text',
          children: [
            {
              displayName: 'RCText',
              children: [],
            },
          ],
        };

        var elementAfter = <Text>Hi.</Text>;
        var treeAfter = {
          displayName: 'Text',
          children: [
            {
              displayName: 'RCText',
              children: [
                {
                  displayName: '#text',
                  text: 'Hi.',
                },
              ],
            },
          ],
        };

        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });

      it('updates from a single text child to no children', () => {
        var elementBefore = <Text>Hi.</Text>;
        var treeBefore = {
          displayName: 'Text',
          children: [
            {
              displayName: 'RCText',
              children: [
                {
                  displayName: '#text',
                  text: 'Hi.',
                },
              ],
            },
          ],
        };

        var elementAfter = <Text />;
        var treeAfter = {
          displayName: 'Text',
          children: [
            {
              displayName: 'RCText',
              children: [],
            },
          ],
        };

        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });

      it('updates from no children to multiple text children', () => {
        var elementBefore = <Text />;
        var treeBefore = {
          displayName: 'Text',
          children: [
            {
              displayName: 'RCText',
              children: [],
            },
          ],
        };

        var elementAfter = <Text>{'Hi.'}{'Bye.'}</Text>;
        var treeAfter = {
          displayName: 'Text',
          children: [
            {
              displayName: 'RCText',
              children: [
                {
                  displayName: '#text',
                  text: 'Hi.',
                },
                {
                  displayName: '#text',
                  text: 'Bye.',
                },
              ],
            },
          ],
        };

        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });

      it('updates from multiple text children to no children', () => {
        var elementBefore = <Text>{'Hi.'}{'Bye.'}</Text>;
        var treeBefore = {
          displayName: 'Text',
          children: [
            {
              displayName: 'RCText',
              children: [
                {
                  displayName: '#text',
                  text: 'Hi.',
                },
                {
                  displayName: '#text',
                  text: 'Bye.',
                },
              ],
            },
          ],
        };

        var elementAfter = <Text />;
        var treeAfter = {
          displayName: 'Text',
          children: [
            {
              displayName: 'RCText',
              children: [],
            },
          ],
        };
        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });

      it('updates from one text child to multiple text children', () => {
        var elementBefore = <Text>Hi.</Text>;
        var treeBefore = {
          displayName: 'Text',
          children: [
            {
              displayName: 'RCText',
              children: [
                {
                  displayName: '#text',
                  text: 'Hi.',
                },
              ],
            },
          ],
        };

        var elementAfter = <Text>{'Hi.'}{'Bye.'}</Text>;
        var treeAfter = {
          displayName: 'Text',
          children: [
            {
              displayName: 'RCText',
              children: [
                {
                  displayName: '#text',
                  text: 'Hi.',
                },
                {
                  displayName: '#text',
                  text: 'Bye.',
                },
              ],
            },
          ],
        };

        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });

      it('updates from multiple text children to one text child', () => {
        var elementBefore = <Text>{'Hi.'}{'Bye.'}</Text>;
        var treeBefore = {
          displayName: 'Text',
          children: [
            {
              displayName: 'RCText',
              children: [
                {
                  displayName: '#text',
                  text: 'Hi.',
                },
                {
                  displayName: '#text',
                  text: 'Bye.',
                },
              ],
            },
          ],
        };

        var elementAfter = <Text>Hi.</Text>;
        var treeAfter = {
          displayName: 'Text',
          children: [
            {
              displayName: 'RCText',
              children: [
                {
                  displayName: '#text',
                  text: 'Hi.',
                },
              ],
            },
          ],
        };
        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });

      it('updates text nodes when reordering', () => {
        var elementBefore = <Text>{'Hi.'}{'Bye.'}</Text>;
        var treeBefore = {
          displayName: 'Text',
          children: [
            {
              displayName: 'RCText',
              children: [
                {
                  displayName: '#text',
                  text: 'Hi.',
                },
                {
                  displayName: '#text',
                  text: 'Bye.',
                },
              ],
            },
          ],
        };

        var elementAfter = <Text>{'Bye.'}{'Hi.'}</Text>;
        var treeAfter = {
          displayName: 'Text',
          children: [
            {
              displayName: 'RCText',
              children: [
                {
                  displayName: '#text',
                  text: 'Bye.',
                },
                {
                  displayName: '#text',
                  text: 'Hi.',
                },
              ],
            },
          ],
        };
        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });

      it('updates host nodes when reordering with keys', () => {
        var elementBefore = (
          <View>
            <Text key="a">Hi.</Text>
            <Text key="b">Bye.</Text>
          </View>
        );
        var treeBefore = {
          displayName: 'View',
          children: [
            {
              displayName: 'Text',
              children: [
                {
                  displayName: 'RCText',
                  children: [
                    {
                      displayName: '#text',
                      text: 'Hi.',
                    },
                  ],
                },
              ],
            },
            {
              displayName: 'Text',
              children: [
                {
                  displayName: 'RCText',
                  children: [
                    {
                      displayName: '#text',
                      text: 'Bye.',
                    },
                  ],
                },
              ],
            },
          ],
        };

        var elementAfter = (
          <View>
            <Text key="b">Bye.</Text>
            <Text key="a">Hi.</Text>
          </View>
        );
        var treeAfter = {
          displayName: 'View',
          children: [
            {
              displayName: 'Text',
              children: [
                {
                  displayName: 'RCText',
                  children: [
                    {
                      displayName: '#text',
                      text: 'Bye.',
                    },
                  ],
                },
              ],
            },
            {
              displayName: 'Text',
              children: [
                {
                  displayName: 'RCText',
                  children: [
                    {
                      displayName: '#text',
                      text: 'Hi.',
                    },
                  ],
                },
              ],
            },
          ],
        };

        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });

      it('updates host nodes when reordering with keys', () => {
        var elementBefore = (
          <View>
            <Text>Hi.</Text>
            <Text>Bye.</Text>
          </View>
        );
        var treeBefore = {
          displayName: 'View',
          children: [
            {
              displayName: 'Text',
              children: [
                {
                  displayName: 'RCText',
                  children: [
                    {
                      displayName: '#text',
                      text: 'Hi.',
                    },
                  ],
                },
              ],
            },
            {
              displayName: 'Text',
              children: [
                {
                  displayName: 'RCText',
                  children: [
                    {
                      displayName: '#text',
                      text: 'Bye.',
                    },
                  ],
                },
              ],
            },
          ],
        };

        var elementAfter = (
          <View>
            <Text>Bye.</Text>
            <Text>Hi.</Text>
          </View>
        );
        var treeAfter = {
          displayName: 'View',
          children: [
            {
              displayName: 'Text',
              children: [
                {
                  displayName: 'RCText',
                  children: [
                    {
                      displayName: '#text',
                      text: 'Bye.',
                    },
                  ],
                },
              ],
            },
            {
              displayName: 'Text',
              children: [
                {
                  displayName: 'RCText',
                  children: [
                    {
                      displayName: '#text',
                      text: 'Hi.',
                    },
                  ],
                },
              ],
            },
          ],
        };

        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });

      it('updates a single composite child of a different type', () => {
        function Foo() {
          return null;
        }

        function Bar() {
          return null;
        }

        var elementBefore = <View><Foo /></View>;
        var treeBefore = {
          displayName: 'View',
          children: [
            {
              displayName: 'Foo',
              children: [],
            },
          ],
        };

        var elementAfter = <View><Bar /></View>;
        var treeAfter = {
          displayName: 'View',
          children: [
            {
              displayName: 'Bar',
              children: [],
            },
          ],
        };

        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });

      it('updates a single composite child of the same type', () => {
        function Foo({children}) {
          return children;
        }

        var elementBefore = <View><Foo><View /></Foo></View>;
        var treeBefore = {
          displayName: 'View',
          children: [
            {
              displayName: 'Foo',
              children: [
                {
                  displayName: 'View',
                  children: [],
                },
              ],
            },
          ],
        };

        var elementAfter = <View><Foo><Image /></Foo></View>;
        var treeAfter = {
          displayName: 'View',
          children: [
            {
              displayName: 'Foo',
              children: [
                {
                  displayName: 'Image',
                  children: [],
                },
              ],
            },
          ],
        };

        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });

      it('updates from no children to a single composite child', () => {
        function Foo() {
          return null;
        }

        var elementBefore = <View />;
        var treeBefore = {
          displayName: 'View',
          children: [],
        };

        var elementAfter = <View><Foo /></View>;
        var treeAfter = {
          displayName: 'View',
          children: [
            {
              displayName: 'Foo',
              children: [],
            },
          ],
        };

        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });

      it('updates from a single composite child to no children', () => {
        function Foo() {
          return null;
        }

        var elementBefore = <View><Foo /></View>;
        var treeBefore = {
          displayName: 'View',
          children: [
            {
              displayName: 'Foo',
              children: [],
            },
          ],
        };

        var elementAfter = <View />;
        var treeAfter = {
          displayName: 'View',
          children: [],
        };

        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });

      it('updates mixed children', () => {
        function Foo() {
          return <View />;
        }
        var element1 = (
          <View>
            <Text>hi</Text>
            {false}
            <Text>{42}</Text>
            {null}
            <Foo />
          </View>
        );
        var tree1 = {
          displayName: 'View',
          children: [
            {
              displayName: 'Text',
              children: [
                {
                  displayName: 'RCText',
                  children: [
                    {
                      displayName: '#text',
                      text: 'hi',
                    },
                  ],
                },
              ],
            },
            {
              displayName: 'Text',
              children: [
                {
                  displayName: 'RCText',
                  children: [
                    {
                      displayName: '#text',
                      text: '42',
                    },
                  ],
                },
              ],
            },
            {
              displayName: 'Foo',
              children: [
                {
                  displayName: 'View',
                  children: [],
                },
              ],
            },
          ],
        };

        var element2 = (
          <View>
            <Foo />
            {false}
            <Text>hi</Text>
            {null}
          </View>
        );
        var tree2 = {
          displayName: 'View',
          children: [
            {
              displayName: 'Foo',
              children: [
                {
                  displayName: 'View',
                  children: [],
                },
              ],
            },
            {
              displayName: 'Text',
              children: [
                {
                  displayName: 'RCText',
                  children: [
                    {
                      displayName: '#text',
                      text: 'hi',
                    },
                  ],
                },
              ],
            },
          ],
        };

        var element3 = (
          <View>
            <Foo />
          </View>
        );
        var tree3 = {
          displayName: 'View',
          children: [
            {
              displayName: 'Foo',
              children: [
                {
                  displayName: 'View',
                  children: [],
                },
              ],
            },
          ],
        };

        assertTreeMatches([
          [element1, tree1],
          [element2, tree2],
          [element3, tree3],
        ]);
      });
    });

    describe('functional component', () => {
      it('updates with a host child', () => {
        function Foo({children}) {
          return children;
        }

        var elementBefore = <Foo><View /></Foo>;
        var treeBefore = {
          displayName: 'Foo',
          children: [
            {
              displayName: 'View',
              children: [],
            },
          ],
        };

        var elementAfter = <Foo><Image /></Foo>;
        var treeAfter = {
          displayName: 'Foo',
          children: [
            {
              displayName: 'Image',
              children: [],
            },
          ],
        };

        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });

      it('updates from null to a host child', () => {
        function Foo({children}) {
          return children;
        }

        var elementBefore = <Foo>{null}</Foo>;
        var treeBefore = {
          displayName: 'Foo',
          children: [],
        };

        var elementAfter = <Foo><View /></Foo>;
        var treeAfter = {
          displayName: 'Foo',
          children: [
            {
              displayName: 'View',
              children: [],
            },
          ],
        };

        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });

      it('updates from a host child to null', () => {
        function Foo({children}) {
          return children;
        }

        var elementBefore = <Foo><View /></Foo>;
        var treeBefore = {
          displayName: 'Foo',
          children: [
            {
              displayName: 'View',
              children: [],
            },
          ],
        };

        var elementAfter = <Foo>{null}</Foo>;
        var treeAfter = {
          displayName: 'Foo',
          children: [],
        };

        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });

      it('updates from a host child to a composite child', () => {
        function Bar() {
          return null;
        }

        function Foo({children}) {
          return children;
        }

        var elementBefore = <Foo><View /></Foo>;
        var treeBefore = {
          displayName: 'Foo',
          children: [
            {
              displayName: 'View',
              children: [],
            },
          ],
        };

        var elementAfter = <Foo><Bar /></Foo>;
        var treeAfter = {
          displayName: 'Foo',
          children: [
            {
              displayName: 'Bar',
              children: [],
            },
          ],
        };

        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });

      it('updates from a composite child to a host child', () => {
        function Bar() {
          return null;
        }

        function Foo({children}) {
          return children;
        }

        var elementBefore = <Foo><Bar /></Foo>;
        var treeBefore = {
          displayName: 'Foo',
          children: [
            {
              displayName: 'Bar',
              children: [],
            },
          ],
        };

        var elementAfter = <Foo><View /></Foo>;
        var treeAfter = {
          displayName: 'Foo',
          children: [
            {
              displayName: 'View',
              children: [],
            },
          ],
        };

        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });

      it('updates from null to a composite child', () => {
        function Bar() {
          return null;
        }

        function Foo({children}) {
          return children;
        }

        var elementBefore = <Foo>{null}</Foo>;
        var treeBefore = {
          displayName: 'Foo',
          children: [],
        };

        var elementAfter = <Foo><Bar /></Foo>;
        var treeAfter = {
          displayName: 'Foo',
          children: [
            {
              displayName: 'Bar',
              children: [],
            },
          ],
        };

        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });

      it('updates from a composite child to null', () => {
        function Bar() {
          return null;
        }

        function Foo({children}) {
          return children;
        }

        var elementBefore = <Foo><Bar /></Foo>;
        var treeBefore = {
          displayName: 'Foo',
          children: [
            {
              displayName: 'Bar',
              children: [],
            },
          ],
        };

        var elementAfter = <Foo>{null}</Foo>;
        var treeAfter = {
          displayName: 'Foo',
          children: [],
        };

        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });
    });

    describe('class component', () => {
      it('updates with a host child', () => {
        class Foo extends React.Component {
          render() {
            return this.props.children;
          }
        }

        var elementBefore = <Foo><View /></Foo>;
        var treeBefore = {
          displayName: 'Foo',
          children: [
            {
              displayName: 'View',
              children: [],
            },
          ],
        };

        var elementAfter = <Foo><Image /></Foo>;
        var treeAfter = {
          displayName: 'Foo',
          children: [
            {
              displayName: 'Image',
              children: [],
            },
          ],
        };

        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });

      it('updates from null to a host child', () => {
        class Foo extends React.Component {
          render() {
            return this.props.children;
          }
        }

        var elementBefore = <Foo>{null}</Foo>;
        var treeBefore = {
          displayName: 'Foo',
          children: [],
        };

        var elementAfter = <Foo><View /></Foo>;
        var treeAfter = {
          displayName: 'Foo',
          children: [
            {
              displayName: 'View',
              children: [],
            },
          ],
        };

        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });

      it('updates from a host child to null', () => {
        class Foo extends React.Component {
          render() {
            return this.props.children;
          }
        }

        var elementBefore = <Foo><View /></Foo>;
        var treeBefore = {
          displayName: 'Foo',
          children: [
            {
              displayName: 'View',
              children: [],
            },
          ],
        };

        var elementAfter = <Foo>{null}</Foo>;
        var treeAfter = {
          displayName: 'Foo',
          children: [],
        };

        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });

      it('updates from a host child to a composite child', () => {
        class Bar extends React.Component {
          render() {
            return null;
          }
        }

        class Foo extends React.Component {
          render() {
            return this.props.children;
          }
        }

        var elementBefore = <Foo><View /></Foo>;
        var treeBefore = {
          displayName: 'Foo',
          children: [
            {
              displayName: 'View',
              children: [],
            },
          ],
        };

        var elementAfter = <Foo><Bar /></Foo>;
        var treeAfter = {
          displayName: 'Foo',
          children: [
            {
              displayName: 'Bar',
              children: [],
            },
          ],
        };

        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });

      it('updates from a composite child to a host child', () => {
        class Bar extends React.Component {
          render() {
            return null;
          }
        }

        class Foo extends React.Component {
          render() {
            return this.props.children;
          }
        }

        var elementBefore = <Foo><Bar /></Foo>;
        var treeBefore = {
          displayName: 'Foo',
          children: [
            {
              displayName: 'Bar',
              children: [],
            },
          ],
        };

        var elementAfter = <Foo><View /></Foo>;
        var treeAfter = {
          displayName: 'Foo',
          children: [
            {
              displayName: 'View',
              children: [],
            },
          ],
        };

        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });

      it('updates from null to a composite child', () => {
        class Bar extends React.Component {
          render() {
            return null;
          }
        }

        class Foo extends React.Component {
          render() {
            return this.props.children;
          }
        }

        var elementBefore = <Foo>{null}</Foo>;
        var treeBefore = {
          displayName: 'Foo',
          children: [],
        };

        var elementAfter = <Foo><Bar /></Foo>;
        var treeAfter = {
          displayName: 'Foo',
          children: [
            {
              displayName: 'Bar',
              children: [],
            },
          ],
        };

        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });

      it('updates from a composite child to null', () => {
        class Bar extends React.Component {
          render() {
            return null;
          }
        }

        class Foo extends React.Component {
          render() {
            return this.props.children;
          }
        }

        var elementBefore = <Foo><Bar /></Foo>;
        var treeBefore = {
          displayName: 'Foo',
          children: [
            {
              displayName: 'Bar',
              children: [],
            },
          ],
        };

        var elementAfter = <Foo>{null}</Foo>;
        var treeAfter = {
          displayName: 'Foo',
          children: [],
        };

        assertTreeMatches([
          [elementBefore, treeBefore],
          [elementAfter, treeAfter],
        ]);
      });
    });
  });

  it('tracks owner correctly', () => {
    class Foo extends React.Component {
      render() {
        return <Bar><Text>Hi.</Text></Bar>;
      }
    }
    function Bar({children}) {
      return <View>{children}<Text>Mom</Text></View>;
    }

    // Note that owner is not calculated for text nodes
    // because they are not created from real elements.
    var element = <View><Foo /></View>;
    var tree = {
      displayName: 'View',
      children: [
        {
          displayName: 'Foo',
          children: [
            {
              displayName: 'Bar',
              ownerDisplayName: 'Foo',
              children: [
                {
                  displayName: 'View',
                  ownerDisplayName: 'Bar',
                  children: [
                    {
                      displayName: 'Text',
                      ownerDisplayName: 'Foo',
                      children: [
                        {
                          displayName: 'RCText',
                          ownerDisplayName: 'Text',
                          children: [
                            {
                              displayName: '#text',
                              text: 'Hi.',
                            },
                          ],
                        },
                      ],
                    },
                    {
                      displayName: 'Text',
                      ownerDisplayName: 'Bar',
                      children: [
                        {
                          displayName: 'RCText',
                          ownerDisplayName: 'Text',
                          children: [
                            {
                              displayName: '#text',
                              text: 'Mom',
                            },
                          ],
                        },
                      ],
                    },
                  ],
                },
              ],
            },
          ],
        },
      ],
    };
    assertTreeMatches([element, tree], {includeOwnerDisplayName: true});
  });

  it('purges unmounted components automatically', () => {
    var renderBar = true;
    var fooInstance;
    var barInstance;

    class Foo extends React.Component {
      render() {
        fooInstance = ReactInstanceMap.get(this);
        return renderBar ? <Bar /> : null;
      }
    }

    class Bar extends React.Component {
      render() {
        barInstance = ReactInstanceMap.get(this);
        return null;
      }
    }

    ReactNative.render(<Foo />, 1);
    ReactComponentTreeTestUtils.expectTree(
      barInstance._debugID,
      {
        displayName: 'Bar',
        parentDisplayName: 'Foo',
        parentID: fooInstance._debugID,
        children: [],
      },
      'Foo',
    );

    renderBar = false;
    ReactNative.render(<Foo />, 1);
    ReactComponentTreeTestUtils.expectTree(
      barInstance._debugID,
      {
        displayName: 'Unknown',
        children: [],
        parentID: null,
      },
      'Foo',
    );

    ReactNative.unmountComponentAtNode(1);
    ReactComponentTreeTestUtils.expectTree(
      barInstance._debugID,
      {
        displayName: 'Unknown',
        children: [],
        parentID: null,
      },
      'Foo',
    );
  });

  it('reports update counts', () => {
    ReactNative.render(<View />, 1);
    var viewID = ReactComponentTreeHook.getRootIDs()[0];
    expectDev(ReactComponentTreeHook.getUpdateCount(viewID)).toEqual(0);

    ReactNative.render(<Image />, 1);
    var imageID = ReactComponentTreeHook.getRootIDs()[0];
    expectDev(ReactComponentTreeHook.getUpdateCount(viewID)).toEqual(0);
    expectDev(ReactComponentTreeHook.getUpdateCount(imageID)).toEqual(0);

    ReactNative.render(<Image />, 1);
    expectDev(ReactComponentTreeHook.getUpdateCount(viewID)).toEqual(0);
    expectDev(ReactComponentTreeHook.getUpdateCount(imageID)).toEqual(1);

    ReactNative.render(<Image />, 1);
    expectDev(ReactComponentTreeHook.getUpdateCount(viewID)).toEqual(0);
    expectDev(ReactComponentTreeHook.getUpdateCount(imageID)).toEqual(2);

    ReactNative.unmountComponentAtNode(1);
    expectDev(ReactComponentTreeHook.getUpdateCount(viewID)).toEqual(0);
    expectDev(ReactComponentTreeHook.getUpdateCount(imageID)).toEqual(0);
  });

  it('does not report top-level wrapper as a root', () => {
    ReactNative.render(<View><Image /></View>, 1);
    expectDev(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual([
      'View',
    ]);

    ReactNative.render(<View><Text /></View>, 1);
    expectDev(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual([
      'View',
    ]);

    ReactNative.unmountComponentAtNode(1);
    expectDev(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual([]);
    expectDev(ReactComponentTreeTestUtils.getRegisteredDisplayNames()).toEqual(
      [],
    );
  });
});

redpajama_set_name: RedPajamaGithub


text:
//#define LOG

using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.IO;

namespace ICSimulator
{
    public abstract class Router
    {
        public Coord coord;
        public int ID { get { return coord.ID; } }

        public Link[] linkOut = new Link[6];
        public Link[] linkIn = new Link[6];
        public Router[] neigh = new Router[6];
        public int neighbors;

        protected string routerName;
        protected Node m_n;

        // Keep track of the current router's average queue length over the
        // last INJ_RATE_WIN cycles
        public const int AVG_QLEN_WIN=1000;
        public float avg_qlen;
        public int[] qlen_win;
        public int qlen_ptr;
        public int qlen_count;
        public ulong m_lastInj;
        public ulong last_starve, starve_interval;

        // --------------------------------------------------------------------

        public struct PreferredDirection
        {
            public int xDir;
            public int yDir;
			public int zDir;
        }

		public Router(RingCoord rc, bool isNode)
        {
        	int id = RingCoord.getIDfromRingID(rc.ID);
            coord = new Coord(id);

			if(isNode)
            	m_n = Simulator.network.nodes[ID];
            routerName = "Router";

            neighbors = 0;

            m_lastInj = 0;
            last_starve = 0;
            starve_interval = 0;

            qlen_win = new int[AVG_QLEN_WIN];
        }

        public Router(Coord myCoord)
        {
            coord = myCoord;

            m_n = Simulator.network.nodes[ID];
            routerName = "Router";

            neighbors = 0;

            m_lastInj = 0;
            last_starve = 0;
            starve_interval = 0;

            qlen_win = new int[AVG_QLEN_WIN];
        }

        public void setNode(Node n)
        {
            m_n = n;
        }

        /********************************************************
         * PUBLIC API
         ********************************************************/

        // called from Network
        public void doStep()
        {
            statsInput();
            _doStep();
            statsOutput();
        }

        protected abstract void _doStep(); // called from Network

        public abstract bool canInjectFlit(Flit f); // called from Processor
        public abstract void InjectFlit(Flit f); // called from Processor

        public virtual int rank(Flit f1, Flit f2) { return 0; }

        // finally, subclasses should call myProcessor.ejectFlit() whenever a flit
        // arrives (or is part of a reassembled packet ready to be delivered, or whatever)

        // also, subclasses should call statsInput() before removing
        // inputs, statsOutput() after placing outputs, and
        // statsInjectFlit(f) if a flit is injected,
        // and statsEjectFlit(f) if a flit is ejected.

        // for flush/retry mechanisms: clear all router state.
        public virtual void flush() { }

        /********************************************************
         * ROUTING HELPERS
         ********************************************************/

        protected virtual PreferredDirection determineDirection(Flit f)
        {
            return determineDirection(f, new Coord(0, 0));
        }

        protected PreferredDirection determineDirection(Flit f, Coord current)
        {
            PreferredDirection pd;
            pd.xDir = Simulator.DIR_NONE;
            pd.yDir = Simulator.DIR_NONE;
			pd.zDir = Simulator.DIR_NONE;
            if (f.state == Flit.State.Placeholder) return pd;

            //if (f.packet.ID == 238)
            //    Console.WriteLine("packet 238 at ID ({0},{1}), wants ({2},{3})", current.x, current.y, f.packet.dest.x, f.packet.dest.y);

            return determineDirection(f.dest);
        }

        protected PreferredDirection determineDirection(Coord c)
        {
            PreferredDirection pd;
            pd.xDir = Simulator.DIR_NONE;
            pd.yDir = Simulator.DIR_NONE;
            pd.zDir = Simulator.DIR_NONE;

            if(Config.torus) {
              int x_sdistance = Math.Abs(c.x - coord.x);
              int x_wdistance = Config.network_nrX - Math.Abs(c.x - coord.x);
              int y_sdistance = Math.Abs(c.y - coord.y);
              int y_wdistance = Config.network_nrY - Math.Abs(c.y - coord.y);
              bool x_dright, y_ddown;

              x_dright = coord.x < c.x;
              y_ddown = c.y < coord.y;

              if(c.x == coord.x)
                pd.xDir = Simulator.DIR_NONE;
              else if(x_sdistance < x_wdistance)
                pd.xDir = (x_dright) ? Simulator.DIR_RIGHT : Simulator.DIR_LEFT;
              else
                pd.xDir = (x_dright) ? Simulator.DIR_LEFT : Simulator.DIR_RIGHT;

              if(c.y == coord.y)
                pd.yDir = Simulator.DIR_NONE;
              else if(y_sdistance < y_wdistance)
                pd.yDir = (y_ddown) ? Simulator.DIR_DOWN : Simulator.DIR_UP;
              else
                pd.yDir = (y_ddown) ? Simulator.DIR_UP : Simulator.DIR_DOWN;

            } else {
              if (c.x > coord.x)
                  pd.xDir = Simulator.DIR_RIGHT;
              else if (c.x < coord.x)
                  pd.xDir = Simulator.DIR_LEFT;
              else
                  pd.xDir = Simulator.DIR_NONE;

              if (c.y > coord.y)
                  pd.yDir = Simulator.DIR_UP;
              else if (c.y < coord.y)
                  pd.yDir = Simulator.DIR_DOWN;
              else
                  pd.yDir = Simulator.DIR_NONE;
            }

            if (Config.dor_only && pd.xDir != Simulator.DIR_NONE)
                pd.yDir = Simulator.DIR_NONE;

            return pd;
        }

        // returns true if the direction is good for this packet.
        protected bool isDirectionProductive(Coord dest, int direction)
        {
            bool answer = false;
            switch (direction)
            {
                case Simulator.DIR_UP:    answer = (dest.y > coord.y); break;
                case Simulator.DIR_RIGHT: answer = (dest.x > coord.x); break;
                case Simulator.DIR_LEFT:  answer = (dest.x < coord.x); break;
                case Simulator.DIR_DOWN:  answer = (dest.y < coord.y); break;
                default: throw new Exception("This function shouldn't be called in this case!");
            }
            return answer;
        }

        protected virtual int dimension_order_route(Flit f)
        {
            if (f.packet.dest.x < coord.x)
                return Simulator.DIR_LEFT;
            else if (f.packet.dest.x > coord.x)
                return Simulator.DIR_RIGHT;
            else if (f.packet.dest.y < coord.y)
                return Simulator.DIR_DOWN;
            else if (f.packet.dest.y > coord.y)
                return Simulator.DIR_UP;
            else //if the destination's coordinates are equal to the router's coordinates
                return Simulator.DIR_UP;
        }

        /********************************************************
         * STATISTICS
         ********************************************************/
        protected int incomingFlits;
        protected virtual void statsInput()
        {
            int goldenCount = 0;
            incomingFlits = 0;
            for (int i = 0; i < 4; i++)
            {
                if (linkIn[i] != null && linkIn[i].Out != null)
                {
                    linkIn[i].Out.Deflected = false;

                    if (Simulator.network.golden.isGolden(linkIn[i].Out))
                        goldenCount++;
                    incomingFlits++;
                }
            }

            Simulator.stats.golden_pernode.Add(goldenCount);
            Simulator.stats.golden_bycount[goldenCount].Add();

            Simulator.stats.traversals_pernode[incomingFlits].Add();
            //Simulator.stats.traversals_pernode_bysrc[ID,incomingFlits].Add();
        }

        protected virtual void statsOutput()
        {
            int deflected = 0;
            int unproductive = 0;
            int traversals = 0;
            for (int i = 0; i < 4; i++)
            {
                if (linkOut[i] != null && linkOut[i].In != null)
                {
                    if (linkOut[i].In.Deflected)
                    {
                        // deflected! (may still be productive, depending on deflection definition/DOR used)
                        deflected++;
                        linkOut[i].In.nrOfDeflections++;
                        Simulator.stats.deflect_flit_byloc[ID].Add();

                        if (linkOut[i].In.packet != null)
                        {
                            Simulator.stats.total_deflected.Add();

                            // Golden counters of deflections
                            if(Simulator.network.golden.isGolden(linkOut[i].In)) {
                                Simulator.stats.golden_deflected.Add();
                                Simulator.stats.golden_deflect_flit_byloc[ID].Add();
                                Simulator.stats.golden_deflect_flit_bysrc[linkOut[i].In.packet.src.ID].Add();
                                Simulator.stats.golden_deflect_flit_byreq[linkOut[i].In.packet.requesterID].Add();
                            }
                            Simulator.stats.deflect_flit_bysrc[linkOut[i].In.packet.src.ID].Add();
                            Simulator.stats.deflect_flit_byreq[linkOut[i].In.packet.requesterID].Add();
                        }
                    }

                    if (!isDirectionProductive(linkOut[i].In.dest, i))
                    {
                        //unproductive!
                        unproductive++;
                        Simulator.stats.unprod_flit_byloc[ID].Add();

                        if (linkOut[i].In.packet != null)
                            Simulator.stats.unprod_flit_bysrc[linkOut[i].In.packet.src.ID].Add();
                    }
                    traversals++;
                    //linkOut[i].In.deflectTest();
                }
            }

            Simulator.stats.deflect_flit.Add(deflected);
            Simulator.stats.deflect_flit_byinc[incomingFlits].Add(deflected);
            Simulator.stats.unprod_flit.Add(unproductive);
            Simulator.stats.unprod_flit_byinc[incomingFlits].Add(unproductive);
            Simulator.stats.flit_traversals.Add(traversals);

            int qlen = m_n.RequestQueueLen;

            qlen_count -= qlen_win[qlen_ptr];
            qlen_count += qlen;

            // Compute the average queue length
            qlen_win[qlen_ptr] = qlen;
            if(++qlen_ptr >= AVG_QLEN_WIN) qlen_ptr=0;

            avg_qlen = (float)qlen_count / (float)AVG_QLEN_WIN;

        }

        protected virtual void statsInjectFlit(Flit f)
        {
            //if (f.packet.src.ID == 3) Console.WriteLine("inject flit: packet {0}, seq {1}",
            //        f.packet.ID, f.flitNr);

            Simulator.stats.inject_flit.Add();
            if (f.isHeadFlit) Simulator.stats.inject_flit_head.Add();
            if (f.packet != null)
            {
                Simulator.stats.inject_flit_bysrc[f.packet.src.ID].Add();
                //Simulator.stats.inject_flit_srcdest[f.packet.src.ID, f.packet.dest.ID].Add();
            }

            if (f.packet != null && f.packet.injectionTime == ulong.MaxValue)
                f.packet.injectionTime = Simulator.CurrentRound;
            f.injectionTime = Simulator.CurrentRound;

            ulong hoq = Simulator.CurrentRound - m_lastInj;
            m_lastInj = Simulator.CurrentRound;

            Simulator.stats.hoq_latency.Add(hoq);
            Simulator.stats.hoq_latency_bysrc[coord.ID].Add(hoq);
        }

        protected virtual void statsEjectFlit(Flit f)
        {
            //if (f.packet.src.ID == 3) Console.WriteLine("eject flit: packet {0}, seq {1}",
            //        f.packet.ID, f.flitNr);

            // per-flit latency stats
            ulong net_latency = Simulator.CurrentRound - f.injectionTime;
            ulong total_latency = Simulator.CurrentRound - f.packet.creationTime;
            ulong inj_latency = total_latency - net_latency;

            Simulator.stats.flit_inj_latency.Add(inj_latency);
            Simulator.stats.flit_net_latency.Add(net_latency);
            Simulator.stats.flit_total_latency.Add(inj_latency);

            Simulator.stats.eject_flit.Add();
            Simulator.stats.eject_flit_bydest[f.packet.dest.ID].Add();

            int minpath = Math.Abs(f.packet.dest.x - f.packet.src.x) + Math.Abs(f.packet.dest.y - f.packet.src.y);
            Simulator.stats.minpath.Add(minpath);
            Simulator.stats.minpath_bysrc[f.packet.src.ID].Add(minpath);

            //f.dumpDeflections();
            Simulator.stats.deflect_perdist[f.distance].Add(f.nrOfDeflections);
            if(f.nrOfDeflections!=0)
                Simulator.stats.deflect_perflit_byreq[f.packet.requesterID].Add(f.nrOfDeflections);

            int shortest_path = Math.Abs(f.packet.src.x - f.packet.dest.x) +
        						Math.Abs(f.packet.src.y - f.packet.dest.y);

            if(f.wasSilver)
            {
                Simulator.stats.silver_latency.Add(net_latency);
                Simulator.stats.silver_ejected.Add();
                Simulator.stats.silver_shortest_path.Add(shortest_path);
                Simulator.stats.silver_totalFlits.Add();
                Simulator.stats.silver_hops.Add(f.hops);
                Simulator.stats.silver_nrWasSilver.Add(f.nrWasSilver);
                Simulator.stats.silver_nrEnteredResubmitBuffer.Add(f.rebufEnteredCount);
                Simulator.stats.silver_nrOfDeflections.Add(f.nrWasDeflected);

            }

            if(f.wasInRebuf)
            {
            	Simulator.stats.rebuf_latency.Add(net_latency);
            	Simulator.stats.rebuf_ejected.Add();
            	Simulator.stats.rebuf_shortest_path.Add(shortest_path);
    			Simulator.stats.rebuf_totalFlits.Add();
    			Simulator.stats.rebuf_hops.Add(f.hops);
                Simulator.stats.rebuf_nrEnteredResubmitBuffer.Add(f.rebufEnteredCount);
                Simulator.stats.rebuf_nrOfDeflections.Add(f.nrWasDeflected);
            }
            else if(f.wasDeflected)
            {
                Simulator.stats.prio_latency.Add(net_latency);
            	Simulator.stats.prio_ejected.Add();
            	Simulator.stats.prio_shortest_path.Add(shortest_path);
    			Simulator.stats.prio_totalFlits.Add();
    			Simulator.stats.prio_hops.Add(f.hops);
                Simulator.stats.prio_nrOfDeflections.Add(f.nrWasDeflected);
      		}
            else
            {
            	Simulator.stats.none_latency.Add(net_latency);
            	Simulator.stats.none_ejected.Add();
            	Simulator.stats.none_shortest_path.Add(shortest_path);
    			Simulator.stats.none_totalFlits.Add();
    			Simulator.stats.none_hops.Add(f.hops);
                Simulator.stats.none_nrOfDeflections.Add(f.nrWasDeflected);
            }
        }

        protected virtual void statsEjectPacket(Packet p)
        {
            ulong net_latency = Simulator.CurrentRound - p.injectionTime;
            ulong total_latency = Simulator.CurrentRound - p.creationTime;

            Simulator.stats.net_latency.Add(net_latency);
            Simulator.stats.total_latency.Add(total_latency);
            Simulator.stats.net_latency_bysrc[p.src.ID].Add(net_latency);
            Simulator.stats.net_latency_bydest[p.dest.ID].Add(net_latency);
            //Simulator.stats.net_latency_srcdest[p.src.ID, p.dest.ID].Add(net_latency);
            Simulator.stats.total_latency_bysrc[p.src.ID].Add(total_latency);
            Simulator.stats.total_latency_bydest[p.dest.ID].Add(total_latency);
            //Simulator.stats.total_latency_srcdest[p.src.ID, p.dest.ID].Add(total_latency);

        }

        public override string ToString()
        {
            return routerName + " (" + coord.x + "," + coord.y + ")";
        }

        public string getRouterName()
        {
            return routerName;
        }

        public Router neighbor(int dir)
        {
            int x, y;
            switch (dir)
            {
                case Simulator.DIR_UP:    x = coord.x;     y = coord.y + 1; break;
                case Simulator.DIR_DOWN:  x = coord.x;     y = coord.y - 1; break;
                case Simulator.DIR_RIGHT: x = coord.x + 1; y = coord.y;     break;
                case Simulator.DIR_LEFT:  x = coord.x - 1; y = coord.y;     break;
                default: return null;
            }
            // mesh, not torus: detect edge
            if (x < 0 || x >= Config.network_nrX || y < 0 || y >= Config.network_nrY) return null;

            return Simulator.network.routers[Coord.getIDfromXY(x, y)];
        }

        public void close()
        {
        }

        public virtual void visitFlits(Flit.Visitor fv)
        {
        }

        public virtual void statsStarve(Flit f)
        {
            Simulator.stats.starve_flit.Add();
            Simulator.stats.starve_flit_bysrc[f.packet.src.ID].Add();

            if (last_starve == Simulator.CurrentRound - 1) {
              starve_interval++;
            } else {
              Simulator.stats.starve_interval_bysrc[f.packet.src.ID].Add(starve_interval);
              starve_interval = 0;
            }

            last_starve = Simulator.CurrentRound;
        }

        public virtual int linkUtil()
        {
            int count = 0;
            for (int i = 0; i < 4; i++)
                if (linkIn[i] != null && linkIn[i].Out != null)
                    count++;
            return count;
        }

        public double linkUtilNeighbors()
        {
            int tot = 0, used = 0;
            for (int dir = 0; dir < 4; dir++)
            {
                Router n = neighbor(dir);
                if (n == null) continue;
                tot += n.neighbors;
                used += n.linkUtil();
            }

            return (double)used / tot;
        }
    }
}


text:
using Leak.Networking.Core;
using Leak.Peer.Sender.Core;

namespace Leak.Peer.Sender.Tests
{
    public class SenderUnknown : SenderMessage, NetworkOutgoingMessage
    {
        public string Type
        {
            get { return "unknown"; }
        }

        public NetworkOutgoingMessage Apply(byte id)
        {
            return this;
        }

        public int Length
        {
            get { return 5; }
        }

        public void ToBytes(DataBlock block)
        {
        }

        public void Release()
        {
        }
    }
}


text:
package com.baseprogramming.pdwriter.units;

public class PdPica implements PdUnit
{
    private final float pica;
    private final float points;

    public PdPica(float pica)
    {
        this.pica = pica;
        points=this.pica * PdUnit.POINTS_PER_PICA;
    }

    public float getPica()
    {
        return pica;
    }

    @Override
    public float getPoints()
    {
        return points;
    }

    @Override
    public int hashCode()
    {
        int hash = 7;
        hash = 29 * hash + Float.floatToIntBits(this.points);
        return hash;
    }

    @Override public String toString()
    {
        return Float.toString(points);
    }

    @Override
    public boolean equals(Object obj)
    {
        if (this == obj)
        {
            return true;
        }
        if (obj == null)
        {
            return false;
        }
        if (getClass() != obj.getClass())
        {
            return false;
        }
        final PdPica other = (PdPica) obj;

        return (Float.floatToIntBits(this.points) != Float.floatToIntBits(other.points));

    }

    @Override
    public int compareTo(PdUnit other)
    {
        if(other == null)
        {
            throw new NullPointerException("PDUnit argument is null");
        }

        return Float.compare(points, other.getPoints());
    }

}


text:
package org.easybatch.core.reader;

import org.easybatch.core.api.RecordReader;
import org.easybatch.core.api.RecordReaderClosingException;
import org.easybatch.core.api.RecordReaderOpeningException;
import org.easybatch.core.api.RecordReadingException;
import org.easybatch.core.record.MultiRecord;

import static org.easybatch.core.util.Utils.checkArgument;
import static org.easybatch.core.util.Utils.checkNotNull;

/**
 * Read a chunk of records at a time.
 *
 * @author Mahmoud Ben Hassine (mahmoud@benhassine.fr)
 */
public abstract class MultiRecordReader implements RecordReader {

    protected RecordReader delegate;

    protected int chunkSize;

    protected long currentRecordNumber;

    public MultiRecordReader(final int chunkSize, final RecordReader delegate) {
        checkArgument(chunkSize >= 1, "chunk size must be greater than or equal to 1");
        checkNotNull(delegate, "delegate record reader");
        this.chunkSize = chunkSize;
        this.delegate = delegate;
    }

    public void open() throws RecordReaderOpeningException {
        delegate.open();
    }

    public abstract boolean hasNextRecord();

    public abstract MultiRecord readNextRecord() throws RecordReadingException;

    public Long getTotalRecords() {
        return delegate.getTotalRecords();
    }

    public String getDataSourceName() {
        return delegate.getDataSourceName();
    }

    public void close() throws RecordReaderClosingException {
        delegate.close();
    }
}


text:
package org.axonframework.eventstore.jpa;

import java.sql.SQLException;

/**
 * SQLStateResolver is an implementation of PersistenceExceptionResolver used to resolve sql state values to see if
 * it violates a unique key constraint.
 *

 * SQL state codes are standardized - the leading two characters identifying the category. Integrity constraint
 * violations are in category 23. Some database systems further specify these state codes, e.g. postgres uses 23505 for a
 * unique key violation.
 *
 * @author Jochen Munz
 */
public class SQLStateResolver implements org.axonframework.common.jdbc.PersistenceExceptionResolver {

    private static final String INTEGRITY_CONSTRAINT_VIOLATION_CODE = "23";
    private String checkCode = null;

    /**
     * Constructor that uses the standard SQL state category for the check.
     */
    public SQLStateResolver() {
        checkCode = INTEGRITY_CONSTRAINT_VIOLATION_CODE;
    }

    /**
     * Constructor that can be used to supply a specific SQL state code for the check.
     *

     * The check is done using startsWith(), supplying a substring of the state code is ok.
     *
     * @param checkState The state string that is used in the check.
     */
    public SQLStateResolver(String checkState) {
        this.checkCode = checkState;
    }

    @Override
    public boolean isDuplicateKeyViolation(Exception exception) {
        boolean isDuplicateKey = false;
        SQLException sqlException = findSQLException(exception);
        if (sqlException != null && sqlException.getSQLState() != null) {
            if (sqlException.getSQLState().startsWith(checkCode)) {
                isDuplicateKey = true;
            }
        }
        return isDuplicateKey;
    }

    private SQLException findSQLException(Throwable exception) {
        SQLException sqlException = null;
        while (sqlException == null && exception != null) {
            if (exception instanceof SQLException) {
                sqlException = (SQLException) exception;
            } else {
                exception = exception.getCause();
            }
        }
        return sqlException;
    }
}


text:
require 'spec_helper'

module ModelObserver
  describe "#find_by_sql" do
    it "should publish notifications of instantiation when #find_by_sql called" do
      Author.all.to_a
      expect(ActiveSupport::Notifications.instrumenter).to receive(:instrument).with("instantiate.model_observer", kind_of(Hash))
      Author.all.to_a
    end
  end
end


text:
<!DOCTYPE html>

  <title>LifeItUp Web Admin</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

  <link rel="stylesheet/less" type="text/css" href="assets/style/lifeitup.less" />

          Edit a section

              <col class="col-50">
              <col class="col-10">
              <col class="col-10">
              <col class="col-10">
              <col class="col-10">
              <col class="col-10">

                  Section name
                  Type
                  View online
                  Hide/Show
                  Remove
                  Edit

                  90's video games

                      FPS

                    <button class="btn btn-default" data-toggle="popover" data-placement="left" title="" data-content="Are you sure you want to delete this server?
DeleteCancel" data-trigger="focus" data-html="true" data-original-title="Remove server">

                    </button>

                  90's video games

                      Adventure

                    <button class="btn btn-default" data-toggle="popover" data-placement="left" title="" data-content="Are you sure you want to delete this server?
DeleteCancel" data-trigger="focus" data-html="true" data-original-title="Remove server">

                    </button>

                  90's video games

                      Fighting

                    <button class="btn btn-default" data-toggle="popover" data-placement="left" title="" data-content="Are you sure you want to delete this server?
DeleteCancel" data-trigger="focus" data-html="true" data-original-title="Remove server">

                    </button>

                  90's video games

                      Online multiplayer

                    <button class="btn btn-default" data-toggle="popover" data-placement="left" title="" data-content="Are you sure you want to delete this server?
DeleteCancel" data-trigger="focus" data-html="true" data-original-title="Remove server">

                    </button>

                  90's video games

                      Arcade

                    <button class="btn btn-default" data-toggle="popover" data-placement="left" title="" data-content="Are you sure you want to delete this server?
DeleteCancel" data-trigger="focus" data-html="true" data-original-title="Remove server">

                    </button>


text:
using System;
using System.Linq;

namespace Microsoft.Azure.Management.DataLake.AnalyticsJob.Models
{
    /// <summary>
    /// The Data Lake Analytics U-SQL job statistics vertex stage information.
    /// </summary>
    public partial class JobStatisticsVertexStage
    {
        private long _dataRead;

        /// <summary>
        /// Optional. Gets or sets the amount of data read, in bytes.
        /// </summary>
        public long DataRead
        {
            get { return this._dataRead; }
            set { this._dataRead = value; }
        }

        private long _dataReadCrossPod;

        /// <summary>
        /// Optional. Gets or sets the amount of data read across multiple
        /// pods, in bytes.
        /// </summary>
        public long DataReadCrossPod
        {
            get { return this._dataReadCrossPod; }
            set { this._dataReadCrossPod = value; }
        }

        private long _dataReadIntraPod;

        /// <summary>
        /// Optional. Gets or sets the amount of data read in one pod, in bytes.
        /// </summary>
        public long DataReadIntraPod
        {
            get { return this._dataReadIntraPod; }
            set { this._dataReadIntraPod = value; }
        }

        private long _dataToRead;

        /// <summary>
        /// Optional. Gets or sets the amount of data remaining to be read, in
        /// bytes.
        /// </summary>
        public long DataToRead
        {
            get { return this._dataToRead; }
            set { this._dataToRead = value; }
        }

        private long _dataWritten;

        /// <summary>
        /// Optional. Gets or sets the amount of data written, in bytes.
        /// </summary>
        public long DataWritten
        {
            get { return this._dataWritten; }
            set { this._dataWritten = value; }
        }

        private int? _duplicateDiscardCount;

        /// <summary>
        /// Optional. Gets or sets the number of duplicates that were discarded.
        /// </summary>
        public int? DuplicateDiscardCount
        {
            get { return this._duplicateDiscardCount; }
            set { this._duplicateDiscardCount = value; }
        }

        private int? _failedCount;

        /// <summary>
        /// Optional. Gets or sets the number of failures that occured in this
        /// stage.
        /// </summary>
        public int? FailedCount
        {
            get { return this._failedCount; }
            set { this._failedCount = value; }
        }

        private long _maxVertexDataRead;

        /// <summary>
        /// Optional. Gets or sets the maximum amount of data read in a single
        /// vertex, in bytes.
        /// </summary>
        public long MaxVertexDataRead
        {
            get { return this._maxVertexDataRead; }
            set { this._maxVertexDataRead = value; }
        }

        private long _minVertexDataRead;

        /// <summary>
        /// Optional. Gets or sets the minimum amount of data read in a single
        /// vertex, in bytes.
        /// </summary>
        public long MinVertexDataRead
        {
            get { return this._minVertexDataRead; }
            set { this._minVertexDataRead = value; }
        }

        private int? _readFailureCount;

        /// <summary>
        /// Optional. Gets or sets the number of read failures in this stage.
        /// </summary>
        public int? ReadFailureCount
        {
            get { return this._readFailureCount; }
            set { this._readFailureCount = value; }
        }

        private int? _revocationCount;

        /// <summary>
        /// Optional. Gets or sets the number of vertices that were revoked
        /// during this stage.
        /// </summary>
        public int? RevocationCount
        {
            get { return this._revocationCount; }
            set { this._revocationCount = value; }
        }

        private int? _runningCount;

        /// <summary>
        /// Optional. Gets or sets the number of currently running vertices in
        /// this stage.
        /// </summary>
        public int? RunningCount
        {
            get { return this._runningCount; }
            set { this._runningCount = value; }
        }

        private int? _scheduledCount;

        /// <summary>
        /// Optional. Gets or sets the number of currently scheduled vertices
        /// in this stage
        /// </summary>
        public int? ScheduledCount
        {
            get { return this._scheduledCount; }
            set { this._scheduledCount = value; }
        }

        private string _stageName;

        /// <summary>
        /// Optional. Gets or sets the name of this stage in job execution.
        /// </summary>
        public string StageName
        {
            get { return this._stageName; }
            set { this._stageName = value; }
        }

        private int? _succeededCount;

        /// <summary>
        /// Optional. Gets or sets the number of vertices that succeeded in
        /// this stage.
        /// </summary>
        public int? SucceededCount
        {
            get { return this._succeededCount; }
            set { this._succeededCount = value; }
        }

        private long _tempDataWritten;

        /// <summary>
        /// Optional. Gets or sets the amount of temporary data written, in
        /// bytes.
        /// </summary>
        public long TempDataWritten
        {
            get { return this._tempDataWritten; }
            set { this._tempDataWritten = value; }
        }

        private int? _totalCount;

        /// <summary>
        /// Optional. Gets or sets the total vertex count for this stage.
        /// </summary>
        public int? TotalCount
        {
            get { return this._totalCount; }
            set { this._totalCount = value; }
        }

        private TimeSpan _totalFailedTime;

        /// <summary>
        /// Optional. Gets or sets the amount of time that failed vertices took
        /// up in this stage.
        /// </summary>
        public TimeSpan TotalFailedTime
        {
            get { return this._totalFailedTime; }
            set { this._totalFailedTime = value; }
        }

        private int? _totalProgress;

        /// <summary>
        /// Optional. Gets or sets the current progress of this stage, as a
        /// percentage.
        /// </summary>
        public int? TotalProgress
        {
            get { return this._totalProgress; }
            set { this._totalProgress = value; }
        }

        private TimeSpan _totalSucceededTime;

        /// <summary>
        /// Optional. Gets or sets the amount of time all successful vertices
        /// took in this stage.
        /// </summary>
        public TimeSpan TotalSucceededTime
        {
            get { return this._totalSucceededTime; }
            set { this._totalSucceededTime = value; }
        }

        /// <summary>
        /// Initializes a new instance of the JobStatisticsVertexStage class.
        /// </summary>
        public JobStatisticsVertexStage()
        {
        }
    }
}


text:
		<title>div</title>

Tag Name: div

Description

		Render HTML div providing content from remote call via AJAX

Attributes

Dynamic Attributes Allowed:
 false

Name

Required

Default

Evaluated

Type

Description

					accesskey
					false

					false
					String
					Set the html accesskey attribute on rendered html element

					afterNotifyTopics
					false

					false
					String
					Comma delimmited list of topics that will published after the request(if the request succeeds)

					autoStart
					false
					true
					false
					Boolean
					Start timer automatically

					beforeNotifyTopics
					false

					false
					String
					Comma delimmited list of topics that will published before the request

					closable
					false
					false
					false
					String
					Show a close button when the div is inside a 'tabbedpanel'

					cssClass
					false

					false
					String
					The css class to use for element

					cssErrorClass
					false

					false
					String
					The css error class to use for element

					cssErrorStyle
					false

					false
					String
					The css error style definitions for element to use

					cssStyle
					false

					false
					String
					The css style to use for element

					delay
					false

					false
					Integer
					How long to wait before fetching the content (in milliseconds)

					disabled
					false

					false
					String
					Set the html disabled attribute on rendered html element

					errorNotifyTopics
					false

					false
					String
					Comma delimmited list of topics that will published after the request(if the request fails)

					errorPosition
					false

					false
					String
					Define error position of form element (top|bottom)

					errorText
					false

					false
					String
					The text to display to the user if the is an error fetching the content

					executeScripts
					false
					false
					false
					Boolean
					Javascript code in the fetched content will be executed

					formFilter
					false

					false
					String
					Function name used to filter the fields of the form.

					formId
					false

					false
					String
					Form id whose fields will be serialized and passed as parameters

					handler
					false

					false
					String
					Javascript function name that will make the request

					highlightColor
					false
					none
					false
					String
					Color used to perform a highlight effect on this element

					highlightDuration
					false
					2000
					false
					Integer
					Duration of highlight effect in milliseconds. Only valid if 'highlightColor' attribute is set

					href
					false

					false
					String
					The URL to call to obtain the content. Note: If used with ajax context, the value must be set as an url tag value.

					id
					false

					false
					String
					The id to use for the element

					indicator
					false

					false
					String
					Id of element that will be shown while making request

					javascriptTooltip
					false
					false
					false
					Boolean
					Use JavaScript to generate tooltips

					key
					false

					false
					String
					Set the key (name, value, label) for this particular component

					label
					false

					false
					String
					Label expression used for rendering an element specific label

					labelSeparator
					false
					:
					false
					String
					String that will be appended to the label

					labelposition
					false

					false
					String
					Define label position of form element (top/left)

					listenTopics
					false

					false
					String
					Topic that will trigger the remote call

					loadingText
					false
					Loading...
					false
					String
					Text to be shown while content is being fetched

					name
					false

					false
					String
					The name to set for element

					notifyTopics
					false

					false
					String
					Comma delimmited list of topics that will published before and after the request, and on errors

					onblur
					false

					false
					String
					 Set the html onblur attribute on rendered html element

					onchange
					false

					false
					String
					Set the html onchange attribute on rendered html element

					onclick
					false

					false
					String
					Set the html onclick attribute on rendered html element

					ondblclick
					false

					false
					String
					Set the html ondblclick attribute on rendered html element

					onfocus
					false

					false
					String
					Set the html onfocus attribute on rendered html element

					onkeydown
					false

					false
					String
					Set the html onkeydown attribute on rendered html element

					onkeypress
					false

					false
					String
					Set the html onkeypress attribute on rendered html element

					onkeyup
					false

					false
					String
					Set the html onkeyup attribute on rendered html element

					onmousedown
					false

					false
					String
					Set the html onmousedown attribute on rendered html element

					onmousemove
					false

					false
					String
					Set the html onmousemove attribute on rendered html element

					onmouseout
					false

					false
					String
					Set the html onmouseout attribute on rendered html element

					onmouseover
					false

					false
					String
					Set the html onmouseover attribute on rendered html element

					onmouseup
					false

					false
					String
					Set the html onmouseup attribute on rendered html element

					onselect
					false

					false
					String
					Set the html onselect attribute on rendered html element

					openTemplate
					false

					false
					String
					Set template to use for opening the rendered html.

					parseContent
					false
					true
					false
					Boolean
					Parse returned HTML for Dojo widgets

					preload
					false
					true
					false
					Boolean
					Load content when page is loaded

					refreshOnShow
					false
					false
					false
					Boolean
					Content will be loaded when div becomes visible, used only inside the tabbedpanel tag

					requiredLabel
					false
					false
					false
					Boolean
					If set to true, the rendered element will indicate that input is required

					requiredPosition
					false

					false
					String
					Define required position of required form element (left|right)

					separateScripts
					false
					true
					false
					String
					Run scripts in a separate scope, unique for each tag

					showErrorTransportText
					false
					true
					false
					Boolean
					Set whether errors will be shown or not

					showLoadingText
					false
					false
					false
					Boolean
					Show loading text on targets

					startTimerListenTopics
					false

					false
					String
					Topics that will start the timer (for autoupdate)

					stopTimerListenTopics
					false

					false
					String
					Topics that will stop the timer (for autoupdate)

					tabindex
					false

					false
					String
					Set the html tabindex attribute on rendered html element

					template
					false

					false
					String
					The template (other than default) to use for rendering the element

					templateDir
					false

					false
					String
					The template directory.

					theme
					false

					false
					String
					The theme (other than default) to use for rendering the element

					title
					false

					false
					String
					Set the html title attribute on rendered html element

					tooltip
					false

					false
					String
					Set the tooltip of this particular component

					tooltipConfig
					false

					false
					String
					Deprecated. Use individual tooltip configuration attributes instead.

					tooltipCssClass
					false
					StrutsTTClassic
					false
					String
					CSS class applied to JavaScrip tooltips

					tooltipDelay
					false
					Classic
					false
					String
					Delay in milliseconds, before showing JavaScript tooltips

					tooltipIconPath
					false

					false
					String
					Icon path used for image that will have the tooltip

					transport
					false
					XMLHTTPTransport
					false
					String
					Transport used by Dojo to make the request

					updateFreq
					false

					false
					Integer
					How often to reload the content (in milliseconds)

					value
					false

					false
					String
					Preset the value of input element.


text:
FROM scratch
CMD ["echo", "hello world"]


text:
<?php

namespace app\modules\grave\widgets;

use app\modules\grave\models\search\TombSearch as Search;
use app\modules\grave\models\Grave;
use app\core\helpers\ArrayHelper;

/**
 * The ZActiveForm widget extend ActiveForm.
 *
 * @author wsq <cboy868@163.com>
 */
class TombSearch extends \yii\base\Widget
{
    public $form;

    public $grave_id;
    // public $options = [];

    /**
     * Renders the widget.
     */
    public function run() {

        $grave = Grave::find()->where(['<>', 'status', Grave::STATUS_DEL])
                              ->andWhere(['is_leaf'=>1])
                              ->orderBy('id asc')
                              ->asArray()
                              ->all();

        $grave_ids = ArrayHelper::map($grave, 'id', 'name');

        $model = new Search;
        $model->search(\Yii::$app->request->queryParams);
        if ($this->grave_id) {
            $model->grave_id = $this->grave_id;
        }
        return $this->render('tomb', ['model'=>$model,
            'grave'=>$grave_ids,
            'form'=>$this->form
        ]);
    }

}


text:
package com.phonegap.io;

/**
 * Fetches a resource and executes a callback.
 *
 * @author Jose Noheda
 *
 */
public class AsynchronousResourceFetcher implements Runnable {

	private String url;
	private Callback callback;

	public AsynchronousResourceFetcher(String url, Callback callback) {
		this.url = url;
		this.callback = callback;
	}

	public void run() {
		callback.execute(ConnectionManager.getUnmanagedConnection(url, null, null));
	}

}


text:
class CreateClients < ActiveRecord::Migration
  def change
  	#here we manually create a migration
  	#there is special syntax
  	create_table :clients do |t| #table name as parameter
  		t.text :name
  		t.text :phone
  		t.text :datestamp
  		t.text :barber
  		t.text :color

  		t.timestamps #creates 2 column: created_at and updated_at (date_time record)
  	end
  end
end
#string will be transformed to varchar (255)


text:
package io.klerch.alexa.pokemon;

import io.klerch.alexa.tellask.model.wrapper.AlexaRequestStreamHandler;
import io.klerch.alexa.tellask.schema.UtteranceReader;
import io.klerch.alexa.tellask.util.resource.ResourceUtteranceReader;

import java.util.Collections;
import java.util.Set;

public class PokemonSpeechletHandler extends AlexaRequestStreamHandler {
    @Override
    public Set<String> getSupportedApplicationIds() {
        return Collections.singleton(SkillConfig.getAlexaAppId());
    }

    @Override
    public UtteranceReader getUtteranceReader() {
        return new ResourceUtteranceReader("out/");
    }
}


text:
package com.hazelcast.simulator.protocol.operation;

import com.hazelcast.simulator.agent.workerprocess.WorkerProcessSettings;

import java.util.List;

/**
 * Creates one or more Simulator Workers, based on a list of {@link WorkerProcessSettings}.
 */
public class CreateWorkerOperation implements SimulatorOperation {

    /**
     * Defines a list of {@link WorkerProcessSettings} to create Simulator Workers.
     */
    private final List<WorkerProcessSettings> settingsList;
    private int delayMs;

    public CreateWorkerOperation(List<WorkerProcessSettings> settingsList, int delayMs) {
        this.settingsList = settingsList;
        this.delayMs = delayMs;
    }

    public int getDelayMs() {
        return delayMs;
    }

    public List<WorkerProcessSettings> getWorkerProcessSettings() {
        return settingsList;
    }
}


text:
package com.intellij.javaee.oss.converter;

import java.util.Collection;
import java.util.Collections;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.intellij.jam.model.common.CommonModelManager;
import com.intellij.javaee.model.xml.ejb.CmpField;
import com.intellij.javaee.model.xml.ejb.EntityBean;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.xml.ConvertContext;
import com.intellij.util.xml.ElementPresentationManager;
import com.intellij.util.xml.ResolvingConverter;

public abstract class CmpFieldConverter extends ResolvingConverter<CmpField> {

    @Override
    @Nullable
    public CmpField fromString(String value, ConvertContext context) {
        EntityBean bean = getEntityBean(context);
        return (bean != null) ? ElementPresentationManager.findByName(bean.getCmpFields(), value) : null;
    }

    @Override
    @Nullable
    public String toString(CmpField value, ConvertContext context) {
        return (value != null) ? value.getFieldName().getValue() : null;
    }

    @Override
    @Nonnull
    public Collection<CmpField> getVariants(ConvertContext context) {
        EntityBean bean = getEntityBean(context);
        if (bean != null) {
            final CommonModelManager manager = CommonModelManager.getInstance();
            return ContainerUtil.map2List(bean.getCmpFields(), new Function<com.intellij.javaee.model.common.ejb.CmpField, CmpField>() {
                public CmpField fun(com.intellij.javaee.model.common.ejb.CmpField field) {
                    return manager.getDomElement(field);
                }
            });
        }
        return Collections.emptyList();
    }

    @Nullable
    protected abstract EntityBean getEntityBean(ConvertContext context);
}