text:
package primitives

import (
	"testing"

	"github.com/apache/beam/sdks/v2/go/pkg/beam"
	"github.com/apache/beam/sdks/v2/go/pkg/beam/testing/ptest"
	"github.com/apache/beam/sdks/v2/go/test/integration"
)

func TestWindowSums_Lifted(t *testing.T) {
	integration.CheckFilters(t)
	p, s := beam.NewPipelineWithRoot()
	WindowSums_Lifted(s)
	ptest.RunAndValidate(t, p)
}

func TestWindowSums_GBK(t *testing.T) {
	integration.CheckFilters(t)
	p, s := beam.NewPipelineWithRoot()
	WindowSums_GBK(s)
	ptest.RunAndValidate(t, p)
}

func TestValidateWindowedSideInputs(t *testing.T) {
	integration.CheckFilters(t)
	p, s := beam.NewPipelineWithRoot()
	ValidateWindowedSideInputs(s)
	ptest.RunAndValidate(t, p)
}

func TestTriggerDefault(t *testing.T) {
	integration.CheckFilters(t)
	p, s := beam.NewPipelineWithRoot()
	TriggerDefault(s)
	ptest.RunAndValidate(t, p)
}

func TestTriggerAlways(t *testing.T) {
	integration.CheckFilters(t)
	p, s := beam.NewPipelineWithRoot()
	TriggerAlways(s)
	ptest.RunAndValidate(t, p)
}

func TestTriggerElementCount(t *testing.T) {
	integration.CheckFilters(t)
	p, s := beam.NewPipelineWithRoot()
	TriggerElementCount(s)
	ptest.RunAndValidate(t, p)
}

func TestTriggerRepeat(t *testing.T) {
	integration.CheckFilters(t)
	p, s := beam.NewPipelineWithRoot()
	TriggerRepeat(s)
	ptest.RunAndValidate(t, p)
}

func TestTriggerAfterEndOfWindow(t *testing.T) {
	integration.CheckFilters(t)
	p, s := beam.NewPipelineWithRoot()
	TriggerAfterEndOfWindow(s)
	ptest.RunAndValidate(t, p)
}


text:
#region Header

// ---------------------------------------------------------------------------------
// <copyright file="UserWallet.cs" company="https://github.com/sant0ro/Yupi">
//   Copyright (c) 2016 Claudio Santoro, TheDoctor
// </copyright>
// <license>
//   Permission is hereby granted, free of charge, to any person obtaining a copy
//   of this software and associated documentation files (the "Software"), to deal
//   in the Software without restriction, including without limitation the rights
//   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//   copies of the Software, and to permit persons to whom the Software is
//   furnished to do so, subject to the following conditions:
//
//   The above copyright notice and this permission notice shall be included in
//   all copies or substantial portions of the Software.
//
//   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//   THE SOFTWARE.
// </license>
// ---------------------------------------------------------------------------------

#endregion Header

namespace Yupi.Model.Domain.Components
{
    using System;
    using System.Collections.Generic;
    using System.Linq;

    public class UserWallet
    {
        #region Properties

        [Required]
        public virtual int AchievementPoints
        {
            get; set;
        }

        [Ignore]
        public virtual IDictionary<ActivityPointsType, int> ActivityPoints
        {
            get; protected set;
        } = new Dictionary<ActivityPointsType, int> ();

        [Required]
        public virtual int Credits
        {
            get; set;
        }

        #endregion Properties

        #region Methods

        public virtual void AddActivityPoints(ActivityPointsType type, int value)
        {
            if (this.ActivityPoints.ContainsKey(type))
            {
                ActivityPoints.Add(type, value);
            }
            else
            {
                ActivityPoints[type] += value;
            }
        }

        public virtual int GetActivityPoints(ActivityPointsType type)
        {
            int value = 0;
            ActivityPoints.TryGetValue(type, out value);
            return value;
        }

        public virtual void SubstractActivityPoints(ActivityPointsType type, int value)
        {
            if (!this.ActivityPoints.ContainsKey(type))
            {
                throw new InvalidOperationException("User has no activity points of this type!");
            }

            ActivityPoints[type] -= value;
        }

        #endregion Methods
    }
}

redpajama_set_name: RedPajamaGithub


text:
import { DEFAULT_SETTINGS, DOM_ATTRIBUTES, toResultsWithRegExp } from './settings';
import { defaults } from './utils';

/**
 * Converts raw results string into table with rows and cells.
 * Returns null if not valid input.
 * @param {string} rawResults
 * @param {object} [config]
 * @param {number} [config.startingRow=0] - informs where is the first row with results
 * @param {number} [config.placeColumn=0] - informs in which column is the place located
 * @param {string} [config.roundsColumns] - comma separated list of columns where game results are located
 * @param {string} [config.cellSeparator='[\t ]+'] - separated used to divide rows into cells
 * @param {boolean} [config.joinNames=true] - joins two consecutive cells after the place column into one cell
 * @returns {HTMLElement|null}
 */
export default function convertRawResultsToTable(rawResults, config) {
    const output = document.createElement('table');

    if (!rawResults) {
        return output;
    }

    const settings = defaults(DEFAULT_SETTINGS, config);
    const lines = rawResults
        .replace(/<br[^>]*>/gi, '\n')
        .replace(/<\/?code[^>]*>/gi, '')
        .split(/\r\n|\n/);

    if (lines.length <= 2 && !lines[0] && !lines[1]) {
        return output;
    }

    const resultsMap = toResultsWithRegExp(settings.results);
    const resultsMapCount = resultsMap.length;

    const rows = lines
        .map((line) => line

            // probably unhealthy replacing space in rank in order to make sure
            // that it won't be broken into two cells
            .replace(/([0-9]+)\s(dan|kyu)/i, '$1_$2')

            // split line to cells (consider tabs and spaces as separators by default)
            .split(new RegExp(settings.cellSeparator))

            // remove empty cells
            .filter((cell) => cell.length > 0)
        )

        // filter out empty rows or rows starting with ';' (EGD/FFG comment)
        .filter((cells) => cells.length > 0 && cells[0].indexOf(';') !== 0);

    const tableWidth = rows.reduce((prev, line) => Math.max(prev, line.length), 0);
    const tableModifier = settings.joinNames ? -1 : 0;
    const joinNamePos = settings.placeColumn + 1;

    let gamesInColumns = null;

    // if columns rounds are provided then convert only them
    if (typeof settings.roundsColumns === 'string') {
        gamesInColumns = settings.roundsColumns.split(',').map(Number);
    }

    let previousPlace;

    rows.forEach((cells, index) => {
        const row = document.createElement('tr');
        const width = cells.length;

        if (!width) {
            return;
        }

        if (index < settings.startingRow || width < (tableWidth + tableModifier)) {
            let cell = document.createElement('td');

            cell.setAttribute('colspan', tableWidth + tableModifier);
            cell.textContent = cells.join(' ');

            row.setAttribute(DOM_ATTRIBUTES.PLAYER_PLACEMENT, -1);
            row.appendChild(cell);

        } else {

            const place = parseInt(cells[settings.placeColumn], 10);

            if (isNaN(place) && !previousPlace) {
                cells.forEach((cellContent) => {
                    let cell = document.createElement('td');

                    cell.textContent = cellContent;

                    row.setAttribute(DOM_ATTRIBUTES.PLAYER_PLACEMENT, -1);
                    row.appendChild(cell);
                });

            } else {
                row.setAttribute(DOM_ATTRIBUTES.PLAYER_PLACEMENT, previousPlace || place);

                let opponents = [];

                if (settings.joinNames) {
                    cells.splice(joinNamePos, 2, `${cells[joinNamePos]}  ${cells[joinNamePos + 1]}`);
                }

                cells.forEach((cellContent, index) => {
                    let cell = document.createElement('td');

                    cell.textContent = cellContent.replace(/_/, ' ');

                    if (!gamesInColumns || gamesInColumns.indexOf(index) >= 0) {
                        for (let i = 0; i < resultsMapCount; i++) {
                            let match = cellContent.match(resultsMap[i].regexp);

                            if (!match) {
                                continue;
                            }

                            let opponentPlacement = match[1];

                            opponents.push(opponentPlacement);
                            cell.setAttribute(DOM_ATTRIBUTES.OPPONENT_PLACEMENT, opponentPlacement);
                            cell.setAttribute(DOM_ATTRIBUTES.GAME_RESULT, resultsMap[i].cls);
                        }
                    }

                    row.appendChild(cell);
                });

                if (opponents.length) {
                    row.setAttribute(DOM_ATTRIBUTES.OPPONENTS, opponents.join(','));
                }

                if (!previousPlace) {
                    previousPlace = 2;
                }  else {
                    previousPlace += 1;
                }

            }
        }

        output.appendChild(row);
    });

    output.setAttribute(DOM_ATTRIBUTES.RESULT_TABLE, '');

    return output;
}


text:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <View
        android:layout_width="match_parent"
        android:id="@+id/bg"
        android:layout_height="456dp" />
    <ImageView
        android:layout_width="45dp"
        android:id="@+id/iv"
        android:layout_height="45dp" />

</FrameLayout>


text:
  int main(void) {
    int retval = EXIT_SUCCESS;

    fprintf(stdout, "1..%zu\n", (sizeof(test_suite_tests) / sizeof(test_suite_tests[0])));
    for (size_t i = 0 ; i < (sizeof(test_suite_tests) / sizeof(test_suite_tests[0])) ; i++) {
      int res = test_suite_tests[i].func();
      if (res != 0) {
        retval = EXIT_FAILURE;
        fprintf(stdout, "not ok %zu " HEDLEY_STRINGIFY(SIMDE_TEST_WASM_RELAXED_SIMD_INSN) "/%s\n", i + 1, test_suite_tests[i].name);
      } else {
        fprintf(stdout, "ok %zu " HEDLEY_STRINGIFY(SIMDE_TEST_WASM_RELAXED_SIMD_INSN) "/%s\n", i + 1, test_suite_tests[i].name);
      }
    }

    return retval;
  }
#else
  #if defined(__cplusplus)
    static MunitSuite suite = { const_cast<char*>("/" HEDLEY_STRINGIFY(SIMDE_TEST_WASM_RELAXED_SIMD_INSN)), test_suite_tests, NULL, 1, MUNIT_SUITE_OPTION_NONE };
  #else
    static MunitSuite suite = { (char*) "/" HEDLEY_STRINGIFY(SIMDE_TEST_WASM_RELAXED_SIMD_INSN), test_suite_tests, NULL, 1, MUNIT_SUITE_OPTION_NONE };
  #endif

  HEDLEY_C_DECL MunitSuite*
  SIMDE_TEST_GENERATE_VARIANT_SYMBOL_CURRENT(HEDLEY_CONCAT(simde_test_wasm_relaxed_simd_get_suite_,SIMDE_TEST_WASM_RELAXED_SIMD_INSN)) (void) {
    return &suite;
  }
#endif


text:
enum Status {
    Rich,
    Poor,
}

enum Work {
    Civilian,
    Soldier,
}

pub fn main() {
    // Explicitly `use` each name so they are available without
    // manual scoping.
    use self::Status::{Poor, Rich};
    // Automatically `use` each name inside `Work`.
    use self::Work::*;

    // Equivalent to `Status::Poor`.
    let status = Poor;
    // Equivalent to `Work::Civilian`.
    let work = Civilian;

    match status {
        // Note the lack of scoping because of the explicit `use` above.
        Rich => println!("The rich have lots of money!"),
        Poor => println!("The poor have no money..."),
    }

    match work {
        // Note again the lack of scoping.
        Civilian => println!("Civilians work!"),
        Soldier  => println!("Soldiers fight!"),
    }
}


text:
/* global app, alert */
var PageView = require('./base');
var PersonForm = require('../forms/person');

module.exports = PageView.extend({
  pageTitle: 'edit person',
  template: require('../templates/pages/personEdit.hbs'),
  initialize: function (spec) {
    var self = this;
    app.people.getOrFetch(spec.id, {all: true}, function (err, model) {
      if (err) alert('couldnt find a model with id: ' + spec.id);
      self.model = model;
    });
  },
  subviews: {
    form: {
      // this is the css selector that will be the `el` in the
      // prepareView function.
      container: 'form',
      // this says we'll wait for `this.model` to be truthy.
      waitFor: 'model',
      prepareView: function (el) {
        var model = this.model;
        return new PersonForm({
          el: el,
          model: this.model,
          submitCallback: function (data) {
            model.save(data, {
              wait: true,
              success: function () {
                app.navigate('/collections');
              }
            });
          }
        });
      }
    }
  }
});


text:
<?php
namespace Grav\Console\Cli;

use Grav\Common\Filesystem\Folder;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * Class SandboxCommand
 * @package Grav\Console\Cli
 */
class SandboxCommand extends Command
{
    /**
     * @var array
     */
    protected $directories = array(
        '/backup',
        '/cache',
        '/logs',
        '/images',
        '/assets',
        '/user/accounts',
        '/user/config',
        '/user/pages',
        '/user/data',
        '/user/plugins',
        '/user/themes',
    );

    /**
     * @var array
     */
    protected $files = array(
        '/.dependencies',
        '/.htaccess',
        '/nginx.conf',
        '/web.config',
        '/user/config/site.yaml',
        '/user/config/system.yaml',
    );

    /**
     * @var array
     */
    protected $mappings = array(
        '/.editorconfig' => '/.editorconfig',
        '/.gitignore' => '/.gitignore',
        '/CHANGELOG.md' => '/CHANGELOG.md',
        '/LICENSE' => '/LICENSE',
        '/README.md' => '/README.md',
        '/index.php'     => '/index.php',
        '/composer.json' => '/composer.json',
        '/bin'           => '/bin',
        '/system'        => '/system',
        '/vendor'        => '/vendor',
    );

    /**
     * @var string
     */

    protected $default_file = "---\ntitle: HomePage\n---\n# HomePage\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque porttitor eu felis sed ornare. Sed a mauris venenatis, pulvinar velit vel, dictum enim. Phasellus ac rutrum velit. Nunc lorem purus, hendrerit sit amet augue aliquet, iaculis ultricies nisl. Suspendisse tincidunt euismod risus, quis feugiat arcu tincidunt eget. Nulla eros mi, commodo vel ipsum vel, aliquet congue odio. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Pellentesque velit orci, laoreet at adipiscing eu, interdum quis nibh. Nunc a accumsan purus.";

    /**
     * @var
     */
    protected $source;
    /**
     * @var
     */
    protected $destination;
    /**
     * @var InputInterface $input
     */
    protected $input;
    /**
     * @var OutputInterface $output
     */
    protected $output;

    /**
     *
     */
    protected function configure()
    {
        $this
            ->setName('sandbox')
            ->setDescription('Setup of a base Grav system in your webroot, good for development, playing around or starting fresh')
            ->addArgument(
                'destination',
                InputArgument::REQUIRED,
                'The destination directory to symlink into'
            )
            ->addOption(
                'symlink',
                's',
                InputOption::VALUE_NONE,
                'Symlink the base grav system'
            )
            ->setHelp("The <info>sandbox</info> command help create a development environment that can optionally use symbolic links to link the core of grav to the git cloned repository.\nGood for development, playing around or starting fresh");
        $this->source = getcwd();
    }

    /**
     * @param InputInterface  $input
     * @param OutputInterface $output
     *
     * @return int|null|void
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->destination = $input->getArgument('destination');
        $this->input = $input;
        $this->output = $output;

        // Create a red output option
        $this->output->getFormatter()->setStyle('red', new OutputFormatterStyle('red'));
        $this->output->getFormatter()->setStyle('cyan', new OutputFormatterStyle('cyan'));
        $this->output->getFormatter()->setStyle('magenta', new OutputFormatterStyle('magenta'));

        // Symlink the Core Stuff
        if ($input->getOption('symlink')) {
            // Create Some core stuff if it doesn't exist
            $this->createDirectories();

            // Loop through the symlink mappings and create the symlinks
            $this->symlink();

            // Copy the Core STuff
        } else {
            // Create Some core stuff if it doesn't exist
            $this->createDirectories();

            // Loop through the symlink mappings and copy what otherwise would be symlinks
            $this->copy();
        }

        $this->pages();
        $this->initFiles();
        $this->perms();
    }

    /**
     *
     */
    private function createDirectories()
    {
        $this->output->writeln('');
        $this->output->writeln('<comment>Creating Directories</comment>');
        $dirs_created = false;

        if (!file_exists($this->destination)) {
            mkdir($this->destination, 0777, true);
        }

        foreach ($this->directories as $dir) {
            if (!file_exists($this->destination . $dir)) {
                $dirs_created = true;
                $this->output->writeln('    <cyan>' . $dir . '</cyan>');
                mkdir($this->destination . $dir, 0777, true);
            }
        }

        if (!$dirs_created) {
            $this->output->writeln('    <red>Directories already exist</red>');
        }
    }

    /**
     *
     */
    private function copy()
    {
        $this->output->writeln('');
        $this->output->writeln('<comment>Copying Files</comment>');

        foreach ($this->mappings as $source => $target) {
            if ((int)$source == $source) {
                $source = $target;
            }

            $from = $this->source . $source;
            $to = $this->destination . $target;

            $this->output->writeln('    <cyan>' . $source . '</cyan> <comment>-></comment> ' . $to);
            Folder::rcopy($from, $to);
        }
    }

    /**
     *
     */
    private function symlink()
    {
        $this->output->writeln('');
        $this->output->writeln('<comment>Resetting Symbolic Links</comment>');

        foreach ($this->mappings as $source => $target) {
            if ((int)$source == $source) {
                $source = $target;
            }

            $from = $this->source . $source;
            $to = $this->destination . $target;

            $this->output->writeln('    <cyan>' . $source . '</cyan> <comment>-></comment> ' . $to);

            if (is_dir($to)) {
                @Folder::delete($to);
            } else {
                @unlink($to);
            }
            symlink($from, $to);
        }
    }

    /**
     *
     */
    private function initFiles()
    {
        $this->check($this->output);

        $this->output->writeln('');
        $this->output->writeln('<comment>File Initializing</comment>');
        $files_init = false;

        // Copy files if they do not exist
        foreach ($this->files as $source => $target) {
            if ((int)$source == $source) {
                $source = $target;
            }

            $from = $this->source . $source;
            $to = $this->destination . $target;

            if (!file_exists($to)) {
                $files_init = true;
                copy($from, $to);
                $this->output->writeln('    <cyan>' . $target . '</cyan> <comment>-></comment> Created');
            }
        }

        if (!$files_init) {
            $this->output->writeln('    <red>Files already exist</red>');
        }

    }

    /**
     *
     */
    private function pages()
    {
        $this->output->writeln('');
        $this->output->writeln('<comment>Pages Initializing</comment>');

        // get pages files and initialize if no pages exist
        $pages_dir = $this->destination . '/user/pages';
        $pages_files = array_diff(scandir($pages_dir), array('..', '.'));

        if (count($pages_files) == 0) {
            $destination = $this->source . '/user/pages';
            Folder::rcopy($destination, $pages_dir);
            $this->output->writeln('    <cyan>' . $destination . '</cyan> <comment>-></comment> Created');

        }
    }

    /**
     *
     */
    private function perms()
    {
        $this->output->writeln('');
        $this->output->writeln('<comment>Permisions Initializing</comment>');

        $dir_perms = 0755;

        $binaries = glob($this->destination . DS . 'bin' . DS . '*');

        foreach ($binaries as $bin) {
            chmod($bin, $dir_perms);
            $this->output->writeln('    <cyan>bin/' . basename($bin) . '</cyan> permissions reset to ' . decoct($dir_perms));
        }

        $this->output->writeln("");
    }

    /**
     *
     */
    private function check()
    {
        $success = true;

        if (!file_exists($this->destination)) {
            $this->output->writeln('    file: <red>$this->destination</red> does not exist!');
            $success = false;
        }

        foreach ($this->directories as $dir) {
            if (!file_exists($this->destination . $dir)) {
                $this->output->writeln('    directory: <red>' . $dir . '</red> does not exist!');
                $success = false;
            }
        }

        foreach ($this->mappings as $target => $link) {
            if (!file_exists($this->destination . $target)) {
                $this->output->writeln('    mappings: <red>' . $target . '</red> does not exist!');
                $success = false;
            }
        }
        if (!$success) {
            $this->output->writeln('');
            $this->output->writeln('<comment>install should be run with --symlink|--s to symlink first</comment>');
            exit;
        }
    }
}


text:
package org.talend.sdk.component.documentation.sample.datastorevalidation.components.source;

import static java.util.Collections.singletonList;

import java.io.Serializable;
import java.util.List;

import org.talend.sdk.component.api.component.Icon;
import org.talend.sdk.component.api.component.Version;
import org.talend.sdk.component.api.configuration.Option;
import org.talend.sdk.component.api.input.Assessor;
import org.talend.sdk.component.api.input.Emitter;
import org.talend.sdk.component.api.input.PartitionMapper;
import org.talend.sdk.component.api.input.PartitionSize;
import org.talend.sdk.component.api.input.Split;
import org.talend.sdk.component.api.meta.Documentation;

//
// this class role is to enable the work to be distributed in environments supporting it.
//
@Version
@Icon(Icon.IconType.STAR)
@PartitionMapper(name = "DataStoreValidationInput")
@Documentation("TODO fill the documentation for this mapper")
public class DataStoreValidationInputMapper implements Serializable {

    private final DataStoreValidationInputMapperConfiguration configuration;

    public DataStoreValidationInputMapper(
            @Option("configuration") final DataStoreValidationInputMapperConfiguration configuration) {
        this.configuration = configuration;
    }

    @Assessor
    public long estimateSize() {
        // this method should return the estimation of the dataset size
        // it is recommended to return a byte value
        // if you don't have the exact size you can use a rough estimation
        return 1L;
    }

    @Split
    public List<DataStoreValidationInputMapper> split(@PartitionSize final long bundles) {
        // overall idea here is to split the work related to configuration in bundles of size "bundles"
        //
        // for instance if your estimateSize() returned 1000 and you can run on 10 nodes
        // then the environment can decide to run it concurrently (10 * 100).
        // In this case bundles = 100 and we must try to return 10 DataStoreValidationInputMapper with 1/10 of the
        // overall work each.
        //
        // default implementation returns this which means it doesn't support the work to be split
        return singletonList(this);
    }

    @Emitter
    public DataStoreValidationInputSource createWorker() {
        // here we create an actual worker,
        // you are free to rework the configuration etc but our default generated implementation
        // propagates the partition mapper entries.
        return new DataStoreValidationInputSource(configuration);
    }
}


text:
package com.impossibl.stencil.engine.internal;

import java.util.List;

import org.antlr.v4.runtime.CommonToken;
import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.tree.TerminalNode;

import com.impossibl.stencil.engine.parsing.ParamOutputBlockMode;
import com.impossibl.stencil.engine.parsing.StencilParser;
import com.impossibl.stencil.engine.parsing.StencilParser.BlockDeclContext;
import com.impossibl.stencil.engine.parsing.StencilParser.BooleanLiteralContext;
import com.impossibl.stencil.engine.parsing.StencilParser.CallableSignatureContext;
import com.impossibl.stencil.engine.parsing.StencilParser.FloatingLiteralContext;
import com.impossibl.stencil.engine.parsing.StencilParser.FunctionDefinitionContext;
import com.impossibl.stencil.engine.parsing.StencilParser.IntegerLiteralContext;
import com.impossibl.stencil.engine.parsing.StencilParser.LValueRefContext;
import com.impossibl.stencil.engine.parsing.StencilParser.MacroDefinitionContext;
import com.impossibl.stencil.engine.parsing.StencilParser.MemberIndexSelectorContext;
import com.impossibl.stencil.engine.parsing.StencilParser.MemberSelectorContext;
import com.impossibl.stencil.engine.parsing.StencilParser.MethodCallSelectorContext;
import com.impossibl.stencil.engine.parsing.StencilParser.NamedOutputBlockContext;
import com.impossibl.stencil.engine.parsing.StencilParser.NamedValueContext;
import com.impossibl.stencil.engine.parsing.StencilParser.ParamOutputBlockModeContext;
import com.impossibl.stencil.engine.parsing.StencilParser.ParameterDeclContext;
import com.impossibl.stencil.engine.parsing.StencilParser.SafeMemberSelectorContext;
import com.impossibl.stencil.engine.parsing.StencilParser.SimpleNameContext;
import com.impossibl.stencil.engine.parsing.StencilParser.StringLiteralContext;
import com.impossibl.stencil.engine.parsing.StencilParser.UnnamedOutputBlockContext;
import com.impossibl.stencil.engine.parsing.StencilParser.VariableDeclContext;
import com.impossibl.stencil.engine.parsing.StencilParser.VariableRefContext;

public class Contexts {

  public static Boolean value(BooleanLiteralContext ctx) {
    return Boolean.parseBoolean(ctx.getText());
  }

  public static Number value(IntegerLiteralContext ctx) {
    String val = ctx.getText();
    switch(val.charAt(val.length()-1)) {
    case 's':
      return Short.decode(val.substring(0, val.length()-1));
    case 'l':
      return Long.decode(val.substring(0, val.length()-1));
    case 'i':
      val = val.substring(0, val.length()-1);
    default:
      return Integer.decode(val);
    }
  }

  public static Number value(FloatingLiteralContext ctx) {
    String val = ctx.getText();
    switch(val.charAt(val.length()-1)) {
    case 'f':
      return Float.parseFloat(val.substring(0, val.length()-1));
    case 'd':
      val = val.substring(0, val.length()-1);
    default:
      return Double.parseDouble(val);
    }
  }

  public static String value(StringLiteralContext ctx) {
    String text = ctx.getText();
    return text.substring(1, text.length()-1);
  }

  public static String value(SimpleNameContext ctx) {
    if(ctx.stringLit != null)
      return value(ctx.stringLit);
    if(ctx.id != null)
      return value(ctx.id);
    return null;
  }

  public static String value(ParserRuleContext ctx) {
    if(ctx == null)
      return null;
    return ctx.getText();
  }

  public static String value(TerminalNode node) {
    if(node == null)
      return null;
    return node.getText();
  }

  public static String value(Token token) {
    if(token == null)
      return null;
    return token.getText();
  }

  public static ParamOutputBlockMode value(ParamOutputBlockModeContext ctx) {
    if(ctx == null)
      return null;
    for(ParamOutputBlockMode mode : ParamOutputBlockMode.values()) {
      if(mode.name().toLowerCase().equals(ctx.getText()))
        return mode;
    }
    return null;
  }

  public static ParamOutputBlockMode mode(ParserRuleContext paramBlock) {
    if(paramBlock instanceof UnnamedOutputBlockContext)
      return value(((UnnamedOutputBlockContext) paramBlock).blockMode);
    else if(paramBlock instanceof NamedOutputBlockContext)
      return value(((NamedOutputBlockContext) paramBlock).blockMode);
    return null;
  }

  public static String name(LValueRefContext ref) {
    if(ref == null)
      return null;
    return value(ref.id);
  }

  public static String name(NamedValueContext val) {
    if(val == null)
      return null;
    return value(val.name);
  }

  public static String name(VariableRefContext ref) {
    if(ref == null)
      return null;
    return value(ref.id);
  }

  public static String name(VariableDeclContext decl) {
    if(decl == null)
      return null;
    return value(decl.id);
  }

  public static String name(ParameterDeclContext decl) {
    return value(decl.id);
  }

  public static String name(BlockDeclContext decl) {
    if(decl == null)
      return null;
    return value(decl.id);
  }

  public static String name(NamedOutputBlockContext block) {
    if(block == null)
      return null;
    return value(block.id);
  }

  public static String name(MethodCallSelectorContext ctx) {
    if(ctx == null)
      return null;
    return value(ctx.id);
  }

  public static String name(MemberSelectorContext ctx) {
    if(ctx == null)
      return null;
    return value(ctx.id);
  }

  public static String name(SafeMemberSelectorContext ctx) {
    if(ctx == null)
      return null;
    return value(ctx.id);
  }

  public static String name(MemberIndexSelectorContext ctx) {
    if(ctx == null)
      return null;
    return value(ctx.id);
  }

  public static String name(MacroDefinitionContext ctx) {
    if(ctx == null)
      return null;
    return value(ctx.id);
  }

  public static String name(FunctionDefinitionContext ctx) {
    if(ctx == null)
      return null;
    return value(ctx.id);
  }

  public static CallableSignatureContext createCallableSignatureContext(List<ParameterDeclContext> paramDecls) {

    CallableSignatureContext sig = new CallableSignatureContext(null, -1);

    sig.paramDecls = paramDecls;

    return sig;
  }

  public static ParameterDeclContext createParameterDecl(ParserRuleContext parent, String name) {

    ParameterDeclContext paramDecl = new ParameterDeclContext(parent,-1);

    paramDecl.id = createToken(StencilParser.ID, name);

    return paramDecl;
  }

  public static ParameterDeclContext createAllParameterDecl(ParserRuleContext parent, String name) {

    ParameterDeclContext allParamDecl = new ParameterDeclContext(parent, -1);

    allParamDecl.id = createToken(StencilParser.ID, name);
    allParamDecl.flag = createToken(StencilParser.MUL, "*");

    return allParamDecl;
  }

  public static BlockDeclContext createBlockDecl(ParserRuleContext parent, String name) {

    BlockDeclContext blockDecl = new BlockDeclContext(parent,-1);

    blockDecl.id = createToken(StencilParser.ID, name);

    return blockDecl;
  }

  public static BlockDeclContext createUnnamedBlockDecl(ParserRuleContext parent, String name) {

    BlockDeclContext unnamedBlockDecl = new BlockDeclContext(parent, -1);

    unnamedBlockDecl.id = createToken(StencilParser.ID, name);
    unnamedBlockDecl.flag = createToken(StencilParser.ADD, "+");

    return unnamedBlockDecl;
  }

  public static BlockDeclContext createAllBlockDecl(ParserRuleContext parent, String name) {

    BlockDeclContext allBlockDecl = new BlockDeclContext(parent, -1);

    allBlockDecl.id = createToken(StencilParser.ID, name);
    allBlockDecl.flag = createToken(StencilParser.MUL, "*");

    return allBlockDecl;
  }

  public static Token createToken(int ttype, String text) {
    return new CommonToken(ttype, text);
  }

}


text: A space areial fighting game.


text:
gradle-override-plugin
==============
[![Build Status](https://travis-ci.org/nebula-plugins/gradle-override-plugin.svg?branch=master)](https://travis-ci.org/nebula-plugins/gradle-override-plugin)
[![Coverage Status](https://coveralls.io/repos/nebula-plugins/gradle-override-plugin/badge.svg?branch=master&service=github)](https://coveralls.io/github/nebula-plugins/gradle-override-plugin?branch=master)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/nebula-plugins/gradle-override-plugin?utm_source=badgeutm_medium=badgeutm_campaign=pr-badge)
[![Apache 2.0](https://img.shields.io/github/license/nebula-plugins/gradle-override-plugin.svg)](http://www.apache.org/licenses/LICENSE-2.0)

Plugin for overriding properties in a project from the command line. The main use case for this functionality is to avoid
the introduction of "magic" system/project properties for providing user-driven property values as part of build logic.
Property names are provided as String and are looked up by dot notation. If no matching property can be resolved, the build fails.

## The world without the plugin

A typical scenario without the plugin looks as such:

    extensions.create('example', MyExtension)

    class MyExtension {
        String myProp
        Integer otherProp
        Boolean flag
    }

    example {
        myProp = System.getProperty('my.prop') ?: 'hello'
        otherProp = System.getProperty('other.prop') ? System.getProperty('other.prop').toInteger() : 1
        flag = System.getProperty('flag') ? System.getProperty('other.prop').toBoolean() : true
    }

In this scenario, the build script user can override the default value assigned to the extension property `myProp` by
providing the system property `my.prop` on the command line. This works. However, the build script author has to implement
this functionality for every property that is supposed to be overriden from the command line. With an increasing amount of
code this becomes very tedious. Furthermore, the build script user has to know the name of system property.

## Usage

### Applying the Plugin

To apply this plugin if using Gradle 2.1 or newer

    plugins {
      id 'nebula.override' version '3.0.2'
    }

If using an older version of Gradle

    buildscript {
        repositories { jcenter() }

        dependencies {
            classpath 'com.netflix.nebula:gradle-override-plugin:3.0.2'
        }
    }

    apply plugin: 'nebula.override'

### Overriding properties with the plugin

Overriding properties is not limited to specific Gradle domain objects. You can override all writeable properties. Some
examples:

* Project properties e.g. `buildDir`
* Task properties e.g. `javadoc.maxMemory`
* Extension properties on any nested level

You can override properties through the following methods:

* By providing an environment variable with the prefix `OVERRIDE_`.
* By providing a system property with the prefix `override.`.

Override properties provided through system properties take precedence over the ones provided by environment variables.

Let's consider the following, modified build script code:

    apply plugin: 'nebula.override'

    class MyExtension {
        String myProp
    }

    example {
        myProp = 'hello'
    }

The plugin defers overriding existing properties until the project is parsed during the configuration phase to allow for
changing values of all properties. Property values are automatically converted to the correct type. From the command line
the build script user can override the default value `hello` of myProp by providing `-Doverride.example.myProp=newValue`.

### Future improvements

* Introduce a plugin-specific argument that doesn't require a "prefix" similar to project properties e.g.
`-Nexample.myProp=newValue`. This will require a change in Gradle core as the functionality to add new command line handlers
(see `AbstractPropertiesCommandLineConverter`) is not exposed.

Gradle Compatibility Tested
---------------------------

Built with Oracle JDK7
Tested with Oracle JDK8

| Gradle Version | Works |
| :------------: | :---: |
| 2.2.1          | yes   |
| 2.3            | yes   |
| 2.4            | yes   |
| 2.5            | yes   |
| 2.6            | yes   |
| 2.7            | yes   |
| 2.8            | yes   |

LICENSE
=======

Copyright 2014-2015 Netflix, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

<http://www.apache.org/licenses/LICENSE-2.0>

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.


text:
#include "core/style/StyleGridData.h"

#include "core/style/ComputedStyle.h"

namespace blink {

StyleGridData::StyleGridData()
    : m_gridTemplateColumns(ComputedStyle::initialGridTemplateColumns()),
      m_gridTemplateRows(ComputedStyle::initialGridTemplateRows()),
      m_namedGridColumnLines(ComputedStyle::initialNamedGridColumnLines()),
      m_namedGridRowLines(ComputedStyle::initialNamedGridRowLines()),
      m_orderedNamedGridColumnLines(
          ComputedStyle::initialOrderedNamedGridColumnLines()),
      m_orderedNamedGridRowLines(
          ComputedStyle::initialOrderedNamedGridRowLines()),
      m_autoRepeatNamedGridColumnLines(
          ComputedStyle::initialNamedGridColumnLines()),
      m_autoRepeatNamedGridRowLines(ComputedStyle::initialNamedGridRowLines()),
      m_autoRepeatOrderedNamedGridColumnLines(
          ComputedStyle::initialOrderedNamedGridColumnLines()),
      m_autoRepeatOrderedNamedGridRowLines(
          ComputedStyle::initialOrderedNamedGridRowLines()),
      m_gridAutoFlow(ComputedStyle::initialGridAutoFlow()),
      m_gridAutoRows(ComputedStyle::initialGridAutoRows()),
      m_gridAutoColumns(ComputedStyle::initialGridAutoColumns()),
      m_namedGridArea(ComputedStyle::initialNamedGridArea()),
      m_namedGridAreaRowCount(ComputedStyle::initialNamedGridAreaCount()),
      m_namedGridAreaColumnCount(ComputedStyle::initialNamedGridAreaCount()),
      m_gridColumnGap(ComputedStyle::initialGridColumnGap()),
      m_gridRowGap(ComputedStyle::initialGridRowGap()),
      m_gridAutoRepeatColumns(ComputedStyle::initialGridAutoRepeatTracks()),
      m_gridAutoRepeatRows(ComputedStyle::initialGridAutoRepeatTracks()),
      m_autoRepeatColumnsInsertionPoint(
          ComputedStyle::initialGridAutoRepeatInsertionPoint()),
      m_autoRepeatRowsInsertionPoint(
          ComputedStyle::initialGridAutoRepeatInsertionPoint()),
      m_autoRepeatColumnsType(ComputedStyle::initialGridAutoRepeatType()),
      m_autoRepeatRowsType(ComputedStyle::initialGridAutoRepeatType()) {}

StyleGridData::StyleGridData(const StyleGridData& o)
    : RefCounted<StyleGridData>(),
      m_gridTemplateColumns(o.m_gridTemplateColumns),
      m_gridTemplateRows(o.m_gridTemplateRows),
      m_namedGridColumnLines(o.m_namedGridColumnLines),
      m_namedGridRowLines(o.m_namedGridRowLines),
      m_orderedNamedGridColumnLines(o.m_orderedNamedGridColumnLines),
      m_orderedNamedGridRowLines(o.m_orderedNamedGridRowLines),
      m_autoRepeatNamedGridColumnLines(o.m_autoRepeatNamedGridColumnLines),
      m_autoRepeatNamedGridRowLines(o.m_autoRepeatNamedGridRowLines),
      m_autoRepeatOrderedNamedGridColumnLines(
          o.m_autoRepeatOrderedNamedGridColumnLines),
      m_autoRepeatOrderedNamedGridRowLines(
          o.m_autoRepeatOrderedNamedGridRowLines),
      m_gridAutoFlow(o.m_gridAutoFlow),
      m_gridAutoRows(o.m_gridAutoRows),
      m_gridAutoColumns(o.m_gridAutoColumns),
      m_namedGridArea(o.m_namedGridArea),
      m_namedGridAreaRowCount(o.m_namedGridAreaRowCount),
      m_namedGridAreaColumnCount(o.m_namedGridAreaColumnCount),
      m_gridColumnGap(o.m_gridColumnGap),
      m_gridRowGap(o.m_gridRowGap),
      m_gridAutoRepeatColumns(o.m_gridAutoRepeatColumns),
      m_gridAutoRepeatRows(o.m_gridAutoRepeatRows),
      m_autoRepeatColumnsInsertionPoint(o.m_autoRepeatColumnsInsertionPoint),
      m_autoRepeatRowsInsertionPoint(o.m_autoRepeatRowsInsertionPoint),
      m_autoRepeatColumnsType(o.m_autoRepeatColumnsType),
      m_autoRepeatRowsType(o.m_autoRepeatRowsType) {}

}  // namespace blink