// Copyright 2014 The Bazel Authors. All rights reserved.
//
// 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.
package com.google.devtools.build.lib.runtime;

import com.google.common.collect.ImmutableMap;
import com.google.devtools.build.lib.util.OptionsUtils;
import com.google.devtools.build.lib.vfs.DigestHashFunction;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.common.options.Converter;
import com.google.devtools.common.options.Option;
import com.google.devtools.common.options.OptionDocumentationCategory;
import com.google.devtools.common.options.OptionEffectTag;
import com.google.devtools.common.options.OptionMetadataTag;
import com.google.devtools.common.options.OptionsBase;
import java.util.Map;

/**
 * Options that will be evaluated by the blaze client startup code and passed to the blaze server
 * upon startup.
 *
 *
IMPORTANT

 *
 * These options and their defaults must be kept in sync with those in the source of the launcher.
 * The latter define the actual default values, most startup options are passed every time,
 * regardless of whether a value was set explicitly or if the default was used. Some options are
 * omitted by default, though this should only be true for options where "omitted" is a distinct
 * value.
 *
 *
The same relationship holds between {@link HostJvmStartupOptions} and the launcher.
 */
public class BlazeServerStartupOptions extends OptionsBase {
  /**
   * Converter for the option_sources option. Takes a string in the form of
   * "option_name1:source1:option_name2:source2:.." and converts it into an option name to source
   * map.
   */
  public static class OptionSourcesConverter implements Converter<Map<String, String>> {
    private String unescape(String input) {
      return input.replace("_C", ":").replace("_U", "_");
    }

    @Override
    public Map<String, String> convert(String input) {
      ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
      if (input.isEmpty()) {
        return builder.build();
      }

      String[] elements = input.split(":");
      for (int i = 0; i < (elements.length + 1) / 2; i++) {
        String name = elements[i * 2];
        String value = "";
        if (elements.length > i * 2 + 1) {
          value = elements[i * 2 + 1];
        }
        builder.put(unescape(name), unescape(value));
      }
      return builder.build();
    }

    @Override
    public String getTypeDescription() {
      return "a list of option-source pairs";
    }
  }

  /* Passed from the client to the server, specifies the installation
   * location. The location should be of the form:
   * $OUTPUT_BASE/_blaze_${USER}/install/${MD5_OF_INSTALL_MANIFEST}.
   * The server code will only accept a non-empty path; it's the
   * responsibility of the client to compute a proper default if
   * necessary.
   */
  @Option(
      name = "install_base",
      defaultValue = "", // NOTE: only for documentation, value is always passed by the client.
      documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
      effectTags = {OptionEffectTag.CHANGES_INPUTS, OptionEffectTag.LOSES_INCREMENTAL_STATE},
      metadataTags = {OptionMetadataTag.HIDDEN},
      converter = OptionsUtils.PathFragmentConverter.class,
      help = "This launcher option is intended for use only by tests.")
  public PathFragment installBase;

  /*
   * The installation MD5 - a content hash of the blaze binary (includes the Blaze deploy JAR and
   * any other embedded binaries - anything that ends up in the install_base).
   */
  @Option(
      name = "install_md5",
      defaultValue = "", // NOTE: only for documentation, value is always passed by the client.
      documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
      effectTags = {OptionEffectTag.LOSES_INCREMENTAL_STATE, OptionEffectTag.BAZEL_MONITORING},
      metadataTags = {OptionMetadataTag.HIDDEN},
      help = "This launcher option is intended for use only by tests.")
  public String installMD5;

  /* Note: The help string in this option applies to the client code; not
   * the server code. The server code will only accept a non-empty path; it's
   * the responsibility of the client to compute a proper default if
   * necessary.
   */
  @Option(
      name = "output_base",
      defaultValue = "null", // NOTE: only for documentation, value is always passed by the client.
      documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS,
      effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.LOSES_INCREMENTAL_STATE},
      converter = OptionsUtils.PathFragmentConverter.class,
      valueHelp = "<path>",
      help =
          "If set, specifies the output location to which all build output will be written. "
              + "Otherwise, the location will be "
              + "${OUTPUT_ROOT}/_blaze_${USER}/${MD5_OF_WORKSPACE_ROOT}. Note: If you specify a "
              + "different option from one to the next Bazel invocation for this value, you'll "
              + "likely start up a new, additional Bazel server. Bazel starts exactly one server "
              + "per specified output base. Typically there is one output base per workspace - "
              + "however, with this option you may have multiple output bases per workspace and "
              + "thereby run multiple builds for the same client on the same machine concurrently. "
              + "See 'bazel help shutdown' on how to shutdown a Bazel server.")
  public PathFragment outputBase;

  @Option(
      name = "output_user_root",
      defaultValue = "null", // NOTE: only for documentation, value is always passed by the client.
      documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS,
      effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.LOSES_INCREMENTAL_STATE},
      converter = OptionsUtils.PathFragmentConverter.class,
      valueHelp = "<path>",
      help =
          "The user-specific directory beneath which all build outputs are written; by default, "
              + "this is a function of $USER, but by specifying a constant, build outputs can be "
              + "shared between collaborating users.")
  public PathFragment outputUserRoot;

  /**
   * Note: This option is only used by the C++ client, never by the Java server. It is included here
   * to make sure that the option is documented in the help output, which is auto-generated by Java
   * code.
   */
  @Option(
      name = "server_jvm_out",
      defaultValue = "null",
      documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS,
      effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.LOSES_INCREMENTAL_STATE},
      converter = OptionsUtils.PathFragmentConverter.class,
      valueHelp = "<path>",
      help =
          "The location to write the server's JVM's output. If unset then defaults to a location "
              + "in output_base.")
  public PathFragment serverJvmOut;

  // Note: The help string in this option applies to the client code; not the server code. The
  // server code will only accept a non-empty path; it's the responsibility of the client to compute
  // a proper default if necessary.
  @Option(
      name = "failure_detail_out",
      defaultValue = "null", // NOTE: only for documentation, value is always passed by the client.
      documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS,
      effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.LOSES_INCREMENTAL_STATE},
      converter = OptionsUtils.PathFragmentConverter.class,
      valueHelp = "<path>",
      help =
          "If set, specifies a location to write a failure_detail protobuf message if the server"
              + " experiences a failure and cannot report it via gRPC, as normal. Otherwise, the"
              + " location will be ${OUTPUT_BASE}/failure_detail.rawproto.")
  public PathFragment failureDetailOut;

  @Option(
      name = "workspace_directory",
      defaultValue = "", // NOTE: only for documentation, value is always passed by the client.
      documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
      effectTags = {OptionEffectTag.CHANGES_INPUTS, OptionEffectTag.LOSES_INCREMENTAL_STATE},
      metadataTags = {OptionMetadataTag.HIDDEN},
      converter = OptionsUtils.PathFragmentConverter.class,
      help =
          "The root of the workspace, that is, the directory that Bazel uses as the root of the "
              + "build. This flag is only to be set by the bazel client.")
  public PathFragment workspaceDirectory;

  @Option(
      name = "default_system_javabase",
      defaultValue = "", // NOTE: only for documentation, value is always passed by the client.
      documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
      effectTags = {OptionEffectTag.CHANGES_INPUTS, OptionEffectTag.LOSES_INCREMENTAL_STATE},
      metadataTags = {OptionMetadataTag.HIDDEN},
      converter = OptionsUtils.PathFragmentConverter.class,
      help =
          "The root of the user's local JDK install, to be used as the default target javabase"
              + " and as a fall-back host_javabase. This is not the embedded JDK.")
  public PathFragment defaultSystemJavabase;

  @Option(
      name = "max_idle_secs",
      // NOTE: default value only used for documentation, value is always passed by the client when
      // not in --batch mode.
      defaultValue = "" + (3 * 3600),
      documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS,
      effectTags = {OptionEffectTag.EAGERNESS_TO_EXIT, OptionEffectTag.LOSES_INCREMENTAL_STATE},
      valueHelp = "<integer>",
      help =
          "The number of seconds the build server will wait idling before shutting down. Zero"
              + " means that the server will never shutdown. This is only read on server-startup,"
              + " changing this option will not cause the server to restart.")
  public int maxIdleSeconds;

  @Option(
      name = "shutdown_on_low_sys_mem",
      defaultValue = "false",
      documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS,
      effectTags = {OptionEffectTag.EAGERNESS_TO_EXIT, OptionEffectTag.LOSES_INCREMENTAL_STATE},
      help =
          "If max_idle_secs is set and the build server has been idle for a while, shut down the "
              + "server when the system is low on free RAM. Linux only.")
  public boolean shutdownOnLowSysMem;

  @Option(
      name = "batch",
      defaultValue = "false",
      documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS,
      effectTags = {
        OptionEffectTag.LOSES_INCREMENTAL_STATE,
        OptionEffectTag.BAZEL_INTERNAL_CONFIGURATION
      },
      metadataTags = {OptionMetadataTag.DEPRECATED},
      help =
          "If set, Bazel will be run as just a client process without a server, instead of in "
              + "the standard client/server mode. This is deprecated and will be removed, please "
              + "prefer shutting down the server explicitly if you wish to avoid lingering "
              + "servers.")
  public boolean batch;

  @Option(
      name = "deep_execroot",
      defaultValue = "true", // NOTE: only for documentation, value is always passed by the client.
      documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS,
      effectTags = {OptionEffectTag.LOSES_INCREMENTAL_STATE, OptionEffectTag.EXECUTION},
      help =
          "If set, the execution root will be under $OUTPUT_BASE/execroot instead of "
              + "$OUTPUT_BASE.")
  public boolean deepExecRoot;

  @Option(
      name = "block_for_lock",
      defaultValue = "true", // NOTE: only for documentation, value never passed to the server.
      documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS,
      effectTags = {OptionEffectTag.EAGERNESS_TO_EXIT},
      help =
          "When --noblock_for_lock is passed, Bazel does not wait for a running command to "
              + "complete, but instead exits immediately.")
  public boolean blockForLock;

  @Option(
      name = "io_nice_level",
      defaultValue = "-1", // NOTE: only for documentation, value never passed to the server.
      documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS,
      effectTags = {OptionEffectTag.HOST_MACHINE_RESOURCE_OPTIMIZATIONS},
      valueHelp = "{-1,0,1,2,3,4,5,6,7}",
      help =
          "Only on Linux; set a level from 0-7 for best-effort IO scheduling using the "
              + "sys_ioprio_set system call. 0 is highest priority, 7 is lowest. The anticipatory "
              + "scheduler may only honor up to priority 4. If set to a negative value, then Bazel "
              + "does not perform a system call.")
  public int ioNiceLevel;

  @Option(
      name = "batch_cpu_scheduling",
      defaultValue = "false", // NOTE: only for documentation, value never passed to the server.
      documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS,
      effectTags = {OptionEffectTag.HOST_MACHINE_RESOURCE_OPTIMIZATIONS},
      help =
          "Only on Linux; use 'batch' CPU scheduling for Blaze. This policy is useful for "
              + "workloads that are non-interactive, but do not want to lower their nice value. "
              + "See 'man 2 sched_setscheduler'. If false, then Bazel does not perform a system "
              + "call.")
  public boolean batchCpuScheduling;

  @Option(
      name = "ignore_all_rc_files",
      defaultValue = "false", // NOTE: purely decorative, rc files are read by the client.
      documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS,
      effectTags = {OptionEffectTag.CHANGES_INPUTS},
      help =
          "Disables all rc files, regardless of the values of other rc-modifying flags, even if "
              + "these flags come later in the list of startup options.")
  public boolean ignoreAllRcFiles;

  @Option(
      name = "fatal_event_bus_exceptions",
      defaultValue = "false", // NOTE: only for documentation, value is always passed by the client.
      documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
      effectTags = {OptionEffectTag.EAGERNESS_TO_EXIT, OptionEffectTag.LOSES_INCREMENTAL_STATE},
      deprecationWarning = "Will be enabled by default and removed soon",
      help = "No-op: please use --fatal_event_bus_exceptions_exclusions instead")
  public boolean fatalEventBusExceptions;

  @Option(
      name = "option_sources",
      converter = OptionSourcesConverter.class,
      defaultValue = "",
      documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
      effectTags = {OptionEffectTag.AFFECTS_OUTPUTS},
      metadataTags = {OptionMetadataTag.HIDDEN},
      help = "")
  public Map<String, String> optionSources;

  // TODO(bazel-team): In order to make it easier to have local watchers in open source Bazel,
  // turn this into a non-startup option.
  @Option(
      name = "watchfs",
      defaultValue = "false", // NOTE: only for documentation, value is always passed by the client.
      documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS,
      effectTags = {OptionEffectTag.UNKNOWN},
      metadataTags = OptionMetadataTag.DEPRECATED,
      help =
          "If true, %{product} tries to use the operating system's file watch service for local "
              + "changes instead of scanning every file for a change.")
  public boolean watchFS;

  // This option is only passed in --batch mode. The value is otherwise passed as part of the
  // server request.
  @Option(
      name = "invocation_policy",
      defaultValue = "",
      documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
      effectTags = {OptionEffectTag.CHANGES_INPUTS},
      help =
          "A base64-encoded-binary-serialized or text-formated "
              + "invocation_policy.InvocationPolicy proto. Unlike other options, it is an error to "
              + "specify --invocation_policy multiple times.")
  public String invocationPolicy;

  @Option(
      name = "command_port",
      defaultValue = "0",
      documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
      effectTags = {
        OptionEffectTag.LOSES_INCREMENTAL_STATE,
        OptionEffectTag.BAZEL_INTERNAL_CONFIGURATION
      },
      help = "Port to start up the gRPC command server on. If 0, let the kernel choose.")
  public int commandPort;

  @Option(
      name = "product_name",
      defaultValue = "bazel", // NOTE: only for documentation, value is always passed by the client.
      documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
      effectTags = {
        OptionEffectTag.LOSES_INCREMENTAL_STATE,
        OptionEffectTag.AFFECTS_OUTPUTS,
        OptionEffectTag.BAZEL_MONITORING
      },
      metadataTags = {OptionMetadataTag.HIDDEN},
      help =
          "The name of the build system. It is used as part of the name of the generated "
              + "directories (e.g. productName-bin for binaries) as well as for printing error "
              + "messages and logging")
  public String productName;

  // TODO(ulfjack): Make this a command option.
  @Option(
      name = "write_command_log",
      defaultValue = "true", // NOTE: only for documentation, value is always passed by the client.
      documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
      effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.LOSES_INCREMENTAL_STATE},
      help = "Whether or not to write the command.log file")
  public boolean writeCommandLog;

  @Option(
      name = "client_debug",
      defaultValue = "false", // NOTE: only for documentation, value is set and used by the client.
      documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS,
      effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
      help =
          "If true, log debug information from the client to stderr. Changing this option will not "
              + "cause the server to restart.")
  public boolean clientDebug;

  @Option(
      name = "connect_timeout_secs",
      defaultValue = "30", // NOTE: only for documentation, value is set and used by the client.
      documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS,
      effectTags = {OptionEffectTag.BAZEL_INTERNAL_CONFIGURATION},
      help = "The amount of time the client waits for each attempt to connect to the server")
  public int connectTimeoutSecs;

  // TODO(b/109764197): Add OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS & remove the
  // experimental tag once this has been tested and is ready for use.
  @Option(
      name = "digest_function",
      defaultValue = "null",
      converter = DigestHashFunction.DigestFunctionConverter.class,
      documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
      effectTags = {
        OptionEffectTag.LOSES_INCREMENTAL_STATE,
        OptionEffectTag.BAZEL_INTERNAL_CONFIGURATION
      },
      metadataTags = OptionMetadataTag.EXPERIMENTAL,
      help = "The hash function to use when computing file digests.")
  public DigestHashFunction digestHashFunction;

  @Deprecated
  @Option(
      name = "expand_configs_in_place",
      defaultValue = "true", // NOTE: only for documentation, value is always passed by the client.
      documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS,
      effectTags = {OptionEffectTag.NO_OP},
      metadataTags = {OptionMetadataTag.DEPRECATED},
      deprecationWarning = "This option is now a no-op and will soon be deleted.",
      help =
          "Changed the expansion of --config flags to be done in-place, as opposed to in a fixed "
              + "point expansion between normal rc options and command-line specified options.")
  public boolean expandConfigsInPlace;

  @Option(
      name = "idle_server_tasks",
      defaultValue = "true", // NOTE: only for documentation, value is set and used by the client.
      documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS,
      effectTags = {
        OptionEffectTag.LOSES_INCREMENTAL_STATE,
        OptionEffectTag.HOST_MACHINE_RESOURCE_OPTIMIZATIONS,
      },
      help = "Run System.gc() when the server is idle")
  public boolean idleServerTasks;

  @Option(
      name = "unlimit_coredumps",
      defaultValue = "false", // NOTE: purely decorative, rc files are read by the client.
      documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS,
      effectTags = {
        OptionEffectTag.BAZEL_INTERNAL_CONFIGURATION,
      },
      help =
          "Raises the soft coredump limit to the hard limit to make coredumps of the server"
              + " (including the JVM) and the client possible under common conditions. Stick this"
              + " flag in your bazelrc once and forget about it so that you get coredumps when you"
              + " actually encounter a condition that triggers them.")
  public boolean unlimitCoredumps;

  @Option(
      name = "macos_qos_class",
      defaultValue = "default", // Only for documentation; value is set and used by the client.
      documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS,
      effectTags = {
        OptionEffectTag.HOST_MACHINE_RESOURCE_OPTIMIZATIONS,
      },
      help =
          "Sets the QoS service class of the %{product} server when running on macOS. This "
              + "flag has no effect on all other platforms but is supported to ensure rc files "
              + "can be shared among them without changes. Possible values are: user-interactive, "
              + "user-initiated, default, utility, and background.")
  public String macosQosClass;

  @Option(
      name = "incompatible_enable_execution_transition",
      defaultValue = "false", // Only for documentation; value is set by the client.
      documentationCategory = OptionDocumentationCategory.TOOLCHAIN,
      effectTags = {OptionEffectTag.BAZEL_INTERNAL_CONFIGURATION},
      metadataTags = {
        OptionMetadataTag.INCOMPATIBLE_CHANGE,
        OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
      },
      help = "If false, the execution transition behaves like the host transition.")
  public boolean enableExecutionTransition;

  @Option(
      name = "windows_enable_symlinks",
      defaultValue = "false", // Only for documentation; value is set by the client.
      documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS,
      effectTags = {OptionEffectTag.BAZEL_INTERNAL_CONFIGURATION},
      help =
          "If true, real symbolic links will be created on Windows instead of file copying. "
              + "Requires Windows developer mode to be enabled and Windows 10 version 1703 or "
              + "greater.")
  public boolean enableWindowsSymlinks;

  @Option(
      name = "unix_digest_hash_attribute_name",
      defaultValue = "",
      documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
      effectTags = {OptionEffectTag.CHANGES_INPUTS, OptionEffectTag.LOSES_INCREMENTAL_STATE},
      help =
          "The name of an extended attribute that can be placed on files to store a precomputed "
              + "copy of the file's hash, corresponding with --digest_function. This option "
              + "can be used to reduce disk I/O and CPU load caused by hash computation. This "
              + "extended attribute is checked on all source files and output files, meaning "
              + "that it causes a significant number of invocations of the getxattr() system call.")
  public String unixDigestHashAttributeName;
}

{'repo_name': 'bazelbuild/bazel', 'stars': '15030', 'repo_language': 'Java', 'file_name': 'BUILD', 'mime_type': 'text/plain', 'hash': -7510072480491701552, 'source_dataset': 'data'}


/*
 * Copyright (c) 2014-2015 VMware, Inc. All Rights Reserved.
 *
 * 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.
 */

package com.vmware.xenon.services.samples;

import static org.junit.Assert.assertEquals;

import java.net.URI;

import org.junit.Before;
import org.junit.Test;

import com.vmware.xenon.common.BasicReusableHostTestCase;
import com.vmware.xenon.common.Operation;
import com.vmware.xenon.common.ServiceDocument;
import com.vmware.xenon.common.ServiceErrorResponse;
import com.vmware.xenon.common.UriUtils;
import com.vmware.xenon.services.samples.SamplePreviousEchoService.EchoServiceState;

public class TestSamplePreviousEchoService extends BasicReusableHostTestCase {

    @Before
    public void prepare() throws Throwable {
        this.host.startFactory(new SamplePreviousEchoService());
        this.host.waitForServiceAvailable(SamplePreviousEchoService.FACTORY_LINK);
    }

    @Test
    public void testState() throws Throwable {

        URI factoryUri = UriUtils.buildFactoryUri(this.host, SamplePreviousEchoService.class);
        this.host.testStart(1);
        URI[] instanceURIs = new URI[1];
        EchoServiceState initialState = new EchoServiceState();
        initialState.documentSelfLink = "one";
        initialState.message = "Initial Message";
        // try creating instance
        Operation createPost = Operation
                .createPost(factoryUri)
                .setBody(initialState).setCompletion((o, e) -> {
                    if (e != null) {
                        this.host.failIteration(e);
                        return;
                    }
                    ServiceDocument rsp = o.getBody(ServiceDocument.class);
                    instanceURIs[0] = UriUtils.buildUri(this.host, rsp.documentSelfLink);
                    this.host.completeIteration();
                });
        this.host.send(createPost);
        this.host.testWait();

        // Verify initial state
        // Make sure the default PUT worked
        EchoServiceState currentState = this.host.getServiceState(null,
                EchoServiceState.class, instanceURIs[0]);
        assertEquals(currentState.message, initialState.message);

        this.host.testStart(1);
        // Now send do a PUT
        EchoServiceState newState = new EchoServiceState();
        newState.message = "Message One";
        Operation createPut = Operation
                .createPut(instanceURIs[0])
                .setBody(newState)
                .setCompletion((o, e) -> {
                    if (e != null) {
                        ServiceErrorResponse rsp = o.getErrorResponseBody();
                        if (rsp.message == null || rsp.message.isEmpty()) {
                            this.host.failIteration(new IllegalStateException(
                                    "Missing error response"));
                            return;
                        }
                    }
                    this.host.completeIteration();
                });
        this.host.send(createPut);
        host.testWait();

        // This should be equal to the *previous* state
        currentState = this.host.getServiceState(null, EchoServiceState.class, instanceURIs[0]);
        assertEquals(currentState.message, initialState.message);
    }
}

{'repo_name': 'vmware-archive/xenon', 'stars': '226', 'repo_language': 'Java', 'file_name': 'copy-files.sh', 'mime_type': 'text/x-shellscript', 'hash': 7492806699148762257, 'source_dataset': 'data'}


logicjs

Logic programming for JavaScript.

echo "Error: no test specified" && exit 1

{'repo_name': 'mcsoto/LogicJS', 'stars': '991', 'repo_language': 'JavaScript', 'file_name': 'logic.js', 'mime_type': 'text/x-c', 'hash': 106296823141266444, 'source_dataset': 'data'}


/*
 * This file is part of wl12xx
 *
 * Copyright (C) 2012 Texas Instruments. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

#ifndef __WL12XX_SCAN_H__
#define __WL12XX_SCAN_H__

#include "../wlcore/wlcore.h"
#include "../wlcore/cmd.h"
#include "../wlcore/scan.h"

#define WL12XX_MAX_CHANNELS_5GHZ 23

struct basic_scan_params {
	/* Scan option flags (WL1271_SCAN_OPT_*) */
	__le16 scan_options;
	u8 role_id;
	/* Number of scan channels in the list (maximum 30) */
	u8 n_ch;
	/* This field indicates the number of probe requests to send
	   per channel for an active scan */
	u8 n_probe_reqs;
	u8 tid_trigger;
	u8 ssid_len;
	u8 use_ssid_list;

	/* Rate bit field for sending the probes */
	__le32 tx_rate;

	u8 ssid[IEEE80211_MAX_SSID_LEN];
	/* Band to scan */
	u8 band;

	u8 scan_tag;
	u8 padding2[2];
} __packed;

struct basic_scan_channel_params {
	/* Duration in TU to wait for frames on a channel for active scan */
	__le32 min_duration;
	__le32 max_duration;
	__le32 bssid_lsb;
	__le16 bssid_msb;
	u8 early_termination;
	u8 tx_power_att;
	u8 channel;
	/* FW internal use only! */
	u8 dfs_candidate;
	u8 activity_detected;
	u8 pad;
} __packed;

struct wl1271_cmd_scan {
	struct wl1271_cmd_header header;

	struct basic_scan_params params;
	struct basic_scan_channel_params channels[WL1271_SCAN_MAX_CHANNELS];

	/* src mac address */
	u8 addr[ETH_ALEN];
	u8 padding[2];
} __packed;

struct wl1271_cmd_sched_scan_config {
	struct wl1271_cmd_header header;

	__le32 intervals[SCAN_MAX_CYCLE_INTERVALS];

	s8 rssi_threshold; /* for filtering (in dBm) */
	s8 snr_threshold;  /* for filtering (in dB) */

	u8 cycles;       /* maximum number of scan cycles */
	u8 report_after; /* report when this number of results are received */
	u8 terminate;    /* stop scanning after reporting */

	u8 tag;
	u8 bss_type; /* for filtering */
	u8 filter_type;

	u8 ssid_len;     /* For SCAN_SSID_FILTER_SPECIFIC */
	u8 ssid[IEEE80211_MAX_SSID_LEN];

	u8 n_probe_reqs; /* Number of probes requests per channel */

	u8 passive[SCAN_MAX_BANDS];
	u8 active[SCAN_MAX_BANDS];

	u8 dfs;

	u8 n_pactive_ch; /* number of pactive (passive until fw detects energy)
			    channels in BG band */
	u8 role_id;
	u8 padding[1];
	struct conn_scan_ch_params channels_2[MAX_CHANNELS_2GHZ];
	struct conn_scan_ch_params channels_5[WL12XX_MAX_CHANNELS_5GHZ];
	struct conn_scan_ch_params channels_4[MAX_CHANNELS_4GHZ];
} __packed;

struct wl1271_cmd_sched_scan_start {
	struct wl1271_cmd_header header;

	u8 tag;
	u8 role_id;
	u8 padding[2];
} __packed;

struct wl1271_cmd_sched_scan_stop {
	struct wl1271_cmd_header header;

	u8 tag;
	u8 role_id;
	u8 padding[2];
} __packed;

int wl12xx_scan_start(struct wl1271 *wl, struct wl12xx_vif *wlvif,
		      struct cfg80211_scan_request *req);
int wl12xx_scan_stop(struct wl1271 *wl, struct wl12xx_vif *wlvif);
void wl12xx_scan_completed(struct wl1271 *wl, struct wl12xx_vif *wlvif);
int wl12xx_sched_scan_start(struct wl1271 *wl, struct wl12xx_vif  *wlvif,
			    struct cfg80211_sched_scan_request *req,
			    struct ieee80211_scan_ies *ies);
void wl12xx_scan_sched_scan_stop(struct wl1271 *wl,  struct wl12xx_vif *wlvif);
#endif

{'repo_name': 'ssrg-vt/popcorn-kernel', 'stars': '105', 'repo_language': 'C', 'file_name': 'wacom_serial4.c', 'mime_type': 'text/x-c', 'hash': -8517532626559932105, 'source_dataset': 'data'}


/*
 * Copyright (c) 2001, 2003, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 *
 */

package sun.jvm.hotspot.interpreter;

import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.utilities.*;

public class BytecodeTableswitch extends Bytecode {
  BytecodeTableswitch(Method method, int bci) {
    super(method, bci);
  }

  // Attributes
  public int  defaultOffset()     { return javaSignedWordAt(alignedOffset(1 + 0*jintSize)); }
  public int  lowKey()            { return javaSignedWordAt(alignedOffset(1 + 1*jintSize)); }
  public int  highKey()           { return javaSignedWordAt(alignedOffset(1 + 2*jintSize)); }
  public int  length()            { return highKey()-lowKey()+1; }
  public int  destOffsetAt(int i) {
    int x2 = alignedOffset(1 + (3 + i)*jintSize);
    int val = javaSignedWordAt(x2);
    return javaSignedWordAt(alignedOffset(1 + (3 + i)*jintSize));
  }

  public void verify() {
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(isValid(), "check tableswitch");
    }
  }

  public boolean isValid() {
    boolean result = javaCode() == Bytecodes._tableswitch;
    if (result == false) return false;
    int lo = lowKey();
    int hi = highKey();
    if (hi < lo) // incorrect hi/lo values in tableswitch
       return false;

    int i  = hi - lo - 1 ;
    while (i-- > 0) {
      // no special check needed
    }
    return true;
  }

  public static BytecodeTableswitch at(Method method, int bci) {
    BytecodeTableswitch b = new BytecodeTableswitch(method, bci);
    if (Assert.ASSERTS_ENABLED) {
      b.verify();
    }
    return b;
  }

  /** Like at, but returns null if the BCI is not at tableswitch  */
  public static BytecodeTableswitch atCheck(Method method, int bci) {
    BytecodeTableswitch b = new BytecodeTableswitch(method, bci);
    return (b.isValid() ? b : null);
  }

  public static BytecodeTableswitch at(BytecodeStream bcs) {
    return new BytecodeTableswitch(bcs.method(), bcs.bci());
  }

  public String toString() {
    StringBuffer buf = new StringBuffer();
    buf.append("tableswitch");
    buf.append(spaces);
    buf.append("default: ");
    buf.append(Integer.toString(bci() + defaultOffset()));
    buf.append(comma);
    int lo = lowKey();
    int hi = highKey();
    int i  = hi - lo - 1 ;
    while (i-- > 0) {
       buf.append("case ");
       buf.append(Integer.toString(lo + i));
       buf.append(':');
       buf.append(Integer.toString(bci() + destOffsetAt(i)));
       buf.append(comma);
    }
    return buf.toString();
  }
}

{'repo_name': 'AdoptOpenJDK/openjdk-jdk11u', 'stars': '106', 'repo_language': 'Java', 'file_name': 'CompositionArea.java', 'mime_type': 'text/x-java', 'hash': -5253853848030007190, 'source_dataset': 'data'}


The System `fsstat` metricset provides overall file system statistics.

This metricset is available on:

- FreeBSD
- Linux
- macOS
- OpenBSD
- Windows

[float]
=== Configuration

*`filesystem.ignore_types`* - A list of filesystem types to ignore. Metrics will
not be collected from filesystems matching these types. This setting also
affects the `filesystem` metricset. If this option is not set, metricbeat ignores
all types for virtual devices in systems where this information is available (e.g.
all types marked as `nodev` in `/proc/filesystems` in Linux systems).

{'repo_name': 'elastic/beats', 'stars': '9014', 'repo_language': 'Go', 'file_name': 'generate.go', 'mime_type': 'text/plain', 'hash': 1436247502550365621, 'source_dataset': 'data'}


# -*- coding: utf-8 -*-
"""
    pygments.lexers.haskell
    ~~~~~~~~~~~~~~~~~~~~~~~

    Lexers for Haskell and related languages.

    :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
"""

import re

from pygments.lexer import Lexer, RegexLexer, bygroups, do_insertions, \
    default, include
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
    Number, Punctuation, Generic
from pygments import unistring as uni

__all__ = ['HaskellLexer', 'IdrisLexer', 'AgdaLexer', 'CryptolLexer',
           'LiterateHaskellLexer', 'LiterateIdrisLexer', 'LiterateAgdaLexer',
           'LiterateCryptolLexer', 'KokaLexer']

line_re = re.compile('.*?\n')

class HaskellLexer(RegexLexer):
    """
    A Haskell lexer based on the lexemes defined in the Haskell 98 Report.

    .. versionadded:: 0.8
    """
    name = 'Haskell'
    aliases = ['haskell', 'hs']
    filenames = ['*.hs']
    mimetypes = ['text/x-haskell']

    flags = re.MULTILINE | re.UNICODE

    reserved = ('case', 'class', 'data', 'default', 'deriving', 'do', 'else',
                'family', 'if', 'in', 'infix[lr]?', 'instance',
                'let', 'newtype', 'of', 'then', 'type', 'where', '_')
    ascii = ('NUL', 'SOH', '[SE]TX', 'EOT', 'ENQ', 'ACK',
             'BEL', 'BS', 'HT', 'LF', 'VT', 'FF', 'CR', 'S[OI]', 'DLE',
             'DC[1-4]', 'NAK', 'SYN', 'ETB', 'CAN',
             'EM', 'SUB', 'ESC', '[FGRU]S', 'SP', 'DEL')

    tokens = {
        'root': [
            # Whitespace:
            (r'\s+', Text),
            # (r'--\s*|.*$', Comment.Doc),
            (r'--(?![!#$%&*+./<=>?@^|_~:\\]).*?$', Comment.Single),
            (r'\{-', Comment.Multiline, 'comment'),
            # Lexemes:
            #  Identifiers
            (r'\bimport\b', Keyword.Reserved, 'import'),
            (r'\bmodule\b', Keyword.Reserved, 'module'),
            (r'\berror\b', Name.Exception),
            (r'\b(%s)(?!\')\b' % '|'.join(reserved), Keyword.Reserved),
            (r"'[^\\]'", String.Char),  # this has to come before the TH quote
            (r'^[_' + uni.Ll + r'][\w\']*', Name.Function),
            (r"'?[_" + uni.Ll + r"][\w']*", Name),
            (r"('')?[" + uni.Lu + r"][\w\']*", Keyword.Type),
            (r"(')[" + uni.Lu + r"][\w\']*", Keyword.Type),
            (r"(')\[[^\]]*\]", Keyword.Type),  # tuples and lists get special treatment in GHC
            (r"(')\([^)]*\)", Keyword.Type),  # ..
            #  Operators
            (r'\\(?![:!#$%&*+.\\/<=>?@^|~-]+)', Name.Function),  # lambda operator
            (r'(<-|::|->|=>|=)(?![:!#$%&*+.\\/<=>?@^|~-]+)', Operator.Word),  # specials
            (r':[:!#$%&*+.\\/<=>?@^|~-]*', Keyword.Type),  # Constructor operators
            (r'[:!#$%&*+.\\/<=>?@^|~-]+', Operator),  # Other operators
            #  Numbers
            (r'\d+[eE][+-]?\d+', Number.Float),
            (r'\d+\.\d+([eE][+-]?\d+)?', Number.Float),
            (r'0[oO][0-7]+', Number.Oct),
            (r'0[xX][\da-fA-F]+', Number.Hex),
            (r'\d+', Number.Integer),
            #  Character/String Literals
            (r"'", String.Char, 'character'),
            (r'"', String, 'string'),
            #  Special
            (r'\[\]', Keyword.Type),
            (r'\(\)', Name.Builtin),
            (r'[][(),;`{}]', Punctuation),
        ],
        'import': [
            # Import statements
            (r'\s+', Text),
            (r'"', String, 'string'),
            # after "funclist" state
            (r'\)', Punctuation, '#pop'),
            (r'qualified\b', Keyword),
            # import X as Y
            (r'([' + uni.Lu + r'][\w.]*)(\s+)(as)(\s+)([' + uni.Lu + r'][\w.]*)',
             bygroups(Name.Namespace, Text, Keyword, Text, Name), '#pop'),
            # import X hiding (functions)
            (r'([' + uni.Lu + r'][\w.]*)(\s+)(hiding)(\s+)(\()',
             bygroups(Name.Namespace, Text, Keyword, Text, Punctuation), 'funclist'),
            # import X (functions)
            (r'([' + uni.Lu + r'][\w.]*)(\s+)(\()',
             bygroups(Name.Namespace, Text, Punctuation), 'funclist'),
            # import X
            (r'[\w.]+', Name.Namespace, '#pop'),
        ],
        'module': [
            (r'\s+', Text),
            (r'([' + uni.Lu + r'][\w.]*)(\s+)(\()',
             bygroups(Name.Namespace, Text, Punctuation), 'funclist'),
            (r'[' + uni.Lu + r'][\w.]*', Name.Namespace, '#pop'),
        ],
        'funclist': [
            (r'\s+', Text),
            (r'[' + uni.Lu + r']\w*', Keyword.Type),
            (r'(_[\w\']+|[' + uni.Ll + r'][\w\']*)', Name.Function),
            (r'--(?![!#$%&*+./<=>?@^|_~:\\]).*?$', Comment.Single),
            (r'\{-', Comment.Multiline, 'comment'),
            (r',', Punctuation),
            (r'[:!#$%&*+.\\/<=>?@^|~-]+', Operator),
            # (HACK, but it makes sense to push two instances, believe me)
            (r'\(', Punctuation, ('funclist', 'funclist')),
            (r'\)', Punctuation, '#pop:2'),
        ],
        # NOTE: the next four states are shared in the AgdaLexer; make sure
        # any change is compatible with Agda as well or copy over and change
        'comment': [
            # Multiline Comments
            (r'[^-{}]+', Comment.Multiline),
            (r'\{-', Comment.Multiline, '#push'),
            (r'-\}', Comment.Multiline, '#pop'),
            (r'[-{}]', Comment.Multiline),
        ],
        'character': [
            # Allows multi-chars, incorrectly.
            (r"[^\\']'", String.Char, '#pop'),
            (r"\\", String.Escape, 'escape'),
            ("'", String.Char, '#pop'),
        ],
        'string': [
            (r'[^\\"]+', String),
            (r"\\", String.Escape, 'escape'),
            ('"', String, '#pop'),
        ],
        'escape': [
            (r'[abfnrtv"\'&\\]', String.Escape, '#pop'),
            (r'\^[][' + uni.Lu + r'@^_]', String.Escape, '#pop'),
            ('|'.join(ascii), String.Escape, '#pop'),
            (r'o[0-7]+', String.Escape, '#pop'),
            (r'x[\da-fA-F]+', String.Escape, '#pop'),
            (r'\d+', String.Escape, '#pop'),
            (r'\s+\\', String.Escape, '#pop'),
        ],
    }

class IdrisLexer(RegexLexer):
    """
    A lexer for the dependently typed programming language Idris.

    Based on the Haskell and Agda Lexer.

    .. versionadded:: 2.0
    """
    name = 'Idris'
    aliases = ['idris', 'idr']
    filenames = ['*.idr']
    mimetypes = ['text/x-idris']

    reserved = ('case', 'class', 'data', 'default', 'using', 'do', 'else',
                'if', 'in', 'infix[lr]?', 'instance', 'rewrite', 'auto',
                'namespace', 'codata', 'mutual', 'private', 'public', 'abstract',
                'total', 'partial',
                'let', 'proof', 'of', 'then', 'static', 'where', '_', 'with',
                'pattern',  'term',  'syntax', 'prefix',
                'postulate', 'parameters', 'record', 'dsl', 'impossible', 'implicit',
                'tactics', 'intros', 'intro', 'compute', 'refine', 'exact', 'trivial')

    ascii = ('NUL', 'SOH', '[SE]TX', 'EOT', 'ENQ', 'ACK',
             'BEL', 'BS', 'HT', 'LF', 'VT', 'FF', 'CR', 'S[OI]', 'DLE',
             'DC[1-4]', 'NAK', 'SYN', 'ETB', 'CAN',
             'EM', 'SUB', 'ESC', '[FGRU]S', 'SP', 'DEL')

    directives = ('lib', 'link', 'flag', 'include', 'hide', 'freeze', 'access',
                  'default', 'logging', 'dynamic', 'name', 'error_handlers', 'language')

    tokens = {
        'root': [
            # Comments
            (r'^(\s*)(%%%s)' % '|'.join(directives),
             bygroups(Text, Keyword.Reserved)),
            (r'(\s*)(--(?![!#$%&*+./<=>?@^|_~:\\]).*?)$', bygroups(Text, Comment.Single)),
            (r'(\s*)(\|{3}.*?)$', bygroups(Text, Comment.Single)),
            (r'(\s*)(\{-)', bygroups(Text, Comment.Multiline), 'comment'),
            # Declaration
            (r'^(\s*)([^\s(){}]+)(\s*)(:)(\s*)',
             bygroups(Text, Name.Function, Text, Operator.Word, Text)),
            #  Identifiers
            (r'\b(%s)(?!\')\b' % '|'.join(reserved), Keyword.Reserved),
            (r'(import|module)(\s+)', bygroups(Keyword.Reserved, Text), 'module'),
            (r"('')?[A-Z][\w\']*", Keyword.Type),
            (r'[a-z][\w\']*', Text),
            #  Special Symbols
            (r'(<-|::|->|=>|=)', Operator.Word),  # specials
            (r'([(){}\[\]:!#$%&*+.\\/<=>?@^|~-]+)', Operator.Word),  # specials
            #  Numbers
            (r'\d+[eE][+-]?\d+', Number.Float),
            (r'\d+\.\d+([eE][+-]?\d+)?', Number.Float),
            (r'0[xX][\da-fA-F]+', Number.Hex),
            (r'\d+', Number.Integer),
            # Strings
            (r"'", String.Char, 'character'),
            (r'"', String, 'string'),
            (r'[^\s(){}]+', Text),
            (r'\s+?', Text),  # Whitespace
        ],
        'module': [
            (r'\s+', Text),
            (r'([A-Z][\w.]*)(\s+)(\()',
             bygroups(Name.Namespace, Text, Punctuation), 'funclist'),
            (r'[A-Z][\w.]*', Name.Namespace, '#pop'),
        ],
        'funclist': [
            (r'\s+', Text),
            (r'[A-Z]\w*', Keyword.Type),
            (r'(_[\w\']+|[a-z][\w\']*)', Name.Function),
            (r'--.*$', Comment.Single),
            (r'\{-', Comment.Multiline, 'comment'),
            (r',', Punctuation),
            (r'[:!#$%&*+.\\/<=>?@^|~-]+', Operator),
            # (HACK, but it makes sense to push two instances, believe me)
            (r'\(', Punctuation, ('funclist', 'funclist')),
            (r'\)', Punctuation, '#pop:2'),
        ],
        # NOTE: the next four states are shared in the AgdaLexer; make sure
        # any change is compatible with Agda as well or copy over and change
        'comment': [
            # Multiline Comments
            (r'[^-{}]+', Comment.Multiline),
            (r'\{-', Comment.Multiline, '#push'),
            (r'-\}', Comment.Multiline, '#pop'),
            (r'[-{}]', Comment.Multiline),
        ],
        'character': [
            # Allows multi-chars, incorrectly.
            (r"[^\\']", String.Char),
            (r"\\", String.Escape, 'escape'),
            ("'", String.Char, '#pop'),
        ],
        'string': [
            (r'[^\\"]+', String),
            (r"\\", String.Escape, 'escape'),
            ('"', String, '#pop'),
        ],
        'escape': [
            (r'[abfnrtv"\'&\\]', String.Escape, '#pop'),
            (r'\^[][A-Z@^_]', String.Escape, '#pop'),
            ('|'.join(ascii), String.Escape, '#pop'),
            (r'o[0-7]+', String.Escape, '#pop'),
            (r'x[\da-fA-F]+', String.Escape, '#pop'),
            (r'\d+', String.Escape, '#pop'),
            (r'\s+\\', String.Escape, '#pop')
        ],
    }

class AgdaLexer(RegexLexer):
    """
    For the `Agda <http://wiki.portal.chalmers.se/agda/pmwiki.php>`_
    dependently typed functional programming language and proof assistant.

    .. versionadded:: 2.0
    """

    name = 'Agda'
    aliases = ['agda']
    filenames = ['*.agda']
    mimetypes = ['text/x-agda']

    reserved = ['abstract', 'codata', 'coinductive', 'constructor', 'data',
                'field', 'forall', 'hiding', 'in', 'inductive', 'infix',
                'infixl', 'infixr', 'instance', 'let', 'mutual', 'open',
                'pattern', 'postulate', 'primitive', 'private',
                'quote', 'quoteGoal', 'quoteTerm',
                'record', 'renaming', 'rewrite', 'syntax', 'tactic',
                'unquote', 'unquoteDecl', 'using', 'where', 'with']

    tokens = {
        'root': [
            # Declaration
            (r'^(\s*)([^\s(){}]+)(\s*)(:)(\s*)',
             bygroups(Text, Name.Function, Text, Operator.Word, Text)),
            # Comments
            (r'--(?![!#$%&*+./<=>?@^|_~:\\]).*?$', Comment.Single),
            (r'\{-', Comment.Multiline, 'comment'),
            # Holes
            (r'\{!', Comment.Directive, 'hole'),
            # Lexemes:
            #  Identifiers
            (r'\b(%s)(?!\')\b' % '|'.join(reserved), Keyword.Reserved),
            (r'(import|module)(\s+)', bygroups(Keyword.Reserved, Text), 'module'),
            (r'\b(Set|Prop)\b', Keyword.Type),
            #  Special Symbols
            (r'(\(|\)|\{|\})', Operator),
            (u'(\\.{1,3}|\\||\u039B|\u2200|\u2192|:|=|->)', Operator.Word),
            #  Numbers
            (r'\d+[eE][+-]?\d+', Number.Float),
            (r'\d+\.\d+([eE][+-]?\d+)?', Number.Float),
            (r'0[xX][\da-fA-F]+', Number.Hex),
            (r'\d+', Number.Integer),
            # Strings
            (r"'", String.Char, 'character'),
            (r'"', String, 'string'),
            (r'[^\s(){}]+', Text),
            (r'\s+?', Text),  # Whitespace
        ],
        'hole': [
            # Holes
            (r'[^!{}]+', Comment.Directive),
            (r'\{!', Comment.Directive, '#push'),
            (r'!\}', Comment.Directive, '#pop'),
            (r'[!{}]', Comment.Directive),
        ],
        'module': [
            (r'\{-', Comment.Multiline, 'comment'),
            (r'[a-zA-Z][\w.]*', Name, '#pop'),
            (r'[\W0-9_]+', Text)
        ],
        'comment': HaskellLexer.tokens['comment'],
        'character': HaskellLexer.tokens['character'],
        'string': HaskellLexer.tokens['string'],
        'escape': HaskellLexer.tokens['escape']
    }

class CryptolLexer(RegexLexer):
    """
    FIXME: A Cryptol2 lexer based on the lexemes defined in the Haskell 98 Report.

    .. versionadded:: 2.0
    """
    name = 'Cryptol'
    aliases = ['cryptol', 'cry']
    filenames = ['*.cry']
    mimetypes = ['text/x-cryptol']

    reserved = ('Arith', 'Bit', 'Cmp', 'False', 'Inf', 'True', 'else',
                'export', 'extern', 'fin', 'if', 'import', 'inf', 'lg2',
                'max', 'min', 'module', 'newtype', 'pragma', 'property',
                'then', 'type', 'where', 'width')
    ascii = ('NUL', 'SOH', '[SE]TX', 'EOT', 'ENQ', 'ACK',
             'BEL', 'BS', 'HT', 'LF', 'VT', 'FF', 'CR', 'S[OI]', 'DLE',
             'DC[1-4]', 'NAK', 'SYN', 'ETB', 'CAN',
             'EM', 'SUB', 'ESC', '[FGRU]S', 'SP', 'DEL')

    tokens = {
        'root': [
            # Whitespace:
            (r'\s+', Text),
            # (r'--\s*|.*$', Comment.Doc),
            (r'//.*$', Comment.Single),
            (r'/\*', Comment.Multiline, 'comment'),
            # Lexemes:
            #  Identifiers
            (r'\bimport\b', Keyword.Reserved, 'import'),
            (r'\bmodule\b', Keyword.Reserved, 'module'),
            (r'\berror\b', Name.Exception),
            (r'\b(%s)(?!\')\b' % '|'.join(reserved), Keyword.Reserved),
            (r'^[_a-z][\w\']*', Name.Function),
            (r"'?[_a-z][\w']*", Name),
            (r"('')?[A-Z][\w\']*", Keyword.Type),
            #  Operators
            (r'\\(?![:!#$%&*+.\\/<=>?@^|~-]+)', Name.Function),  # lambda operator
            (r'(<-|::|->|=>|=)(?![:!#$%&*+.\\/<=>?@^|~-]+)', Operator.Word),  # specials
            (r':[:!#$%&*+.\\/<=>?@^|~-]*', Keyword.Type),  # Constructor operators
            (r'[:!#$%&*+.\\/<=>?@^|~-]+', Operator),  # Other operators
            #  Numbers
            (r'\d+[eE][+-]?\d+', Number.Float),
            (r'\d+\.\d+([eE][+-]?\d+)?', Number.Float),
            (r'0[oO][0-7]+', Number.Oct),
            (r'0[xX][\da-fA-F]+', Number.Hex),
            (r'\d+', Number.Integer),
            #  Character/String Literals
            (r"'", String.Char, 'character'),
            (r'"', String, 'string'),
            #  Special
            (r'\[\]', Keyword.Type),
            (r'\(\)', Name.Builtin),
            (r'[][(),;`{}]', Punctuation),
        ],
        'import': [
            # Import statements
            (r'\s+', Text),
            (r'"', String, 'string'),
            # after "funclist" state
            (r'\)', Punctuation, '#pop'),
            (r'qualified\b', Keyword),
            # import X as Y
            (r'([A-Z][\w.]*)(\s+)(as)(\s+)([A-Z][\w.]*)',
             bygroups(Name.Namespace, Text, Keyword, Text, Name), '#pop'),
            # import X hiding (functions)
            (r'([A-Z][\w.]*)(\s+)(hiding)(\s+)(\()',
             bygroups(Name.Namespace, Text, Keyword, Text, Punctuation), 'funclist'),
            # import X (functions)
            (r'([A-Z][\w.]*)(\s+)(\()',
             bygroups(Name.Namespace, Text, Punctuation), 'funclist'),
            # import X
            (r'[\w.]+', Name.Namespace, '#pop'),
        ],
        'module': [
            (r'\s+', Text),
            (r'([A-Z][\w.]*)(\s+)(\()',
             bygroups(Name.Namespace, Text, Punctuation), 'funclist'),
            (r'[A-Z][\w.]*', Name.Namespace, '#pop'),
        ],
        'funclist': [
            (r'\s+', Text),
            (r'[A-Z]\w*', Keyword.Type),
            (r'(_[\w\']+|[a-z][\w\']*)', Name.Function),
            # TODO: these don't match the comments in docs, remove.
            #(r'--(?![!#$%&*+./<=>?@^|_~:\\]).*?$', Comment.Single),
            #(r'{-', Comment.Multiline, 'comment'),
            (r',', Punctuation),
            (r'[:!#$%&*+.\\/<=>?@^|~-]+', Operator),
            # (HACK, but it makes sense to push two instances, believe me)
            (r'\(', Punctuation, ('funclist', 'funclist')),
            (r'\)', Punctuation, '#pop:2'),
        ],
        'comment': [
            # Multiline Comments
            (r'[^/*]+', Comment.Multiline),
            (r'/\*', Comment.Multiline, '#push'),
            (r'\*/', Comment.Multiline, '#pop'),
            (r'[*/]', Comment.Multiline),
        ],
        'character': [
            # Allows multi-chars, incorrectly.
            (r"[^\\']'", String.Char, '#pop'),
            (r"\\", String.Escape, 'escape'),
            ("'", String.Char, '#pop'),
        ],
        'string': [
            (r'[^\\"]+', String),
            (r"\\", String.Escape, 'escape'),
            ('"', String, '#pop'),
        ],
        'escape': [
            (r'[abfnrtv"\'&\\]', String.Escape, '#pop'),
            (r'\^[][A-Z@^_]', String.Escape, '#pop'),
            ('|'.join(ascii), String.Escape, '#pop'),
            (r'o[0-7]+', String.Escape, '#pop'),
            (r'x[\da-fA-F]+', String.Escape, '#pop'),
            (r'\d+', String.Escape, '#pop'),
            (r'\s+\\', String.Escape, '#pop'),
        ],
    }

    EXTRA_KEYWORDS = set(('join', 'split', 'reverse', 'transpose', 'width',
                          'length', 'tail', '<<', '>>', '<<<', '>>>', 'const',
                          'reg', 'par', 'seq', 'ASSERT', 'undefined', 'error',
                          'trace'))

    def get_tokens_unprocessed(self, text):
        stack = ['root']
        for index, token, value in \
                RegexLexer.get_tokens_unprocessed(self, text, stack):
            if token is Name and value in self.EXTRA_KEYWORDS:
                yield index, Name.Builtin, value
            else:
                yield index, token, value

class LiterateLexer(Lexer):
    """
    Base class for lexers of literate file formats based on LaTeX or Bird-style
    (prefixing each code line with ">").

    Additional options accepted:

    `litstyle`
        If given, must be ``"bird"`` or ``"latex"``.  If not given, the style
        is autodetected: if the first non-whitespace character in the source
        is a backslash or percent character, LaTeX is assumed, else Bird.
    """

    bird_re = re.compile(r'(>[ \t]*)(.*\n)')

    def __init__(self, baselexer, **options):
        self.baselexer = baselexer
        Lexer.__init__(self, **options)

    def get_tokens_unprocessed(self, text):
        style = self.options.get('litstyle')
        if style is None:
            style = (text.lstrip()[0:1] in '%\\') and 'latex' or 'bird'

        code = ''
        insertions = []
        if style == 'bird':
            # bird-style
            for match in line_re.finditer(text):
                line = match.group()
                m = self.bird_re.match(line)
                if m:
                    insertions.append((len(code),
                                       [(0, Comment.Special, m.group(1))]))
                    code += m.group(2)
                else:
                    insertions.append((len(code), [(0, Text, line)]))
        else:
            # latex-style
            from pygments.lexers.markup import TexLexer
            lxlexer = TexLexer(**self.options)
            codelines = 0
            latex = ''
            for match in line_re.finditer(text):
                line = match.group()
                if codelines:
                    if line.lstrip().startswith('\\end{code}'):
                        codelines = 0
                        latex += line
                    else:
                        code += line
                elif line.lstrip().startswith('\\begin{code}'):
                    codelines = 1
                    latex += line
                    insertions.append((len(code),
                                       list(lxlexer.get_tokens_unprocessed(latex))))
                    latex = ''
                else:
                    latex += line
            insertions.append((len(code),
                               list(lxlexer.get_tokens_unprocessed(latex))))
        for item in do_insertions(insertions, self.baselexer.get_tokens_unprocessed(code)):
            yield item

class LiterateHaskellLexer(LiterateLexer):
    """
    For Literate Haskell (Bird-style or LaTeX) source.

    Additional options accepted:

    `litstyle`
        If given, must be ``"bird"`` or ``"latex"``.  If not given, the style
        is autodetected: if the first non-whitespace character in the source
        is a backslash or percent character, LaTeX is assumed, else Bird.

    .. versionadded:: 0.9
    """
    name = 'Literate Haskell'
    aliases = ['lhs', 'literate-haskell', 'lhaskell']
    filenames = ['*.lhs']
    mimetypes = ['text/x-literate-haskell']

    def __init__(self, **options):
        hslexer = HaskellLexer(**options)
        LiterateLexer.__init__(self, hslexer, **options)

class LiterateIdrisLexer(LiterateLexer):
    """
    For Literate Idris (Bird-style or LaTeX) source.

    Additional options accepted:

    `litstyle`
        If given, must be ``"bird"`` or ``"latex"``.  If not given, the style
        is autodetected: if the first non-whitespace character in the source
        is a backslash or percent character, LaTeX is assumed, else Bird.

    .. versionadded:: 2.0
    """
    name = 'Literate Idris'
    aliases = ['lidr', 'literate-idris', 'lidris']
    filenames = ['*.lidr']
    mimetypes = ['text/x-literate-idris']

    def __init__(self, **options):
        hslexer = IdrisLexer(**options)
        LiterateLexer.__init__(self, hslexer, **options)

class LiterateAgdaLexer(LiterateLexer):
    """
    For Literate Agda source.

    Additional options accepted:

    `litstyle`
        If given, must be ``"bird"`` or ``"latex"``.  If not given, the style
        is autodetected: if the first non-whitespace character in the source
        is a backslash or percent character, LaTeX is assumed, else Bird.

    .. versionadded:: 2.0
    """
    name = 'Literate Agda'
    aliases = ['lagda', 'literate-agda']
    filenames = ['*.lagda']
    mimetypes = ['text/x-literate-agda']

    def __init__(self, **options):
        agdalexer = AgdaLexer(**options)
        LiterateLexer.__init__(self, agdalexer, litstyle='latex', **options)

class LiterateCryptolLexer(LiterateLexer):
    """
    For Literate Cryptol (Bird-style or LaTeX) source.

    Additional options accepted:

    `litstyle`
        If given, must be ``"bird"`` or ``"latex"``.  If not given, the style
        is autodetected: if the first non-whitespace character in the source
        is a backslash or percent character, LaTeX is assumed, else Bird.

    .. versionadded:: 2.0
    """
    name = 'Literate Cryptol'
    aliases = ['lcry', 'literate-cryptol', 'lcryptol']
    filenames = ['*.lcry']
    mimetypes = ['text/x-literate-cryptol']

    def __init__(self, **options):
        crylexer = CryptolLexer(**options)
        LiterateLexer.__init__(self, crylexer, **options)

class KokaLexer(RegexLexer):
    """
    Lexer for the `Koka <http://koka.codeplex.com>`_
    language.

    .. versionadded:: 1.6
    """

    name = 'Koka'
    aliases = ['koka']
    filenames = ['*.kk', '*.kki']
    mimetypes = ['text/x-koka']

    keywords = [
        'infix', 'infixr', 'infixl',
        'type', 'cotype', 'rectype', 'alias',
        'struct', 'con',
        'fun', 'function', 'val', 'var',
        'external',
        'if', 'then', 'else', 'elif', 'return', 'match',
        'private', 'public', 'private',
        'module', 'import', 'as',
        'include', 'inline',
        'rec',
        'try', 'yield', 'enum',
        'interface', 'instance',
    ]

    # keywords that are followed by a type
    typeStartKeywords = [
        'type', 'cotype', 'rectype', 'alias', 'struct', 'enum',
    ]

    # keywords valid in a type
    typekeywords = [
        'forall', 'exists', 'some', 'with',
    ]

    # builtin names and special names
    builtin = [
        'for', 'while', 'repeat',
        'foreach', 'foreach-indexed',
        'error', 'catch', 'finally',
        'cs', 'js', 'file', 'ref', 'assigned',
    ]

    # symbols that can be in an operator
    symbols = r'[$%&*+@!/\\^~=.:\-?|<>]+'

    # symbol boundary: an operator keyword should not be followed by any of these
    sboundary = '(?!'+symbols+')'

    # name boundary: a keyword should not be followed by any of these
    boundary = '(?![\w/])'

    # koka token abstractions
    tokenType = Name.Attribute
    tokenTypeDef = Name.Class
    tokenConstructor = Generic.Emph

    # main lexer
    tokens = {
        'root': [
            include('whitespace'),

            # go into type mode
            (r'::?' + sboundary, tokenType, 'type'),
            (r'(alias)(\s+)([a-z]\w*)?', bygroups(Keyword, Text, tokenTypeDef),
             'alias-type'),
            (r'(struct)(\s+)([a-z]\w*)?', bygroups(Keyword, Text, tokenTypeDef),
             'struct-type'),
            ((r'(%s)' % '|'.join(typeStartKeywords)) +
             r'(\s+)([a-z]\w*)?', bygroups(Keyword, Text, tokenTypeDef),
             'type'),

            # special sequences of tokens (we use ?: for non-capturing group as
            # required by 'bygroups')
            (r'(module)(\s+)(interface\s+)?((?:[a-z]\w*/)*[a-z]\w*)',
             bygroups(Keyword, Text, Keyword, Name.Namespace)),
            (r'(import)(\s+)((?:[a-z]\w*/)*[a-z]\w*)'
             r'(?:(\s*)(=)(\s*)((?:qualified\s*)?)'
             r'((?:[a-z]\w*/)*[a-z]\w*))?',
             bygroups(Keyword, Text, Name.Namespace, Text, Keyword, Text,
                      Keyword, Name.Namespace)),

            (r'(^(?:(?:public|private)\s*)?(?:function|fun|val))'
             r'(\s+)([a-z]\w*|\((?:' + symbols + r'|/)\))',
             bygroups(Keyword, Text, Name.Function)),
            (r'(^(?:(?:public|private)\s*)?external)(\s+)(inline\s+)?'
             r'([a-z]\w*|\((?:' + symbols + r'|/)\))',
             bygroups(Keyword, Text, Keyword, Name.Function)),

            # keywords
            (r'(%s)' % '|'.join(typekeywords) + boundary, Keyword.Type),
            (r'(%s)' % '|'.join(keywords) + boundary, Keyword),
            (r'(%s)' % '|'.join(builtin) + boundary, Keyword.Pseudo),
            (r'::?|:=|\->|[=.]' + sboundary, Keyword),

            # names
            (r'((?:[a-z]\w*/)*)([A-Z]\w*)',
             bygroups(Name.Namespace, tokenConstructor)),
            (r'((?:[a-z]\w*/)*)([a-z]\w*)', bygroups(Name.Namespace, Name)),
            (r'((?:[a-z]\w*/)*)(\((?:' + symbols + r'|/)\))',
             bygroups(Name.Namespace, Name)),
            (r'_\w*', Name.Variable),

            # literal string
            (r'@"', String.Double, 'litstring'),

            # operators
            (symbols + "|/(?![*/])", Operator),
            (r'`', Operator),
            (r'[{}()\[\];,]', Punctuation),

            # literals. No check for literal characters with len > 1
            (r'[0-9]+\.[0-9]+([eE][\-+]?[0-9]+)?', Number.Float),
            (r'0[xX][0-9a-fA-F]+', Number.Hex),
            (r'[0-9]+', Number.Integer),

            (r"'", String.Char, 'char'),
            (r'"', String.Double, 'string'),
        ],

        # type started by alias
        'alias-type': [
            (r'=', Keyword),
            include('type')
        ],

        # type started by struct
        'struct-type': [
            (r'(?=\((?!,*\)))', Punctuation, '#pop'),
            include('type')
        ],

        # type started by colon
        'type': [
            (r'[(\[<]', tokenType, 'type-nested'),
            include('type-content')
        ],

        # type nested in brackets: can contain parameters, comma etc.
        'type-nested': [
            (r'[)\]>]', tokenType, '#pop'),
            (r'[(\[<]', tokenType, 'type-nested'),
            (r',', tokenType),
            (r'([a-z]\w*)(\s*)(:)(?!:)',
             bygroups(Name, Text, tokenType)),  # parameter name
            include('type-content')
        ],

        # shared contents of a type
        'type-content': [
            include('whitespace'),

            # keywords
            (r'(%s)' % '|'.join(typekeywords) + boundary, Keyword),
            (r'(?=((%s)' % '|'.join(keywords) + boundary + '))',
             Keyword, '#pop'),  # need to match because names overlap...

            # kinds
            (r'[EPHVX]' + boundary, tokenType),

            # type names
            (r'[a-z][0-9]*(?![\w/])', tokenType),
            (r'_\w*', tokenType.Variable),  # Generic.Emph
            (r'((?:[a-z]\w*/)*)([A-Z]\w*)',
             bygroups(Name.Namespace, tokenType)),
            (r'((?:[a-z]\w*/)*)([a-z]\w+)',
             bygroups(Name.Namespace, tokenType)),

            # type keyword operators
            (r'::|->|[.:|]', tokenType),

            # catchall
            default('#pop')
        ],

        # comments and literals
        'whitespace': [
            (r'\n\s*#.*$', Comment.Preproc),
            (r'\s+', Text),
            (r'/\*', Comment.Multiline, 'comment'),
            (r'//.*$', Comment.Single)
        ],
        'comment': [
            (r'[^/*]+', Comment.Multiline),
            (r'/\*', Comment.Multiline, '#push'),
            (r'\*/', Comment.Multiline, '#pop'),
            (r'[*/]', Comment.Multiline),
        ],
        'litstring': [
            (r'[^"]+', String.Double),
            (r'""', String.Escape),
            (r'"', String.Double, '#pop'),
        ],
        'string': [
            (r'[^\\"\n]+', String.Double),
            include('escape-sequence'),
            (r'["\n]', String.Double, '#pop'),
        ],
        'char': [
            (r'[^\\\'\n]+', String.Char),
            include('escape-sequence'),
            (r'[\'\n]', String.Char, '#pop'),
        ],
        'escape-sequence': [
            (r'\\[nrt\\"\']', String.Escape),
            (r'\\x[0-9a-fA-F]{2}', String.Escape),
            (r'\\u[0-9a-fA-F]{4}', String.Escape),
            # Yes, \U literals are 6 hex digits.
            (r'\\U[0-9a-fA-F]{6}', String.Escape)
        ]
    }

{'repo_name': 'tmm1/pygments.rb', 'stars': '537', 'repo_language': 'C', 'file_name': 'test_pygments.rb', 'mime_type': 'text/x-ruby', 'hash': -1051845331479436944, 'source_dataset': 'data'}


import * as React from 'react';
import TextareaAutosize from '@material-ui/core/TextareaAutosize';

export default function MaxHeightTextarea() {
  return (
    <TextareaAutosize
      maxRows={4}
      aria-label="maximum height"
      placeholder="Maximum 4 rows"
      defaultValue="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
          ut labore et dolore magna aliqua."
    />
  );
}

{'repo_name': 'mui-org/material-ui', 'stars': '59328', 'repo_language': 'JavaScript', 'file_name': 'config.yml', 'mime_type': 'text/plain', 'hash': 3731872743792380535, 'source_dataset': 'data'}


module.exports = {
  layer: {
    'non-valid-source': {
      messageRegex: /nonValidSource/,
      friendlyMessage: 'The given object is not a valid source. See "carto.source.Base".'
    },
    'non-valid-style': {
      messageRegex: /nonValidStyle/,
      friendlyMessage: 'The given object is not a valid style. See "carto.style.Base".'
    },
    'non-valid-columns': {
      messageRegex: /nonValidColumns/,
      friendlyMessage: 'The given object is not a valid array of string columns.'
    },
    'source-with-different-client': {
      messageRegex: /differentSourceClient/,
      friendlyMessage: "A layer can't have a source which belongs to a different client."
    },
    'style-with-different-client': {
      messageRegex: /differentStyleClient/,
      friendlyMessage: "A layer can't have a style which belongs to a different client."
    },
    'wrong-interactivity-columns': {
      messageRegex: /wrongInteractivityColumns\[(.+)\]#(.+)$/,
      friendlyMessage: 'Columns [$0] set on `$1` do not match the columns set in aggregation options.'
    }
  },
  source: {
    'query-required': {
      messageRegex: /requiredQuery/,
      friendlyMessage: 'SQL Source must have a SQL query.'
    },
    'query-string': {
      messageRegex: /requiredString/,
      friendlyMessage: 'SQL Query must be a string.'
    },
    'no-dataset-name': {
      messageRegex: /noDatasetName/,
      friendlyMessage: 'Table name is required.'
    },
    'dataset-string': {
      messageRegex: /requiredDatasetString$/,
      friendlyMessage: 'Table name must be a string.'
    },
    'dataset-required': {
      messageRegex: /requiredDataset$/,
      friendlyMessage: 'Table name must be not empty.'
    }
  },
  style: {
    'required-css': {
      messageRegex: /requiredCSS$/,
      friendlyMessage: 'CartoCSS is required.'
    },
    'css-string': {
      messageRegex: /requiredCSSString$/,
      friendlyMessage: 'CartoCSS must be a string.'
    }
  },
  client: {
    'bad-layer-type': {
      messageRegex: /badLayerType/,
      friendlyMessage: 'The given object is not a layer.'
    },
    'index-number': {
      messageRegex: /indexNumber/,
      friendlyMessage: 'index property must be a number.'
    },
    'index-out-of-range': {
      messageRegex: /indexOutOfRange/,
      friendlyMessage: 'index is out of range.'
    },
    'api-key-required': {
      messageRegex: /apiKeyRequired/,
      friendlyMessage: 'apiKey property is required.'
    },
    'api-key-string': {
      messageRegex: /apiKeyString/,
      friendlyMessage: 'apiKey property must be a string.'
    },
    'username-required': {
      messageRegex: /usernameRequired/,
      friendlyMessage: 'username property is required.'
    },
    'username-string': {
      messageRegex: /usernameString/,
      friendlyMessage: 'username property must be a string.'
    },
    'non-valid-server-url': {
      messageRegex: /nonValidServerURL/,
      friendlyMessage: 'serverUrl is not a valid URL.'
    },
    'non-matching-server-url': {
      messageRegex: /serverURLDoesntMatchUsername/,
      friendlyMessage: "serverUrl doesn't match the username."
    },
    'duplicated-layer-id': {
      messageRegex: /duplicatedLayerId/,
      friendlyMessage: 'A layer with the same ID already exists in the client.'
    }
  },
  dataview: {
    'source-required': {
      messageRegex: /sourceRequired/,
      friendlyMessage: 'Source property is required.'
    },
    'column-required': {
      messageRegex: /columnRequired/,
      friendlyMessage: 'Column property is required.'
    },
    'column-string': {
      messageRegex: /columnString/,
      friendlyMessage: 'Column property must be a string.'
    },
    'empty-column': {
      messageRegex: /emptyColumn/,
      friendlyMessage: 'Column property must be not empty.'
    },
    'filter-required': {
      messageRegex: /filterRequired/,
      friendlyMessage: 'Filter property is required.'
    },
    'time-series-options-required': {
      messageRegex: /timeSeriesOptionsRequired/,
      friendlyMessage: 'Options object to create a time series dataview is required.'
    },
    'time-series-invalid-aggregation': {
      messageRegex: /timeSeriesInvalidAggregation/,
      friendlyMessage: 'Time aggregation must be a valid value. Use carto.dataview.timeAggregation.'
    },
    'time-series-invalid-offset': {
      messageRegex: /timeSeriesInvalidOffset/,
      friendlyMessage: 'Offset must an integer value between -12 and 14.'
    },
    'time-series-invalid-uselocaltimezone': {
      messageRegex: /timeSeriesInvalidUselocaltimezone/,
      friendlyMessage: 'useLocalTimezone must be a boolean value.'
    },
    'histogram-options-required': {
      messageRegex: /histogramOptionsRequired/,
      friendlyMessage: 'Options object to create a histogram dataview is required.'
    },
    'histogram-invalid-bins': {
      messageRegex: /histogramInvalidBins/,
      friendlyMessage: 'Bins must be a positive integer value.'
    },
    'histogram-invalid-start-end': {
      messageRegex: /histogramInvalidStartEnd/,
      friendlyMessage: 'Both start and end values must be a number or null.'
    },
    'formula-options-required': {
      messageRegex: /formulaOptionsRequired/,
      friendlyMessage: 'Formula dataview options are not defined.'
    },
    'formula-invalid-operation': {
      messageRegex: /formulaInvalidOperation/,
      friendlyMessage: 'Operation for formula dataview is not valid. Use carto.operation'
    },
    'category-options-required': {
      messageRegex: /categoryOptionsRequired/,
      friendlyMessage: 'Category dataview options are not defined.'
    },
    'category-limit-required': {
      messageRegex: /categoryLimitRequired/,
      friendlyMessage: 'Limit for category dataview is required.'
    },
    'category-limit-number': {
      messageRegex: /categoryLimitNumber/,
      friendlyMessage: 'Limit for category dataview must be a number.'
    },
    'category-limit-positive': {
      messageRegex: /categoryLimitPositive/,
      friendlyMessage: 'Limit for category dataview must be greater than 0.'
    },
    'category-invalid-operation': {
      messageRegex: /categoryInvalidOperation/,
      friendlyMessage: 'Operation for category dataview is not valid. Use carto.operation'
    },
    'category-operation-required': {
      messageRegex: /categoryOperationRequired/,
      friendlyMessage: 'Operation column for category dataview is required.'
    },
    'category-operation-string': {
      messageRegex: /categoryOperationString/,
      friendlyMessage: 'Operation column for category dataview must be a string.'
    },
    'category-operation-empty': {
      messageRegex: /categoryOperationEmpty/,
      friendlyMessage: 'Operation column for category dataview must be not empty.'
    }
  },
  filter: {
    'invalid-bounds-object': {
      messageRegex: /invalidBoundsObject/,
      friendlyMessage: 'Bounds object is not valid. Use a carto.filter.Bounds object'
    },
    'invalid-circle-object': {
      messageRegex: /invalidCircleObject/,
      friendlyMessage: 'Circle object is not valid. Use a carto.filter.CircleData object'
    },
    'invalid-polygon-object': {
      messageRegex: /invalidPolygonObject/,
      friendlyMessage: 'Polygon object is not valid. Use a carto.filter.PolygonData object'
    },
    'column-required': {
      messageRegex: /columnRequired/,
      friendlyMessage: 'Column property is required.'
    },
    'column-string': {
      messageRegex: /columnString/,
      friendlyMessage: 'Column property must be a string.'
    },
    'empty-column': {
      messageRegex: /emptyColumn/,
      friendlyMessage: 'Column property must be not empty.'
    },
    'invalid-filter': {
      messageRegex: /invalidFilter(.+)/,
      friendlyMessage: "'$0' is not a valid filter. Please check documentation."
    },
    'invalid-option': {
      messageRegex: /invalidOption(.+)/,
      friendlyMessage: "'$0' is not a valid option for this filter."
    },
    'wrong-filter-type': {
      messageRegex: /wrongFilterType/,
      friendlyMessage: 'Filters need to extend from carto.filter.SQLBase. Please use carto.filter.Category or carto.filter.Range.'
    },
    'invalid-parameter-type': {
      messageRegex: /invalidParameterType(.+)/,
      friendlyMessage: "Invalid parameter type for '$0'. Please check filters documentation."
    }
  },
  aggregation: {
    'threshold-required': {
      messageRegex: /thresholdRequired/,
      friendlyMessage: 'Aggregation threshold is required.'
    },
    'invalid-threshold': {
      messageRegex: /invalidThreshold/,
      friendlyMessage: 'Aggregation threshold must be an integer value greater than 0.'
    },
    'resolution-required': {
      messageRegex: /resolutionRequired/,
      friendlyMessage: 'Aggregation resolution is required.'
    },
    'invalid-resolution': {
      messageRegex: /invalidResolution/,
      friendlyMessage: 'Aggregation resolution must be 0.5, 1 or powers of 2 up to 256 (2, 4, 8, 16, 32, 64, 128, 256).'
    },
    'invalid-placement': {
      messageRegex: /invalidPlacement/,
      friendlyMessage: 'Aggregation placement is not valid. Must be one of these values: `point-sample`, `point-grid`, `centroid`'
    },
    'column-function-required': {
      messageRegex: /columnFunctionRequired(.+)$/,
      friendlyMessage: "Aggregation function for column '$0' is required."
    },
    'invalid-column-function': {
      messageRegex: /invalidColumnFunction(.+)$/,
      friendlyMessage: "Aggregation function for column '$0' is not valid. Use carto.aggregation.function"
    },
    'column-aggregated-column-required': {
      messageRegex: /columnAggregatedColumnRequired(.+)$/,
      friendlyMessage: "Column to be aggregated to '$0' is required."
    },
    'invalid-column-aggregated-column': {
      messageRegex: /invalidColumnAggregatedColumn(.+)$/,
      friendlyMessage: "Column to be aggregated to '$0' must be a string."
    }
  }
};

{'repo_name': 'CartoDB/carto.js', 'stars': '406', 'repo_language': 'JavaScript', 'file_name': 'clean.js', 'mime_type': 'text/plain', 'hash': -6649654824158998767, 'source_dataset': 'data'}


for(var i = 0; i < 10; i++) {
    viewer.addLabel("Hello "+i,{position:{x:i,y:0,z:i}, backgroundColor: 'orange',frame:i});
}

viewer.animate({loop:"forward",reps:1});
viewer.render();

{'repo_name': '3dmol/3Dmol.js', 'stars': '393', 'repo_language': 'Jupyter Notebook', 'file_name': 'org.eclipse.core.resources.prefs', 'mime_type': 'text/plain', 'hash': 4125406586204417335, 'source_dataset': 'data'}


-- fibonacci function with cache

-- very inefficient fibonacci function
function fib(n)
	N=N+1
	if n<2 then
		return n
	else
		return fib(n-1)+fib(n-2)
	end
end

-- a general-purpose value cache
function cache(f)
	local c={}
	return function (x)
		local y=c[x]
		if not y then
			y=f(x)
			c[x]=y
		end
		return y
	end
end

cached_fib = cache(fib)

N=0
assert(fib(24) == 46368)

N=0
assert(cached_fib(24) == 46368)

{'repo_name': 'mherkender/lua.js', 'stars': '516', 'repo_language': 'JavaScript', 'file_name': 'cf.lua', 'mime_type': 'text/plain', 'hash': 7669452434597183214, 'source_dataset': 'data'}


0. Array: default
1,2,,3

1. Array: Replaced Array.prototype.join
replaced Array.prototype.join

2. Array: Replaced non-callable Array.prototype.join
[object Array]

3. Object: no join
[object Object]

4. Object: has join
o join

5. Object: non-callable join
[object Object]

6. Object: no join with toStringTag
[object Replaced @@toStringTag]

7. Object: no join with getter toStringTag
[object Replaced @@toStringTag with a getter]

8. Object: no join, replaced Object.prototype.toString
[object Object]

{'repo_name': 'microsoft/ChakraCore', 'stars': '8232', 'repo_language': 'JavaScript', 'file_name': 'get_system_info.sh', 'mime_type': 'text/plain', 'hash': 7303262864593449956, 'source_dataset': 'data'}