text:
// Utils
// ConsCell data structure (actually a linked list).
// http://en.wikipedia.org/wiki/Cons
// here it uses a doubly-linked list to increase the traversal efficiency
/**
 * @constructor
 * @param {} x
 */
function ConsCell(x) {
  this._car = x; // a value, undefined, or another ConsCell
  this._cdr = null;
  this._prev = null;
};

/**
 *
 * @param {} n - a value, or another ConsCell (nested list)
 */
ConsCell.prototype.setCar = function(n) {
  this._car = n;
};

/**
 *
 * @param {} n - a ConsCell, or a value (dotted pair: `(1 . 2)`)
 */
ConsCell.prototype.setCdr = function(n) {
  this._cdr = n;

  if (n instanceof ConsCell) {
    n._prev = this;
  }
};

var __null__ = "__null__";

/**
 *
 * @returns {} - a value or a ConsCell
 */
ConsCell.prototype.getCar = function() {
  return this._car;
};

/**
 *
 * @returns {} - a ConsCell or a value
 */
ConsCell.prototype.getCdr = function() {
  return this._cdr;
};

// and a bunch of shortcuts...
ConsCell.prototype.getCaar = function() {
  return this.getCar().getCar();
};

ConsCell.prototype.getCadr = function() {
  return this.getCdr().getCar();
};

ConsCell.prototype.getCdar = function() {
  return this.getCar().getCdr();
};

ConsCell.prototype.getCddr = function() {
  return this.getCdr().getCdr();
};

ConsCell.prototype.getCaaar = function() {
  return this.getCar().getCar().getCar();
};

ConsCell.prototype.getCaadr = function() {
  return this.getCdr().getCar().getCar();
};

ConsCell.prototype.getCadar = function() {
  return this.getCar().getCdr().getCar();
};

ConsCell.prototype.getCaddr = function() {
  return this.getCdr().getCdr().getCar();
};

ConsCell.prototype.getCdaar = function() {
  return this.getCar().getCar().getCdr();
};

ConsCell.prototype.getCdadr = function() {
  return this.getCdr().getCar().getCdr();
};

ConsCell.prototype.getCddar = function() {
  return this.getCar().getCdr().getCdr();
};

ConsCell.prototype.getCdddr = function() {
  return this.getCdr().getCdr().getCdr();
};

/**
 *
 * @returns {[]} - an array of Scheme exps
 */
ConsCell.prototype.toArray = function() {
  var result = [];
  var current = this;

  while (current && current !== __null__) {
    result.push(current.getCar());
    current = current.getCdr();
  }

  return result;
};

/**
 * `_.map`'s ConsCell version.
 * @param {ConsCell} x
 * @param {} f
 */
function mapConsCell(x, f) {
  if (x === __null__) {
    return __null__;
  }

  var result = new ConsCell();

  result.setCar(f(x.getCar()));
  result.setCdr(mapConsCell(x.getCdr(), f));

  return result;
}

/**
 * Contract Violation Exception (a.k.a. type error): e.g. (+ 3 'f)
 * @param {} f
 * @param {} expected
 * @param {} given
 * @returns {}
 */
function ContractViolationException(f, expected, given) {
  this.f = f;
  this.expected = expected;
  this.given = given;
  this.toString = function() {
    return this.f + ": Contract Violation\n"
      + "\texpected: " + this.expected + "\n"
      + "\tgiven: " + this.given + "\n";
  };
}

/**
 * unbound identifier
 * @param {string} v - a Scheme variable name
 * @returns {string} - error message
 */
function UnboundedException(v) {
  this.v = v;
  this.toString = function() {
    return this.v + ": undefined;\n"
      + "  cannot reference an identifier before its definition\n";
  };
}

/**
 *
 * @param {} inp - a ConsCell or a value
 * @returns {string} - the expression as a string
 */
function writer(inp) {
  // TODO: convert quotes back to "'", ",", and "`"
  var n = inp;
  var result = "";

  var quoteDict = {
    "quasiquote": "`",
    "unquote": ",",
    "quote": "'"
  };

  if (!(n instanceof ConsCell)) {
    if (n === __null__) {
      result += "()";
    }
    else {
      if (n === true) {
        result += "#t";
      }
      else if (n === false) {
        result += "#f";
      }
      else {
        result += n;
      }
    }

    return result;
  }

  result += "(";

  while (n) {
    result += writer(n._car);

    if (n._cdr === __null__) {
      break;
    }
    else if (!(n._cdr instanceof ConsCell)) {
      result += " . " + writer(n._cdr);
      break;
    }
    else {
      result += " ";
      n = n._cdr;
    }
  }

  result += ")";

  return result;
}

// Scheme Implementation

/**
 * A linear tokenizer.
 * @param {string} rawExp - e.g. "(lambda (x) x)"
 * @returns {[string]} - e.g. ["(", "lambda", "(", "x", ")", "x", ")"]
 */
function tokenize(rawExp) {
  var topDelimiters = ["\""];
  var delimiters = ["(", ")", "[", "]", ",", "'", "`"];

  var tokenResult = [];

  var tempString = "";
  var inStream = false;
  var inStringStream = false;
  var inCommentStream = false;

  for (var i = 0; i < rawExp.length; i++) {
    var currentChar = rawExp[i];

    if (!inStringStream && currentChar === ";") {
      // special case: inStringStream
      inCommentStream = true;
    }
    else if (inCommentStream) {
      if (currentChar === "\n") {
        inCommentStream = false;
      }
      // else: do nothing -- throw them away
    }
    else if (_.contains(topDelimiters, currentChar) && (rawExp[i-1] !== '\\')) {
      // found a `"`, and not an escaped one
      tempString += currentChar;
      inStringStream = !inStringStream;

      if (!inStringStream && tempString.length !== 0) {
        // not the first one: time to push the string
        tokenResult.push(tempString);
        tempString = "";
      }
    }
    else if (inStringStream) {
      // append currentChar to tempString
      tempString += currentChar;
    }
    else {
      if (currentChar === " " || currentChar === "\n") {
        // finds a divider
        if (inStream && tempString.length !== 0) {
          tokenResult.push(tempString);
          tempString = "";

          inStream = false;
        }
        // else: ignore it
      }
      else if (_.contains(delimiters, currentChar)) {
        // finds a delimiter
        if (inStream && tempString.length !== 0) {
          tokenResult.push(tempString);
          tempString = "";

          inStream = false;
        }

        tokenResult.push(currentChar); // pushes the delimiter
      }
      else {
        // just a normal character
        tempString += currentChar;
        inStream = true;

        if (i === rawExp.length - 1) {
          tokenResult.push(tempString);
          tempString = "";

          inStream = false;
        }
      }
    }
  }
  return tokenResult;
}

/**
 *
 * @param {[string]} tokens
 * @returns {}
 */
function parse(tokens) {

  function tryTypeconversion(rawToken) {
    // #t, #f, numbers
    if (rawToken === "#t") {
      return true;
    }
    else if (rawToken === "#f") {
      return false;
    }
    else {
      var maybeNum = parseFloat(rawToken);
      if (!isNaN(maybeNum)) {
        return maybeNum;
      }
    }

    return rawToken;
  }

  function fixDotPair(n) {
    if (!(n instanceof ConsCell)) {
      return;
    }

    while (n) {
      if (n._car instanceof ConsCell) {
        fixDotPair(n._car);
      }
      else if (n._car === ".") {
        n._prev._cdr = n._cdr._car;
      }

      if (n._cdr === __null__) {
        break;
      }
      else {
        n = n._cdr;
      }
    }
  }

  function fixQuotes(n) {
    var quoteDict = {
      "`": "quasiquote",
      ",": "unquote",
      "'": "quote"
    };

    if (!(n instanceof ConsCell)) {
      return;
    }

    while (n) {
      if (n._car instanceof ConsCell) {
        fixQuotes(n._car);
      }

      if (n._car in quoteDict) {
        var q = n._car;

        // fix the most inner stuff first
        fixQuotes(n._cdr);

        n.setCar(new ConsCell());
        n._car.setCar(quoteDict[q]);
        n._car.setCdr(new ConsCell());
        n._car._cdr.setCar(n._cdr._car);
        // anything else? nope.
        n._car._cdr.setCdr(__null__);
        n.setCdr(n._cdr._cdr);

      }

      if (n._cdr === __null__) {
        break;
      }
      else {
        n = n._cdr;
      }
    }
  }

  var result = new ConsCell();
  var processing = result;
  var stack = [];

  for (var i = 0; i < tokens.length; i++) {
    var currentToken = tokens[i];

    if ((currentToken === '(' && tokens[i+1] === ')')
        || (currentToken === '[' && tokens[i+1] === ']')) {
      // case: ()
      // car := null
      processing.setCar(__null__);
      processing.setCdr(new ConsCell());
      processing = processing._cdr;
      i++;
    }
    else if (currentToken === '(' || currentToken === '[') {
      // case: start of a new list
      processing.setCar(new ConsCell());
      processing.setCdr(new ConsCell());
      stack.push(processing._cdr); // pushes the cdr to the stack
      processing = processing._car;
    }
    else if (currentToken === ')' || currentToken === ']') {
      // one step back
      processing._prev.setCdr(__null__);
      processing = stack.pop(); // jumps back yo
    }
    else {
      processing.setCar(tryTypeconversion(currentToken));
      processing.setCdr(new ConsCell());
      processing = processing._cdr;
    }

  }

  fixQuotes(result);
  fixDotPair(result);

  return result._car;
}

/**
 * an environment for current variable bindings
 * @constructor
 * @param {[string]} keysList - a list of Scheme variable names (symbols in Scheme)
 * @param {[]} valuesList - a list of corresponding values
 * @param {Env} outerEnv - lexical scope yo
 */
function Env(keysList, valuesList, outerEnv) {
  this._outer = outerEnv;
  this._data = {}; // mapping
  this._order = []; // keeps the order

  // init
  if (keysList !== undefined && valuesList !== undefined) {
    this.updateAll(keysList, valuesList);
  }
}

/**
 *
 * @param {string} key - a single Scheme variable name
 * @param {} value - a single value
 */
Env.prototype.update = function(key, value) {
  this._data[key] = {}; // a dict
  this._data[key]._val = value; // changes, or adds a value

  if (_.contains(this._order, key)) {
    this._order = _.without(this._order, key);
  }

  this._order.push(key); // keep recently updated values at the top
};

/**
 *
 * @param {[string]} keys - a list of Scheme variable names
 * @param {} values - a list of values
 */
Env.prototype.updateAll = function(keys, values) {
  for (var i = 0; i < keys.length; i++) {
    this.update(keys[i], values[i]);
  }
};

/**
 *
 * @param {string} key - a Scheme variable name
 * @returns {} - the corresponding value
 * @throws {UnboundedException} - variable not bound
 */
Env.prototype.lookupVal = function(key) {
  if (this._data[key] !== undefined) {
    return this._data[key]._val;
  }
  else if (!(this._outer)) {
    throw new UnboundedException(key);
  }
  else {
    return this._outer.lookupVal(key);
  }
};

/**
 *
 * @returns {[string]} - a list of Scheme variable names
 */
Env.prototype.listVars = function() {
  return this._order;
};

/**
 * add primitives to an Env.
 * @param {Env} targetEnv
 */
function addGlobals(targetEnv) {
  this.globalFuncList = {
    // TODO: human-readable error messages, especially on type checking, and argument numbers
    // TODO: better (original) eqv? and eq? -- do env lookup?
    // http://stackoverflow.com/questions/16299246/what-is-the-difference-between-eq-eqv-equal-and-in-scheme
    "+": function (args) {
      return _.foldl(args.toArray(), function (x, y) {
        return x + y;
      });
    },
    "-": function (args) {
      return _.foldl(args.toArray(), function (x, y) {
        return x - y;
      });
    },
    "*": function (args) {
      return _.foldl(args.toArray(), function (x, y) {
        return x * y;
      });
    },
    "/": function (args) {
      return _.foldl(args.toArray(), function (x, y) {
        return x / y;
      });
    },
    "sub1": function (args) {
      return args.getCar() - 1;
    },
    "add1": function (args) {
      return args.getCar() + 1;
    },
    "zero?": function (args) {
      return args.getCar() === 0;
    },
    "=": function (args) {
      return _.every(args.toArray(), function(x) {
        return x === args.toArray()[0];
      });
    },
    ">": function (args) {
      var args = args.toArray();
      for (var i = 0; i < args.length - 1; i++) {
        if (args[i] <= args[i+1]) {
          return false;
        }
      }
      return true;
    },
    "<": function (args) {
      var args = args.toArray();
      for (var i = 0; i < args.length - 1; i++) {
        if (args[i] >= args[i+1]) {
          return false;
        }
      }
      return true;
    },
    ">=": function (args) {
      var args = args.toArray();
      for (var i = 0; i < args.length - 1; i++) {
        if (args[i] < args[i+1]) {
          return false;
        }
      }
      return true;
    },
    "<=": function (args) {
      var args = args.toArray();
      for (var i = 0; i < args.length - 1; i++) {
        if (args[i] > args[i+1]) {
          return false;
        }
      }
      return true;
    },
    "not": function (args) {
      return !args.getCar();
    },
    "car": function (args) {
      return args.getCaar();
    },
    "cdr": function (args) {
      return args.getCdar();
    },
    "cons": function (args) {
      var a = new ConsCell(args.getCar());
      a.setCdr(args.getCadr());

      return a;
    },
    "length": function (args) {
      var result = 0;

      var current = args.getCar();

      while (current && current !== __null__) {
        result++;
        current = current.getCdr();
      }

      return result;
    },
    "append": function (args) {
      // TODO: foldl version to handle > 2 arguments
      var a = args.getCar();

      if (a === __null__) {
        return args.getCadr();

      }
      else {
        a.setCdr(args.getCadr());
        return a;
      }
    },
    "list": function (args) {
      return args;
    },
    "equal?": function (args) {
      var x = args.getCar();
      var y = args.getCadr();

      function deepEqual(x, y) {
        if (!(x instanceof ConsCell) && !(y instanceof ConsCell)) {
          return x == y;
        }
        else if ((x instanceof ConsCell) && (y instanceof ConsCell)){
          return deepEqual(x.getCar(), y.getCar()) && deepEqual(x.getCdr(), y.getCdr());
        }
        else {
          return false;
        }
      };

      return deepEqual(x, y);
    },
    "eqv?": function (args) {
      var x = args.getCar();
      var y = args.getCadr();

      function deepEqual(x, y) {
        if (!(x instanceof ConsCell) && !(y instanceof ConsCell)) {
          return x == y;
        }
        else if ((x instanceof ConsCell) && (y instanceof ConsCell)){
          return deepEqual(x.getCar(), y.getCar()) && deepEqual(x.getCdr(), y.getCdr());
        }
        else {
          return false;
        }
      };

      return deepEqual(x, y);
    },
    "eq?": function (args) {
      var x = args.getCar();
      var y = args.getCadr();

      function deepEqual(x, y) {
        if (!(x instanceof ConsCell) && !(y instanceof ConsCell)) {
          return x == y;
        }
        else if ((x instanceof ConsCell) && (y instanceof ConsCell)){
          return deepEqual(x.getCar(), y.getCar()) && deepEqual(x.getCdr(), y.getCdr());
        }
        else {
          return false;
        }
      };

      return deepEqual(x, y);
    },
    "pair?": function (args) {
      return args instanceof ConsCell;
    },
    "list?": function (args) {
      var current = args.getCar();

      while (current && current !== __null__) {
        if (!(current.getCdr() instanceof ConsCell) && !(current.getCdr() === __null__)) {
          return false;
        }

        current = current.getCdr();
      }

      return true;
    },
    "null?": function (args) {
      return args.getCar() === __null__ && args.getCdr() === __null__;
    },
    "symbol?": function (args) {
      return (typeof args.getCar()) === "string" && args.getCar()[0] !== "\"";
    },
    "boolean?": function (args) {
      return (typeof args.getCar()) === "boolean";
    }
  };

  for (var key in this.globalFuncList) {
    targetEnv.update(key, this.globalFuncList[key]);
  }
}

var initialEnv = new Env();
addGlobals(initialEnv);

/**
 * the Scheme `eval` function.
 * @param {} exp
 * @param {} env
 * @returns {}
 */
function evaly(exp, env) {
  if (env === undefined) {
    env = initialEnv;
  }

  var newExps, proc, current;

  while (true) {
    if ((typeof exp) === "number") { // number
      return exp;
    }
    else if ((typeof exp) === "boolean") { // bool
      return exp;
    }
    else if ((typeof exp) === "string" && exp[0] === "\"") { // string, really a string
      return exp;
    }
    else if ((typeof exp) === "string") { // a var
      return env.lookupVal(exp);
    }
    else if (exp.getCar() === "quote") { // '(something)
      return exp.getCadr(); // something
    }
    else if (exp.getCar() === "if") {
      // var testExp = exp.getCadr();
      // var thenExp = exp.getCaddr();
      // var elseExp = exp.getCdr().getCdr().getCdr().getCar(); // cadddr...

      if (evaly(exp.getCadr(), env)) {
        exp = exp.getCaddr();
      }
      else {
        exp = exp.getCdr().getCdr().getCdr().getCar(); // cadddr...
      }
    }
    else if (exp.getCar() === "define") {
      // var targetVar = exp.getCadr();
      // var valueExp = exp.getCaddr();

      env.update(exp.getCadr(), evaly(exp.getCaddr(), env));
      return null;
    }
    else if (exp.getCar() === "set!") {
      // TODO: check whether the variable exists first.
      // var targetVar = exp.getCadr();
      // var valueExp = exp.getCaddr();

      env.update(exp.getCadr(), evaly(exp.getCaddr(), env));
      return null;

    }
    else if (exp.getCar() === "lambda") {
      // var xs = exp.getCadr();
      // var body = exp.getCaddr();

      return function(args) {
        return evaly(exp.getCaddr(),
                     new Env(exp.getCadr().toArray(), args.toArray(), env));
      };
    }
    else if (exp.getCar() === "begin") {
      current = exp.getCdr();
      if (current === __null__) { // `(begin)` case
        return null;
      }
      while (current.getCdr() !== __null__) {
        evaly(current.getCar());
        current = current.getCdr();
      }

      exp = current.getCar();

    }
    else { // (rator rand), a.k.a. apply
      newExps = mapConsCell(exp, function(e) {
        return evaly(e, env);
      });

      proc = newExps.getCar();

      return proc(newExps.getCdr());
    }
  }
}

document.addEventListener("DOMContentLoaded", function(event) {
  editor.setValue("(define Y\n  ((lambda (y) (lambda (f) (f (lambda (x) (((y y) f) x)))))\n   (lambda (y) (lambda (f) (f (lambda (x) (((y y) f) x)))))))\n\n(define fact\n  (lambda (imp)\n    (lambda (n)\n      (if (< n 2)\n          n\n          (* n (imp (sub1 n)))))))\n\n((Y fact) 5)");
});

function runNow() {
  var originalInput = "(begin " + editor.getValue() + " )";
  function parseAndEval(inp) {
    return evaly(parse(tokenize(inp)));
  }

  var outputDiv = document.getElementById("output");
  var resultP = document.createElement("p");

  var evalResult = writer(parseAndEval(originalInput));

  // TODO: should filter it in the writer function. however, the reason that it's still here is for easier debugging/development.
  if (evalResult !== "null" && evalResult.indexOf("function (args) {") !== 0) {
    resultP.innerHTML = "λ> " + evalResult;
    outputDiv.appendChild(resultP);
  }

}

function resetAll() {
  editor.setValue("");
  initialEnv = new Env();
  addGlobals(initialEnv);

  var outputDiv = document.getElementById("output");
  outputDiv.innerHTML = "";
}


text:
> Please post feedback to the [observatory-discuss group][discuss-list]

This document describes of _version 2.0_ of the Dart VM Service Protocol. This
protocol is used to communicate with a running Dart Virtual Machine.

To use the Service Protocol, start the VM with the *--observe* flag.
The VM will start a webserver which services protocol requests via WebSocket.
It is possible to make HTTP (non-WebSocket) requests,
but this does not allow access to VM _events_ and is not documented
here.

The Service Protocol uses [JSON-RPC 2.0][].

[JSON-RPC 2.0]: http://www.jsonrpc.org/specification

**Table of Contents**

- [RPCs, Requests, and Responses](#rpcs-requests-and-responses)
- [Events](#events)
- [Types](#types)
- [IDs and Names](#ids-and-names)
- [Versioning](#versioning)
- [Private RPCs, Types, and Properties](#private-rpcs-types-and-properties)
- [Public RPCs](#public-rpcs)
	- [addBreakpoint](#addbreakpoint)
	- [addBreakpointAtEntry](#addbreakpointatentry)
	- [evaluate](#evaluate)
	- [evaluateInFrame](#evaluateinframe)
	- [getFlagList](#getflaglist)
	- [getIsolate](#getisolate)
	- [getObject](#getobject)
	- [getStack](#getstack)
	- [getVersion](#getversion)
	- [getVM](#getvm)
	- [pause](#pause)
	- [removeBreakpoint](#removebreakpoint)
	- [resume](#resume)
	- [setName](#setname)
	- [setLibraryDebuggable](#setlibrarydebuggable)
	- [streamCancel](#streamcancel)
	- [streamListen](#streamlisten)
- [Public Types](#public-types)
	- [BoundField](#boundfield)
	- [BoundVariable](#boundvariable)
	- [Breakpoint](#breakpoint)
	- [Class](#class)
	- [ClassList](#classlist)
	- [Code](#code)
	- [CodeKind](#codekind)
	- [Context](#context)
	- [ContextElement](#contextelement)
	- [Error](#error)
	- [ErrorKind](#errorkind)
	- [Event](#event)
	- [EventKind](#eventkind)
	- [Field](#field)
	- [Flag](#flag)
	- [FlagList](#flaglist)
	- [Frame](#frame)
	- [Function](#function)
	- [Instance](#instance)
	- [Isolate](#isolate)
	- [Library](#library)
	- [LibraryDependency](#librarydependency)
	- [MapAssociation](#mapassociation)
	- [Message](#message)
	- [Null](#null)
	- [Object](#object)
	- [Sentinel](#sentinel)
	- [SentinelKind](#sentinelkind)
	- [Script](#script)
	- [SourceLocation](#sourcelocation)
	- [Stack](#stack)
	- [StepOption](#stepoption)
	- [Success](#success)
	- [TypeArguments](#typearguments)
	- [Response](#response)
	- [Version](#version)
	- [VM](#vm)
- [Revision History](#revision-history)

## RPCs, Requests, and Responses

An RPC request is a JSON object sent to the server. Here is an
example [getVersion](#getversion) request:

```
{
  "jsonrpc": "2.0",
  "method": "getVersion",
  "params": {},
  "id": "1"
}
```

The _id_ property must be a string, number, or `null`. The Service Protocol
optionally accepts requests without the _jsonprc_ property.

An RPC response is a JSON object (http://json.org/). The response always specifies an
_id_ property to pair it with the corresponding request. If the RPC
was successful, the _result_ property provides the result.

Here is an example response for our [getVersion](#getversion) request above:

```
{
  "jsonrpc": "2.0",
  "result": {
    "type": "Version",
    "major": 2,
    "minor": 0
  }
  "id": "1"
}
```

Parameters for RPC requests are always provided as _named_ parameters.
The JSON-RPC spec provides for _positional_ parameters as well, but they
are not supported by the Dart VM.

By convention, every response returned by the Service Protocol is a subtype
of [Response](#response) and provides a _type_ paramters which can be used
to distinguish the exact return type. In the example above, the
[Version](#version) type is returned.

Here is an example [streamListen](#streamlisten) request which provides
a parameter:

```
{
  "jsonrpc": "2.0",
  "method": "streamListen",
  "params": {
    "streamId": "GC",
  },
  "id": "2"
}
```

When an RPC encounters an error, it is provided in the _error_
property of the response object. JSON-RPC errors always provide
_code_, _message_, and _data_ properties.

Here is an example error response for our [streamListen](#streamlisten)
request above. This error would be generated if we were attempting to
subscribe to the _GC_ stream multiple times from the same client.

```
{
  "jsonrpc": "2.0",
  "error": {
    "code": 103,
    "message": "Stream already subscribed",
    "data": {
      "details": "The stream 'GC' is already subscribed"
    }
  }
  "id": "2"
}
```

In addition the the [error codes](http://www.jsonrpc.org/specification#error_object)
specified in the JSON-RPC spec, we use the following application specific error codes:

code | message | meaning
---- | ------- | -------
100 | Feature is disabled | The operation is unable to complete because a feature is disabled
101 | VM must be paused | This operation is only valid when the VM is paused
102 | Cannot add breakpoint | The VM is unable to add a breakpoint at the specified line or function
103 | Stream already subscribed | The client is already subscribed to the specified _streamId_
104 | Stream not subscribed | The client is not subscribed to the specified _streamId_

## Events

By using the [streamListen](#streamlisten) and [streamCancel](#streamcancel) RPCs, a client may
request to be notified when an _event_ is posted to a specific
_stream_ in the VM. Every stream has an associated _stream id_ which
is used to name that stream.

Each stream provides access to certain kinds of events. For example the _Isolate_ stream provides
access to events pertaining to isolate births, deaths, and name changes. See [streamListen](#streamlisten)
for a list of the well-known stream ids and their associated events.

Stream events arrive asynchronously over the WebSocket. They're structured as
JSON-RPC 2.0 requests with no _id_ property. The _method_ property will be
_streamNotify_, and the _params_ will have _streamId_ and _event_ properties:

```json
{
  "json-rpc": "2.0",
  "method": "streamNotify",
  "params": {
    "streamId": "Isolate",
    "event": {
      "type": "Event",
      "kind": "IsolateExit",
      "isolate": {
        "type": "@Isolate",
        "id": "isolates/33",
        "number": "51048743613",
        "name": "worker-isolate"
      }
    }
  }
}
```

It is considered a _backwards compatible_ change to add a new type of event to an existing stream.
Clients should be written to handle this gracefully.

## Types

By convention, every result and event provided by the Service Protocol
is a subtype of [Response](#response) and has the _type_ property.
This allows the client to distinguish different kinds of responses. For example,
information about a Dart function is returned using the [Function](#function) type.

If the type of a response begins with the _@_ character, then that
response is a _reference_. If the type name of a response does not
begin with the _@_ character, it is the an _object_. A reference is
intended to be a subset of an object which provides enough information
to generate a reasonable looking reference to the object.

For example, an [@Isolate](#isolate) reference has the _type_, _id_, _name_ and
_number_ properties:

```
  "result": {
    "type": "@Isolate",
    "id": "isolates/33",
    "number": "51048743613"
    "name": "worker-isolate"
  }
```

But an [Isolate](#isolate) object has more information:

```
  "result": {
    "type": "Isolate",
    "id": "isolates/33",
    "number": "51048743613"
    "name": "worker-isolate"
    "rootLib": { ... }
    "entry": ...
    "heaps": ...
     ...
  }
```

## IDs and Names

Many responses returned by the Service Protocol have an _id_ property.
This is an identifier used to request an object from an isolate using
the [getObject](#getobject) RPC. If two responses have the same _id_ then they
refer to the same object. The converse is not true: the same object
may sometimes be returned with two different values for _id_.

The _id_ property should be treated as an opaque string by the client:
it is not meant to be parsed.

An id can be either _temporary_ or _fixed_:

* A _temporary_ id can expire over time. The VM allocates certain ids
  in a ring which evicts old ids over time.

* A _fixed_ id will never expire, but the object it refers to may
  be collected. The VM uses fixed ids for objects like scripts,
  libraries, and classes.

If an id is fixed, the _fixedId_ property will be true. If an id is temporary
the _fixedId_ property will be omitted.

Sometimes a temporary id may expire. In this case, some RPCs may return
an _Expired_ [Sentinel](#sentinel) to indicate this.

The object referred to by an id may be collected by the VM's garbage
collector. In this case, some RPCs may return a _Collected_ [Sentinel](#sentinel)
to indicate this.

Many objects also have a _name_ property. This is provided so that
objects can be displayed in a way that a Dart language programmer
would find familiar. Names are not unique.

## Versioning

The [getVersion](#getversion) RPC can be used to find the version of the protocol
returned by a VM. The _Version_ response has a major and a minor
version number:

```
  "result": {
    "type": "Version",
    "major": 2,
    "minor": 0
  }
```

The major version number is incremented when the protocol is changed
in a potentially _incompatible_ way. An example of an incompatible
change is removing a non-optional property from a result.

The minor version number is incremented when the protocol is changed
in a _backwards compatible_ way. An example of a backwards compatible
change is adding a property to a result.

Certain changes that would normally not be backwards compatible are
considered backwards compatible for the purposes of versioning.
Specifically, additions can be made to the [EventKind](#eventkind) and
[InstanceKind](#instancekind) enumerated types and the client must
handle this gracefully. See the notes on these enumerated types for more
information.

## Private RPCs, Types, and Properties

Any RPC, type, or property which begins with an underscore is said to
be _private_. These RPCs, types, and fields can be changed at any
time without changing major or minor version numbers.

The intention is that the Service Protocol will evolve by adding
private RPCs which may, over time, migrate to the public api as they
become stable. Some private types and properties expose VM specific
implementation state and will never be appropriate to add to
the public api.

## Public RPCs

The following is a list of all public RPCs supported by the Service Protocol.

An RPC is described using the following format:

```
ReturnType methodName(parameterType1 parameterName1,
                      parameterType2, parameterName2,
                      ...)
```

If an RPC says it returns type _T_ it may actually return _T_ or any
[subtype](#public-types) of _T_. For example, an
RPC which is declared to return [@Object](#object) may actually
return [@Instance](#instance).

If an RPC can return one or more independent types, this is indicated
with the vertical bar:

```
ReturnType1|ReturnType2
```

Any RPC may return an _error_ response as [described above](#rpc-error).

Some parameters are optional. This is indicated by the text
_[optional]_ following the parameter name:

```
ReturnType methodName(parameterType parameterName [optional)
```

A description of the return types and parameter types is provided
in the section on [public types](#public-types).

### addBreakpoint

```
Breakpoint addBreakpoint(string isolateId,
                         string scriptId,
                         int line)
```

The _addBreakpoint_ RPC is used to add a breakpoint at a specific line
of some script.

If no breakpoint is possible at that line, the _102_ (Cannot add
breakpoint) error code is returned.

Note that breakpoints are added and removed on a per-isolate basis.

See [Breakpoint](#breakpoint).

### addBreakpointAtEntry

```
Breakpoint addBreakpointAtEntry(string isolateId,
                                string functionId)
```
The _addBreakpointAtEntry_ RPC is used to add a breakpoint at the
entrypoint of some function.

If no breakpoint is possible at the function entry, the _102_ (Cannot add
breakpoint) error code is returned.

See [Breakpoint](#breakpoint).

Note that breakpoints are added and removed on a per-isolate basis.

### evaluate

```
@Instance|@Error|Sentinel evaluate(string isolateId,
                                   string targetId,
                                   string expression)
```

The _evaluate_ RPC is used to evaluate an expression in the context of
some target.

_targetId_ may refer to a [Library](#library), [Class](#class), or
[Instance](#instance).

If _targetId_ is a temporary id which has expired, then then _Expired_
[Sentinel](#sentinel) is returned.

If _targetId_ refers to an object which has been collected by the VM's
garbage collector, then the _Collected_ [Sentinel](#sentinel) is
returned.

If an error occurs while evaluating the expression, an [@Error](#error)
reference will be returned.

If the expression is evaluated successfully, an [@Instance](#instance)
reference will be returned.

### evaluateInFrame

```
@Instance|@Error evaluateInFrame(string isolateId,
                                 int frameIndex,
                                 string expression)
```

The _evaluateInFrame_ RPC is used to evaluate an expression in the
context of a particular stack frame. _frameIndex_ is the index of the
desired [Frame](#frame), with an index of _0_ indicating the top (most
recent) frame.

If an error occurs while evaluating the expression, an [@Error](#error)
reference will be returned.

If the expression is evaluated successfully, an [@Instance](#instance)
reference will be returned.

### getFlagList

```
FlagList getFlagList()
```

The _getFlagList RPC returns a list of all command line flags in the
VM along with their current values.

See [FlagList](#flaglist).

### getIsolate

```
Isolate getIsolate(string isolateId)
```

The _getIsolate_ RPC is used to lookup an _Isolate_ object by its _id_.

See [Isolate](#isolate).

### getObject

```
Object|Sentinel  getObject(string isolateId,
                           string objectId)
```

The _getObject_ RPC is used to lookup an _object_ from some isolate by
its _id_.

If _objectId_ is a temporary id which has expired, then then _Expired_
[Sentinel](#sentinel) is returned.

If _objectId_ refers to an object which has been collected by the VM's
garbage collector, then the _Collected_ [Sentinel](#sentinel) is
returned.

If the object handle has not expired and the object has not been
collected, then an [Object](#object) will be returned.

### getStack

```
Stack getStack(string isolateId)
```

The _getStack_ RPC is used to retrieve the current execution stack and
message queue for an isolate. The isolate does not need to be paused.

See [Stack](#stack).

### getVersion

```
Version getVersion()
```

The _getVersion_ RPC is used to determine what version of the Service Protocol is served by a VM.

See [Version](#version).

### getVM

```
VM getVM()
```

The _getVM_ RPC returns global information about a Dart virtual machine.

See [VM](#vm).

### pause

```
Success pause(string isolateId)
```

The _pause_ RPC is used to interrupt a running isolate. The RPC enqueues the interrupt request and potentially returns before the isolate is paused.

When the isolate is paused an event will be sent on the _Debug_ stream.

See [Success](#success).

### removeBreakpoint

```
Success removeBreakpoint(string isolateId,
                         string breakpointId)
```

The _removeBreakpoint_ RPC is used to remove a breakpoint by its _id_.

Note that breakpoints are added and removed on a per-isolate basis.

See [Success](#success).

### resume

```
Success resume(string isolateId,
               StepOption step [optional])
```

The _resume_ RPC is used to resume execution of a paused isolate.

If the _step_ parameter is not provided, the program will resume
regular execution.

If the _step_ parameter is provided, it indicates what form of
single-stepping to use.

step | meaning
---- | -------
Into | Single step, entering function calls
Over | Single step, skipping over function calls
Out | Single step until the current function exits

See [Success](#success), [StepOption](#StepOption).

### setName

```
Success setName(string isolateId,
                string name)
```

The _setName_ RPC is used to change the debugging name for an isolate.

See [Success](#success).

### setLibraryDebuggable

```
Success setLibraryDebuggable(string isolateId,
                             string libraryId,
                             bool isDebuggable)
```

The _setLibraryDebuggable_ RPC is used to enable or disable whether
breakpoints and stepping work for a given library.

See [Success](#success).

### streamCancel

```
Success streamCancel(string streamId)
```

The _streamCancel_ RPC cancels a stream subscription in the VM.

If the client is not subscribed to the stream, the _104_ (Stream not
subscribed) error code is returned.

See [Success](#success).

### streamListen

```
Success streamListen(string streamId)
```

The _streamListen_ RPC subscribes to a stream in the VM. Once
subscribed, the client will begin receiving events from the stream.

If the client is not subscribed to the stream, the _103_ (Stream already
subscribed) error code is returned.

The _streamId_ parameter may have the following published values:

streamId | event types provided
-------- | -----------
Isolate | IsolateStart, IsolateRunnable, IsolateExit, IsolateUpdate
Debug | PauseStart, PauseExit, PauseBreakpoint, PauseInterrupted, PauseException, Resume, BreakpointAdded, BreakpointResolved, BreakpointRemoved, Inspect
GC | GC

Additionally, some embedders provide the _Stdout_ and _Stderr_
streams.  These streams allow the client to subscribe to writes to
stdout and stderr.

streamId | event types provided
-------- | -----------
Stdout | WriteEvent
Stderr | WriteEvent

It is considered a _backwards compatible_ change to add a new type of event to an existing stream.
Clients should be written to handle this gracefully, perhaps by warning and ignoring.

See [Success](#success).

## Public Types

The following is a list of all public types produced by the Service Protocol.

We define a small set of primitive types, based on JSON equivalents.

type | meaning
---- | -------
string | JSON string values
bool | JSON _true_, _false_
int | JSON numbers without fractions or exponents
float | any JSON number

Note that the Service Protocol does not use JSON _null_.

We describe the format of our JSON objects with the following class format:

```
class T {
  string name;
  int count;
  ...
}
```

This describes a JSON object type _T_ with some set of expected properties.

Types are organized into an inheritance hierarchy. If type _T_
extends type _S_...

```
class S {
  string a;
}

class T extends S {
  string b;
}
```

...then that means that all properties of _S_ are also present in type
_T_. In the example above, type _T_ would have the expected
properties _a_ and _b_.

If a property has an _Array_ type, it is written with brackets:

```
  PropertyType[] arrayProperty;
```

If a property is optional, it is suffixed with the text _[optional]_:

```
  PropertyType optionalProperty [optional];
```

If a property can have multiple independent types, we denote this with
a vertical bar:

```
  PropertyType1|PropertyType2 complexProperty;
```

When a string is only permitted to take one of a certain set of values,
we indicate this by the use of the _enum_ format:

```
enum PermittedValues {
  Value1,
  Value2
}
```

This means that _PermittedValues_ is a _string_ with two potential values,
_Value1_ and _Value2_.

### BoundField

```
class BoundField {
  @Field decl;
  @Instance|Sentinel value;
}
```

A _BoundField_ represents a field bound to a particular value in an
_Instance_.

If the field is uninitialized, the _value_ will be the
_NotInitialized_ [Sentinel](#sentinel).

If the field is being initialized, the _value_ will be the
_BeingInitialized_ [Sentinel](#sentinel).

### BoundVariable

```
class BoundVariable {
  string name;
  @Instance|Sentinel value;
}
```

A _BoundVariable_ represents a local variable bound to a particular value
in a _Frame_.

If the variable is uninitialized, the _value_ will be the
_NotInitialized_ [Sentinel](#sentinel).

If the variable is being initialized, the _value_ will be the
_BeingInitialized_ [Sentinel](#sentinel).

If the variable has been optimized out by the compiler, the _value_
will be the _OptimizedOut_ [Sentinel](#sentinel).

### Breakpoint

```
class Breakpoint extends Object {
  int breakpointNumber;
  bool resolved;
  SourceLocation location;
}
```

A _Breakpoint_ describes a debugger breakpoint.

### Class

```
class @Class extends @Object {
  // The name of this class.
  string name;
}
```

_@Class_ is a reference to a _Class_.

```
class Class extends Object {
  // The name of this class.
  string name;

  // The error which occurred during class finalization, if it exists.
  @Error error [optional];

  // Is this an abstract class?
  bool abstract;

  // Is this a const class?
  bool const;

  // The library which contains this class.
  @Library library;

  // The location of this class in the source code.
  SourceLocation location [optional];

  // The superclass of this class, if any.
  @Class super [optional];

  // A list of interface types for this class.
  //
  // The value will be of the kind: Type.
  @Instance[] interfaces;

  // A list of fields in this class. Does not include fields from
  // superclasses.
  @Field[] fields;

  // A list of functions in this class. Does not include functions
  // from superclasses.
  @Function[] functions;

  // A list of subclasses of this class.
  @Class[] subclasses;
}
```

A _Class_ provides information about a Dart language class.

### ClassList

```
class ClassList extends Response {
  @Class[] classes;
}
```

### Code

```
class @Code extends @Object {
  // A name for this code object.
  string name;

  // What kind of code object is this?
  CodeKind kind;
}
```

_@Code_ is a reference to a _Code_ object.

```
class Code extends @Object {
  // A name for this code object.
  string name;

  // What kind of code object is this?
  CodeKind kind;
}
```

A _Code_ object represents compiled code in the Dart VM.

### CodeKind

```
enum CodeKind {
  Dart,
  Native,
  Stub,
  Tag,
  Collected
}
```

### Context

```
class @Context {
  // The number of variables in this context.
  int length;
}
```

```
class Context {
  // The number of variables in this context.
  int length;

  // The enclosing context for this context.
  Context parent [optional];

  // The variables in this context object.
  ContextElement[] variables;
}
```

### ContextElement

```
class ContextElement {
  @Instance|Sentinel value;
}
```

### Error

```
class @Error extends @Object {
  // What kind of error is this?
  ErrorKind kind;

  // A description of the error.
  string message;
}
```

_@Error_ is a reference to an _Error_.

```
class Error extends Object {
  // What kind of error is this?
  ErrorKind kind;

  // A description of the error.
  string message;

  // If this error is due to an unhandled exception, this
  // is the exception thrown.
  @Instance exception [optional];

  // If this error is due to an unhandled exception, this
  // is the stacktrace object.
  @Instance stacktrace [optional];
}
```

An _Error_ represents a Dart language level error. This is distinct from an
[rpc error](#rpc-error).

### ErrorKind

```
enum ErrorKind {
  // The isolate has encountered an unhandled Dart exception.
  UnhandledException,

  // The isolate has encountered a Dart language error in the program.
  LanguageError,

  // The isolate has encounted an internal error. These errors should be
  // reported as bugs.
  InternalError,

  // The isolate has been terminated by an external source.
  TerminationError
}
```

### Event

```
class Event extends Response {
  // What kind of event is this?
  EventKind kind;

  // The isolate with which this event is associated.
  @Isolate isolate;

  // The timestamp (in milliseconds since the epoch) associated with this event.
  // For some isolate pause events, the timestamp is from when the isolate was
  // paused. For other events, the timestamp is from when the event was created.
  int timestamp;

  // The breakpoint which was added, removed, or resolved.
  //
  // This is provided for the event kinds:
  //   PauseBreakpoint
  //   BreakpointAdded
  //   BreakpointRemoved
  //   BreakpointResolved
  Breakpoint breakpoint [optional];

  // The list of breakpoints at which we are currently paused
  // for a PauseBreakpoint event.
  //
  // This list may be empty. For example, while single-stepping, the
  // VM sends a PauseBreakpoint event with no breakpoints.
  //
  // If there is more than one breakpoint set at the program position,
  // then all of them will be provided.
  //
  // This is provided for the event kinds:
  //   PauseBreakpoint
  Breakpoint[] pauseBreakpoints [optional];

  // The top stack frame associated with this event, if applicable.
  //
  // This is provided for the event kinds:
  //   PauseBreakpoint
  //   PauseInterrupted
  //   PauseException
  //
  // For the Resume event, the top frame is provided at
  // all times except for the initial resume event that is delivered
  // when an isolate begins execution.
  Frame topFrame [optional];

  // The exception associated with this event, if this is a
  // PauseException event.
  @Instance exception [optional];

  // An array of bytes, encoded as a base64 string.
  //
  // This is provided for the WriteEvent event.
  string bytes [optional];
}
```

An _Event_ is an asynchronous notification from the VM. It is delivered
only when the client has subscribed to an event stream using the
[streamListen](#streamListen) RPC.

For more information, see [events](#events).

### EventKind

```
enum EventKind {
  // Notification that a new isolate has started.
  IsolateStart,

  // Notification that an isolate is ready to run.
  IsolateRunnable,

  // Notification that an isolate has exited.
  IsolateExit,

  // Notification that isolate identifying information has changed.
  // Currently used to notify of changes to the isolate debugging name
  // via setName.
  IsolateUpdate,

  // An isolate has paused at start, before executing code.
  PauseStart,

  // An isolate has paused at exit, before terminating.
  PauseExit,

  // An isolate has paused at a breakpoint or due to stepping.
  PauseBreakpoint,

  // An isolate has paused due to interruption via pause.
  PauseInterrupted,

  // An isolate has paused due to an exception.
  PauseException,

  // An isolate has started or resumed execution.
  Resume,

  // A breakpoint has been added for an isolate.
  BreakpointAdded,

  // An unresolved breakpoint has been resolved for an isolate.
  BreakpointResolved,

  // A breakpoint has been removed.
  BreakpointRemoved,

  // A garbage collection event.
  GC,

  // Notification of bytes written, for example, to stdout/stderr.
  WriteEvent
}
```

Adding new values to _EventKind_ is considered a backwards compatible
change. Clients should ignore unrecognized events.

### Field

```
class @Field extends @Object {
  // The name of this field.
  string name;

  // The owner of this field, which can be either a Library or a
  // Class.
  @Object owner;

  // The declared type of this field.
  //
  // The value will always be of one of the kinds:
  // Type, TypeRef, TypeParameter, BoundedType.
  @Instance declaredType;

  // Is this field const?
  bool const;

  // Is this field final?
  bool final;

  // Is this field static?
  bool static;
}
```

An _@Field_ is a reference to a _Field_.

```
class Field extends Object {
  // The name of this field.
  string name;

  // The owner of this field, which can be either a Library or a
  // Class.
  @Object owner;

  // The declared type of this field.
  //
  // The value will always be of one of the kinds:
  // Type, TypeRef, TypeParameter, BoundedType.
  @Instance declaredType;

  // Is this field const?
  bool const;

  // Is this field final?
  bool final;

  // Is this field static?
  bool static;

  // The value of this field, if the field is static.
  @Instance staticValue [optional];

  // The location of this field in the source code.
  SourceLocation location [optional];
}
```

A _Field_ provides information about a Dart language field or
variable.

### Flag

```
class Flag {
  // The name of the flag.
  string name;

  // A description of the flag.
  string comment;

  // Has this flag been modified from its default setting?
  bool modified;

  // The value of this flag as a string.
  //
  // If this property is absent, then the value of the flag was NULL.
  string valueAsString [optional];
}
```

A _Flag_ represents a single VM command line flag.

### FlagList

```
class FlagList extends Response {
  // A list of all flags in the VM.
  Flag[] flags;
}
```

A _FlagList_ represents the complete set of VM command line flags.

### Frame

```
class Frame extends Response {
  int index;
  @Function function;
  @Code code;
  SourceLocation location;
  BoundVariable[] vars;
}
```

### Function

```
class @Function extends @Object {
  // The name of this function.
  string name;

  // The owner of this field, which can be a Library, Class, or a
  // Function.
  @Library|@Class|@Function owner;

  // Is this function static?
  bool static;

  // Is this function const?
  bool const;
}
```

An _@Function_ is a reference to a _Function_.

```
class Function extends Object {
  // The name of this function.
  string name;

  // The owner of this field, which can be a Library, Class, or a
  // Function.
  @Library|@Class|@Function owner;

  // The location of this function in the source code.
  SourceLocation location [optional];

  // The compiled code associated with this function.
  @Code code [optional];
}
```

A _Function_ represents a Dart language function.

### Instance

```
class @Instance extends @Object {
  // What kind of instance is this?
  InstanceKind kind;

  // Instance references always include their class.
  @Class class;

  // The value of this instance as a string.
  //
  // Provided for the instance kinds:
  //   Null (null)
  //   Bool (true or false)
  //   Double (suitable for passing to Double.parse())
  //   Int (suitable for passing to int.parse())
  //   String (value may be truncated)
  string valueAsString [optional];

  // The valueAsString for String references may be truncated. If so,
  // this property is added with the value 'true'.
  bool valueAsStringIsTruncated [optional];

  // The length of a List instance.
  //
  // Provided for instance kinds:
  //   List
  //   Map
  //   Uint8ClampedList
  //   Uint8List
  //   Uint16List
  //   Uint32List
  //   Uint64List
  //   Int8List
  //   Int16List
  //   Int32List
  //   Int64List
  //   Float32List
  //   Float64List
  //   Int32x4List
  //   Float32x4List
  //   Float64x2List
  int length [optional];

  // The name of a Type instance.
  //
  // Provided for instance kinds:
  //   Type
  string name [optional];

  // The corresponding Class if this Type is canonical.
  //
  // Provided for instance kinds:
  //   Type
  @Class typeClass [optional];

  // The parameterized class of a type parameter:
  //
  // Provided for instance kinds:
  //   TypeParameter
  @Class parameterizedClass [optional];

  // The pattern of a RegExp instance.
  //
  // Provided for instance kinds:
  //   RegExp
  String pattern [optional];
}
```

_@Instance_ is a reference to an _Instance_.

```
class Instance extends Object {
  // What kind of instance is this?
  InstanceKind kind;

  // Instance references always include their class.
  @Class class;

  // The value of this instance as a string.
  //
  // Provided for the instance kinds:
  //   Bool (true or false)
  //   Double (suitable for passing to Double.parse())
  //   Int (suitable for passing to int.parse())
  //   String (value may be truncated)
  string valueAsString [optional];

  // The valueAsString for String references may be truncated. If so,
  // this property is added with the value 'true'.
  bool valueAsStringIsTruncated [optional];

  // The length of a List instance.
  //
  // Provided for instance kinds:
  //   List
  //   Map
  //   Uint8ClampedList
  //   Uint8List
  //   Uint16List
  //   Uint32List
  //   Uint64List
  //   Int8List
  //   Int16List
  //   Int32List
  //   Int64List
  //   Float32List
  //   Float64List
  //   Int32x4List
  //   Float32x4List
  //   Float64x2List
  int length [optional];

  // The name of a Type instance.
  //
  // Provided for instance kinds:
  //   Type
  string name [optional];

  // The corresponding Class if this Type is canonical.
  //
  // Provided for instance kinds:
  //   Type
  @Class typeClass [optional];

  // The parameterized class of a type parameter:
  //
  // Provided for instance kinds:
  //   TypeParameter
  @Class parameterizedClass [optional];

  // The fields of this Instance.
  BoundField fields [optional];

  // The elements of a List instance.
  //
  // Provided for instance kinds:
  //   List
  @Instance|Sentinel[] elements [optional];

  // The elements of a List instance.
  //
  // Provided for instance kinds:
  //   Map
  MapAssociation[] associations [optional];

  // The bytes of a TypedData instance.
  //
  // Provided for instance kinds:
  //   Uint8ClampedList
  //   Uint8List
  //   Uint16List
  //   Uint32List
  //   Uint64List
  //   Int8List
  //   Int16List
  //   Int32List
  //   Int64List
  //   Float32List
  //   Float64List
  //   Int32x4List
  //   Float32x4List
  //   Float64x2List
  int[] bytes [optional];

  // The function associated with a Closure instance.
  //
  // Provided for instance kinds:
  //   Closure
  @Function closureFunction [optional];

  // The context associated with a Closure instance.
  //
  // Provided for instance kinds:
  //   Closure
  @Function closureContext [optional];

  // The referent of a MirrorReference instance.
  //
  // Provided for instance kinds:
  //   MirrorReference
  @Instance mirrorReferent [optional];

  // The pattern of a RegExp instance.
  //
  // Provided for instance kinds:
  //   RegExp
  String pattern [optional];

  // Whether this regular expression is case sensitive.
  //
  // Provided for instance kinds:
  //   RegExp
  bool isCaseSensitive [optional];

  // Whether this regular expression matches multiple lines.
  //
  // Provided for instance kinds:
  //   RegExp
  bool isMultiLine [optional];

  // The key for a WeakProperty instance.
  //
  // Provided for instance kinds:
  //   WeakProperty
  @Instance propertyKey [optional];

  // The key for a WeakProperty instance.
  //
  // Provided for instance kinds:
  //   WeakProperty
  @Instance propertyValue [optional];

  // The type arguments for this type.
  //
  // Provided for instance kinds:
  //   Type
  @TypeArguments typeArguments [optional];

  // The index of a TypeParameter instance.
  //
  // Provided for instance kinds:
  //   TypeParameter
  int parameterIndex [optional];

  // The type bounded by a BoundedType instance
  // - or -
  // the referent of a TypeRef instance.
  //
  // The value will always be of one of the kinds:
  // Type, TypeRef, TypeParameter, BoundedType.
  //
  // Provided for instance kinds:
  //   BoundedType
  //   TypeRef
  @Instance targetType [optional];

  // The bound of a TypeParameter or BoundedType.
  //
  // The value will always be of one of the kinds:
  // Type, TypeRef, TypeParameter, BoundedType.
  //
  // Provided for instance kinds:
  //   BoundedType
  //   TypeParameter
  @Instance bound [optional];
}
```

An _Instance_ represents an instance of the Dart language class _Object_.

### InstanceKind

```
enum InstanceKind {
  // A general instance of the Dart class Object.
  PlainInstance,

  // null instance.
  Null,

  // true or false.
  Bool,

  // An instance of the Dart class double.
  Double,

  // An instance of the Dart class int.
  Int,

  // An instance of the Dart class String.
  String,

  // An instance of the built-in VM List implementation. User-defined
  // Lists will be PlainInstance.
  List,

  // An instance of the built-in VM Map implementation. User-defined
  // Maps will be PlainInstance.
  Map,

  // An instance of the built-in VM TypedData implementations.  User-defined
  // TypedDatas will be PlainInstance.
  Uint8ClampedList,
  Uint8List,
  Uint16List,
  Uint32List,
  Uint64List,
  Int8List,
  Int16List,
  Int32List,
  Int64List,
  Float32List,
  Float64List,
  Int32x4List,
  Float32x4List,
  Float64x2List,

  // An instance of the built-in VM Closure implementation. User-defined
  // Closures will be PlainInstance.
  Closure,

  // An instance of the Dart class MirrorReference.
  MirrorReference,

  // An instance of the Dart class RegExp.
  RegExp,

  // An instance of the Dart class WeakProperty.
  WeakProperty,

  // An instance of the Dart class Type
  Type,

  // An instance of the Dart class TypeParamer
  TypeParameter,

  // An instance of the Dart class TypeRef
  TypeRef,

  // An instance of the Dart class BoundedType
  BoundedType,
}
```

Adding new values to _InstanceKind_ is considered a backwards
compatible change. Clients should treat unrecognized instance kinds
as _PlainInstance_.

### Isolate

```
class @Isolate extends Response {
  // The id which is passed to the getIsolate RPC to load this isolate.
  string id;

  // A numeric id for this isolate, represented as a string. Unique.
  string number;

  // A name identifying this isolate. Not guaranteed to be unique.
  string name;
}
```

_@Isolate_ is a reference to an _Isolate_ object.

```
class Isolate extends Response {
  // The id which is passed to the getIsolate RPC to reload this
  // isolate.
  string id;

  // A numeric id for this isolate, represented as a string. Unique.
  string number;

  // A name identifying this isolate. Not guaranteed to be unique.
  string name;

  // The time that the VM started in milliseconds since the epoch.
  //
  // Suitable to pass to DateTime.fromMillisecondsSinceEpoch.
  int startTime;

  // The number of live ports for this isolate.
  int livePorts;

  // Will this isolate pause when exiting?
  bool pauseOnExit;

  // The last pause event delivered to the isolate. If the isolate is
  // running, this will be a resume event.
  Event pauseEvent;

  // The entry function for this isolate.
  //
  // Guaranteed to be initialized when the IsolateRunnable event fires.
  @Function entry [optional];

  // The root library for this isolate.
  //
  // Guaranteed to be initialized when the IsolateRunnable event fires.
  @Library rootLib [optional];

  // A list of all libraries for this isolate.
  //
  // Guaranteed to be initialized when the IsolateRunnable event fires.
  @Library[] libraries;

  // A list of all breakpoints for this isolate.
  Breakpoint[] breakpoints;

  // The error that is causing this isolate to exit, if applicable.
  Error error [optional];
}
```

An _Isolate_ object provides information about one isolate in the VM.

### Library

```
class @Library extends @Object {
  // The name of this library.
  string name;

  // The uri of this library.
  string uri;
}
```

_@Library_ is a reference to a _Library_.

```
class Library extends Object {
  // The name of this library.
  string name;

  // The uri of this library.
  string uri;

  // Is this library debuggable?  Default true.
  bool debuggable;

  // A list of the imports for this library.
  LibraryDependency[] dependencies;

  // A list of the scripts which constitute this library.
  @Script[] scripts;

  // A list of the top-level variables in this library.
  @Field[] variables;

  // A list of the top-level functions in this library.
  @Function[] functions;

  // A list of all classes in this library.
  @Class[] classes;
}
```

A _Library_ provides information about a Dart language library.

See [setLibraryDebuggable](#setlibrarydebuggable).

### LibraryDependency

```
class LibraryDependency {
  // Is this dependency an import (rather than an export)?
  bool isImport;

  // Is this dependency deferred?
  bool isDeferred;

  // The prefix of an 'as' import, or null.
  String prefix;

  // The library being imported or exported.
  @Library target;
}
```

A _LibraryDependency_ provides information about an import or export.

### MapAssociation

```
class MapAssociation {
  @Instance|Sentinel key;
  @Instance|Sentinel value;
}
```

### Message

```
class Message extends Response {
  int index;
  string name;
  string messageObjectId;
  int size;
  @Function handler [optional];
  SourceLocation location [optional];
}
```

### Null

```
class @Null extends @Instance {
  // Always 'null'.
  string valueAsString;
}
```

_@Null_ is a reference to an a _Null_.

```
class Null extends Instance {
  // Always 'null'.
  string valueAsString;
}
```

A _Null_ object represents the Dart language value null.

### Object

```
class @Object extends Response {
  // A unique identifier for an Object. Passed to the
  // getObject RPC to load this Object.
  string id;
}
```

_@Object_ is a reference to a _Object_.

```
class Object extends Response {
  // A unique identifier for an Object. Passed to the
  // getObject RPC to reload this Object.
  //
  // Some objects may get a new id when they are reloaded.
  string id;

  // If an object is allocated in the Dart heap, it will have
  // a corresponding class object.
  //
  // The class of a non-instance is not a Dart class, but is instead
  // an internal vm object.
  //
  // Moving an Object into or out of the heap is considered a
  // backwards compatible change for types other than Instance.
  @Class class [optional];

  // The size of this object in the heap.
  //
  // If an object is not heap-allocated, then this field is omitted.
  //
  // Note that the size can be zero for some objects. In the current
  // VM implementation, this occurs for small integers, which are
  // stored entirely within their object pointers.
  int size [optional];
}
```

An _Object_ is a  persistent object that is owned by some isolate.

### Sentinel

```
class Sentinel extends Response {
  // What kind of sentinel is this?
  SentinelKind kind;

  // A reasonable string representation of this sentinel.
  string valueAsString;
}
```

A _Sentinel_ is used to indicate that the normal response is not available.

We use a _Sentinel_ instead of an [error](#errors) for these cases because
they do not represent a problematic condition. They are normal.

### SentinelKind

```
enum SentinelKind {
  // Indicates that the object referred to has been collected by the GC.
  Collected,

  // Indicates that an object id has expired.
  Expired,

  // Indicates that a variable or field has not been initialized.
  NotInitialized,

  // Indicates that a variable or field is in the process of being initialized.
  BeingInitialized,

  // Indicates that a variable has been eliminated by the optimizing compiler.
  OptimizedOut,

  // Reserved for future use.
  Free,
}
```

A _SentinelKind_ is used to distinguish different kinds of _Sentinel_ objects.

Adding new values to _SentinelKind_ is considered a backwards
compatible change. Clients must handle this gracefully.

### Script

```
class @Script extends @Object {
  // The uri from which this script was loaded.
  string uri;
}
```

_@Script_ is a reference to a _Script_.

```
class Script extends Object {
  // The uri from which this script was loaded.
  string uri;

  // The library which owns this script.
  @Library library;

  // The source code for this script. For certain built-in scripts,
  // this may be reconstructed without source comments.
  string source;

  // A table encoding a mapping from token position to line and column.
  int[][] tokenPosTable;
}
```

A _Script_ provides information about a Dart language script.

The _tokenPosTable_ is an array of int arrays. Each subarray
consists of a line number followed by _(tokenPos, columnNumber)_ pairs:

> [lineNumber, (tokenPos, columnNumber)*]

For example, a _tokenPosTable_ with the value...

> [[1, 100, 5, 101, 8],[2, 102, 7]]

...encodes the mapping:

tokenPos | line | column
-------- | ---- | ------
100 | 1 | 5
101 | 1 | 8
102 | 2 | 7

### SourceLocation

```
class SourceLocation extends Response {
  // The script containing the source location.
  @Script script;

  // The first token of the location.
  int tokenPos;

  // The last token of the location if this is a range.
  int endTokenPos [optional];
}
```

The _SourceLocation_ class is used to designate a position or range in
some script.

### Stack

```
class Stack extends Response {
  Frame[] frames;
  Message[] messages;
}
```

### StepOption

```
enum StepOption {
  Into,
  Over,
  Out
}
```

A _StepOption_ indicates which form of stepping is requested in a [resume](#resume) RPC.

### Success

```
class Success extends Response {
}
```

The _Success_ type is used to indicate that an operation completed successfully.

### TypeArguments

```
class @TypeArguments extends @Object {
  // A name for this type argument list.
  string name;
}
```

_@TypeArguments_ is a reference to a _TypeArguments_ object.

```
class TypeArguments extends Object {
  // A name for this type argument list.
  string name;

  // A list of types.
  //
  // The value will always be one of the kinds:
  // Type, TypeRef, TypeParameter, BoundedType.
  @Instance[] types;
}
```

A _TypeArguments_ object represents the type argument vector for some
instantiated generic type.

### Response

```
class Response {
  // Every response returned by the VM Service has the
  // type property. This allows the client distinguish
  // between different kinds of responses.
  string type;
}
```

Every non-error response returned by the Service Protocol extends _Response_.
By using the _type_ property, the client can determine which [type](#types)
of response has been provided.

### Version

```
class Version extends Response {
  // The major version number is incremented when the protocol is changed
  // in a potentially incompatible way.
  int major;

  // The minor version number is incremented when the protocol is changed
  // in a backwards compatible way.
  int minor;
}
```

See [Versioning](#versioning).

### VM

```
class VM extends Response {
  // Word length on target architecture (e.g. 32, 64).
  int architectureBits;

  // The CPU we are generating code for.
  string targetCPU;

  // The CPU we are actually running on.
  string hostCPU;

  // The Dart VM version string.
  string version;

  // The process id for the VM.
  string pid;

  // The time that the VM started in milliseconds since the epoch.
  //
  // Suitable to pass to DateTime.fromMillisecondsSinceEpoch.
  int startTime;

  // A list of isolates running in the VM.
  @Isolate[] isolates;
}
```

## Revision History

version | comments
------- | --------
1.0 draft 1 | initial revision

[discuss-list]: https://groups.google.com/a/dartlang.org/forum/#!forum/observatory-discuss

redpajama_set_name: RedPajamaGithub


text:
package org.jgrades.admin.accounts;

import org.jgrades.admin.api.accounts.UserMgntService;
import org.jgrades.data.api.dao.accounts.UserRepository;
import org.jgrades.data.api.entities.User;
import org.jgrades.data.api.model.JgRole;
import org.jgrades.data.api.service.crud.AbstractPagingMgntService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

@Service
public class UserMgntServiceImpl extends AbstractPagingMgntService<User, Long, UserRepository> implements UserMgntService {
    @Autowired
    private UserModelEnrichment userModelEnrichment;

    @Autowired
    private UserRolesProcessor userRolesProcessor;

    @Autowired
    public UserMgntServiceImpl(UserRepository repository) {
        super(repository);
    }

    @Override
    @Transactional("mainTransactionManager")
    public void saveOrUpdate(User user) {
        user.setId(repository.save(user).getId());
        userRolesProcessor.process(user);
    }

    @Override
    public void remove(User user) {
        removeWithId(getWithId(user.getId()));
    }

    private void removeWithId(User user) {
        repository.delete(user);
    }

    @Override
    @Transactional("mainTransactionManager")
    public void remove(List<User> users) {
        users.forEach(this::remove);
    }

    @Override
    @Transactional("mainTransactionManager")
    public void removeIds(List<Long> ids) {
        ids.forEach(this::removeId);
    }

    @Override
    @Transactional("mainTransactionManager")
    public void removeId(Long id) {
        userRolesProcessor.remove(getWithId(id));
        super.removeId(id);
    }

    @Override
    public List<User> getAll() {
        return super.getAll().stream()
                .map(userModelEnrichment::enrichWithRoles)
                .collect(Collectors.toList());
    }

    @Override
    public User getWithId(Long id) {
        return userModelEnrichment.enrichWithRoles(super.getWithId(id));
    }

    @Override
    public List<User> getWithIds(List<Long> ids) {
        return super.getWithIds(ids).stream()
                .map(userModelEnrichment::enrichWithRoles)
                .collect(Collectors.toList());
    }

    @Override
    public List<User> get(Specification<User> specification) {
        return repository.findAll(specification).stream()
                .map(userModelEnrichment::enrichWithRoles)
                .collect(Collectors.toList());
    }

    @Override
    public Page<User> getPage(Pageable pageable) {
        Page<User> pageBeforeEnrichment = super.getPage(pageable);
        List<User> newContent = pageBeforeEnrichment.getContent().stream()
                .map(userModelEnrichment::enrichWithRoles)
                .collect(Collectors.toList());
        return new PageImpl<User>(newContent, pageable, pageBeforeEnrichment.getTotalElements());
    }

    @Override
    public Page<User> getPage(Pageable pageable, Specification<User> specification) {
        Page<User> pageBeforeEnrichment = repository.findAll(specification, pageable);
        List<User> newContent = pageBeforeEnrichment.getContent().stream()
                .map(userModelEnrichment::enrichWithRoles)
                .collect(Collectors.toList());
        return new PageImpl<User>(newContent, pageable, pageBeforeEnrichment.getTotalElements());
    }

    @Override
    public Set<JgRole> getUserRoles(User user) {
        return userModelEnrichment.getRoles(user);
    }

    @Override
    public User getWithLogin(String login) {
        return userModelEnrichment.enrichWithRoles(repository.findFirstByLogin(login));
    }
}


text:
package com.amazonaws.services.quicksight.model;

import javax.annotation.Generated;

/**
 *

 * The NextToken value isn't valid.
 *

 */
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class InvalidNextTokenException extends com.amazonaws.services.quicksight.model.AmazonQuickSightException {
    private static final long serialVersionUID = 1L;

    /**
     *

     * The Amazon Web Services request ID for this request.
     *

     */
    private String requestId;

    /**
     * Constructs a new InvalidNextTokenException with the specified error message.
     *
     * @param message
     *        Describes the error encountered.
     */
    public InvalidNextTokenException(String message) {
        super(message);
    }

    /**
     *

     * The Amazon Web Services request ID for this request.
     *

     *
     * @param requestId
     *        The Amazon Web Services request ID for this request.
     */

    @com.fasterxml.jackson.annotation.JsonProperty("RequestId")
    public void setRequestId(String requestId) {
        this.requestId = requestId;
    }

    /**
     *

     * The Amazon Web Services request ID for this request.
     *

     *
     * @return The Amazon Web Services request ID for this request.
     */

    @com.fasterxml.jackson.annotation.JsonProperty("RequestId")
    public String getRequestId() {
        return this.requestId;
    }

    /**
     *

     * The Amazon Web Services request ID for this request.
     *

     *
     * @param requestId
     *        The Amazon Web Services request ID for this request.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public InvalidNextTokenException withRequestId(String requestId) {
        setRequestId(requestId);
        return this;
    }

}


text:
package com.epam.rft.atsy.persistence.entities;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
 * Represents a user in the database, who can log in to the site and manage candidates.
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true, exclude = "userPassword")
@Entity
@Table(name = "users", schema = "atsy", uniqueConstraints = @UniqueConstraint(columnNames = "user_name"))
public class UserEntity extends SuperEntity implements java.io.Serializable {

  @Column(name = "user_name", nullable = false, length = 255, table = "users")
  private String userName;

  @Column(name = "user_pwd", nullable = false, length = 255, table = "users")
  private String userPassword;

  @Builder
  public UserEntity(Long id, String userName, String userPassword) {
    super(id);
    this.userName = userName;
    this.userPassword = userPassword;
  }

}


text:
"""
Interfaces with TotalConnect alarm control panels.

For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/alarm_control_panel.totalconnect/
"""
import logging

import voluptuous as vol

import homeassistant.helpers.config_validation as cv
import homeassistant.components.alarm_control_panel as alarm
from homeassistant.components.alarm_control_panel import PLATFORM_SCHEMA
from homeassistant.const import (
    CONF_PASSWORD, CONF_USERNAME, STATE_ALARM_ARMED_AWAY,
    STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_NIGHT, STATE_ALARM_DISARMED,
    STATE_ALARM_ARMING, STATE_ALARM_DISARMING, STATE_UNKNOWN, CONF_NAME,
    STATE_ALARM_ARMED_CUSTOM_BYPASS)

REQUIREMENTS = ['total_connect_client==0.16']

_LOGGER = logging.getLogger(__name__)

DEFAULT_NAME = 'Total Connect'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_PASSWORD): cv.string,
    vol.Required(CONF_USERNAME): cv.string,
    vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
})

def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up a TotalConnect control panel."""
    name = config.get(CONF_NAME)
    username = config.get(CONF_USERNAME)
    password = config.get(CONF_PASSWORD)

    total_connect = TotalConnect(name, username, password)
    add_devices([total_connect], True)

class TotalConnect(alarm.AlarmControlPanel):
    """Represent an TotalConnect status."""

    def __init__(self, name, username, password):
        """Initialize the TotalConnect status."""
        from total_connect_client import TotalConnectClient

        _LOGGER.debug("Setting up TotalConnect...")
        self._name = name
        self._username = username
        self._password = password
        self._state = STATE_UNKNOWN
        self._client = TotalConnectClient.TotalConnectClient(
            username, password)

    @property
    def name(self):
        """Return the name of the device."""
        return self._name

    @property
    def state(self):
        """Return the state of the device."""
        return self._state

    def update(self):
        """Return the state of the device."""
        status = self._client.get_armed_status()

        if status == self._client.DISARMED:
            state = STATE_ALARM_DISARMED
        elif status == self._client.ARMED_STAY:
            state = STATE_ALARM_ARMED_HOME
        elif status == self._client.ARMED_AWAY:
            state = STATE_ALARM_ARMED_AWAY
        elif status == self._client.ARMED_STAY_NIGHT:
            state = STATE_ALARM_ARMED_NIGHT
        elif status == self._client.ARMED_CUSTOM_BYPASS:
            state = STATE_ALARM_ARMED_CUSTOM_BYPASS
        elif status == self._client.ARMING:
            state = STATE_ALARM_ARMING
        elif status == self._client.DISARMING:
            state = STATE_ALARM_DISARMING
        else:
            state = STATE_UNKNOWN

        self._state = state

    def alarm_disarm(self, code=None):
        """Send disarm command."""
        self._client.disarm()

    def alarm_arm_home(self, code=None):
        """Send arm home command."""
        self._client.arm_stay()

    def alarm_arm_away(self, code=None):
        """Send arm away command."""
        self._client.arm_away()

    def alarm_arm_night(self, code=None):
        """Send arm night command."""
        self._client.arm_stay_night()


text:
'use strict';

describe('module: signup, service: Signup', function () {

  // load the service's module
  beforeEach(module('signup'));
  // load all the templates to prevent unexpected $http requests from ui-router
  beforeEach(module('ngHtml2Js'));

  // instantiate service
  var Signup;
  var $timeout;
  beforeEach(inject(function (_Signup_, _$timeout_) {
    Signup = _Signup_;
    $timeout = _$timeout_;
  }));

  describe('.changeBriefly()', function () {
    beforeEach(function () {
      Signup.changeBriefly();
    });
    it('should briefly change', function () {
      expect(Signup.someData.binding).toEqual('Yeah this was changed');
      $timeout.flush();
      expect(Signup.someData.binding).toEqual('Yes! Got that databinding working');
    });
  });

});


text:
set -euo pipefail

# This script will import slides from the Hacker Slides instance that
# Asheesh has been using into a directory structure that can live in
# this repo.

mkdir -p student-handout
pushd student-handout

# First, nab the slides.
wget --header "Cookie: $2" "https://$1/slides.md"

# Then, nab the static directory, and all that it references.
mkdir -p static
pushd static
wget -nH --cut-dirs=1 --mirror --no-parent --header "Cookie: $2" "https://$1/static/slides.html" || true  # OK if this fails.

# Grab these extra dependencies.
for thing in "plugin/markdown/markdown.js" "plugin/markdown/marked.js" "css/print/paper.css" "plugin/zoom-js/zoom.js" "plugin/notes/notes.js" "plugin/notes/notes.html"
do
wget -nH --cut-dirs=1 --mirror --no-parent --header "Cookie: $2" "https://$1/static/$thing" || true  # OK if this fails.
done

# Prepare this for git commit, but let the user be the one to actually
# commit it.
popd; popd
git add .


text:
package org.apache.metamodel.elasticsearch.nativeclient;

import junit.framework.TestCase;
import org.apache.metamodel.data.DataSetHeader;
import org.apache.metamodel.data.Row;
import org.apache.metamodel.data.SimpleDataSetHeader;
import org.apache.metamodel.query.SelectItem;
import org.apache.metamodel.schema.ColumnType;
import org.apache.metamodel.schema.MutableColumn;

import java.util.*;

public class ElasticSearchUtilsTest extends TestCase {

    public void testAssignDocumentIdForPrimaryKeys() throws Exception {
        MutableColumn primaryKeyColumn = new MutableColumn("value1", ColumnType.STRING).setPrimaryKey(true);
        SelectItem primaryKeyItem = new SelectItem(primaryKeyColumn);
        List<SelectItem> selectItems1 = Collections.singletonList(primaryKeyItem);
        String documentId = "doc1";
        DataSetHeader header = new SimpleDataSetHeader(selectItems1);
        Map<String, Object> values = new HashMap<>();
        values.put("value1", "theValue");
        Row row = NativeElasticSearchUtils.createRow(values, documentId, header);
        String primaryKeyValue = (String) row.getValue(primaryKeyItem);

        assertEquals(primaryKeyValue, documentId);
    }

    public void testCreateRowWithParsableDates() throws Exception {
        SelectItem item1 = new SelectItem(new MutableColumn("value1", ColumnType.STRING));
        SelectItem item2 = new SelectItem(new MutableColumn("value2", ColumnType.DATE));
        List<SelectItem> selectItems1 = Arrays.asList(item1, item2);
        String documentId = "doc1";
        DataSetHeader header = new SimpleDataSetHeader(selectItems1);
        Map<String, Object> values = new HashMap<>();
        values.put("value1", "theValue");
        values.put("value2", "2013-01-04T15:55:51.217+01:00");
        Row row = NativeElasticSearchUtils.createRow(values, documentId, header);
        Object stringValue = row.getValue(item1);
        Object dateValue = row.getValue(item2);

        assertTrue(stringValue instanceof String);
        assertTrue(dateValue instanceof Date);
    }
}


text:
package qa.tools.ikeeper.test.base;

import org.junit.Rule;

import qa.tools.ikeeper.client.BugzillaClient;
import qa.tools.ikeeper.test.IKeeperJUnitConnector;

public class BZTestBase {

    @Rule
    public IKeeperJUnitConnector issueKeeper;

    public BZTestBase() {
        issueKeeper = new IKeeperJUnitConnector(new BugzillaClient("https://bugzilla.redhat.com"));
    }

}


text:
package metrics

import (
	"io"
	"net"
	"sync"
	"time"

	gometrics "github.com/coreos/etcd/third_party/github.com/rcrowley/go-metrics"
)

const (
	// RuntimeMemStatsSampleInterval is the interval in seconds at which the
	// Go runtime's memory statistics will be gathered.
	RuntimeMemStatsSampleInterval	= time.Duration(2) * time.Second

	// GraphitePublishInterval is the interval in seconds at which all
	// gathered statistics will be published to a Graphite endpoint.
	GraphitePublishInterval	= time.Duration(2) * time.Second
)

type standardBucket struct {
	sync.Mutex
	name		string
	registry	gometrics.Registry
	timers		map[string]Timer
	gauges		map[string]Gauge
}

func newStandardBucket(name string) standardBucket {
	registry := gometrics.NewRegistry()

	gometrics.RegisterRuntimeMemStats(registry)
	go gometrics.CaptureRuntimeMemStats(registry, RuntimeMemStatsSampleInterval)

	return standardBucket{
		name:		name,
		registry:	registry,
		timers:		make(map[string]Timer),
		gauges:		make(map[string]Gauge),
	}
}

func (smb standardBucket) Dump(w io.Writer) {
	gometrics.WriteOnce(smb.registry, w)
	return
}

func (smb standardBucket) Timer(name string) Timer {
	smb.Lock()
	defer smb.Unlock()

	timer, ok := smb.timers[name]
	if !ok {
		timer = gometrics.NewTimer()
		smb.timers[name] = timer
		smb.registry.Register(name, timer)
	}

	return timer
}

func (smb standardBucket) Gauge(name string) Gauge {
	smb.Lock()
	defer smb.Unlock()

	gauge, ok := smb.gauges[name]
	if !ok {
		gauge = gometrics.NewGauge()
		smb.gauges[name] = gauge
		smb.registry.Register(name, gauge)
	}

	return gauge
}

func (smb standardBucket) Publish(graphite_addr string) error {
	addr, err := net.ResolveTCPAddr("tcp", graphite_addr)
	if err != nil {
		return err
	}

	go gometrics.Graphite(smb.registry, GraphitePublishInterval, smb.name, addr)

	return nil
}


text:
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="JCobyla">
    <!--bannerLeft>
    </bannerLeft-->
    <!--bannerRight>
    </bannerRight -->
    <body>
        <breadcrumbs>
            <item name="Xypron" href="http://www.xypron.de/" />
            <item name="Projects" href="http://www.xypron.de/projects/" />
            <item name="JCobyla" href="./index.html" />
        </breadcrumbs>
        <menu name="Overview" inherit="top">
            <item name="About" href="index.html" collapse="true">
            </item>
        </menu>
        <menu name="Documentation">
            <item name="Javadoc" href="apidocs/index.html" />
        </menu>
        <menu ref="parent" inherit="top"/>
        <menu ref="modules" inherit="top"/>
        <menu ref="reports" inherit="top"/>
    </body>
    <!--poweredBy>
    </poweredBy-->
</project>


text:
title:    "Changelog"
layout:   nil
version:  1.1
---
Cleared up the project's licensing.  [BSD][], all the way.

[BSD]:  http://github.com/mikewest/jslint-utils/blob/master/LICENSE.markdown


text:
<template name="channel">

<meta name="viewport" content="width=device-width, initial-scale=1.0">
    {{#with channel}}

{{title}}

          {{#if isModerator}}
            {{> qrCode }}
          {{/if}}

{{query}}

            {{#with nextS}}

Up next.. {{title}}

            {{/with}}

          {{> searchBox}}{{> suggestionModal}}{{#if isModerator}}
            {{> prepopulate }}
          {{/if}}

          {{> sourceSelect}}

      {{#with currentSong}}

        <meta name="viewport" content="width=device-width, initial-scale=1.0">

          {{#if isModerator}}
            {{> Moderator videoId=videoID source=source thumbnail=thumbnail}}
          {{else}}

          {{/if}}

              <meta name="viewport" content="width=device-width, initial-scale=1.0">

{{title}}

Currently Playing:
{{title}}

      {{/with}}

      {{#each getRecent}}

      {{/each}}

Upcoming Songs

    {{#if getQueue}}

      {{#each getQueue}}

[ {{votes}} ] {{title}}

              {{#if isModerator}}
                <input id="removeNow" type="button" value="X" style="width: 50px;"/>
              {{/if}}
              <input id="upvoteButton" type="button" value="/\" style="width: 50px;"/>
              <input id="downvoteButton" type="button" value="\/" style="width: 50px;"/>
              {{#if isModerator}}
                <input id="playNow" type="button" value="PLAY" style="width: 50px;"/>
              {{/if}}

    {{/each}}
  {{/if}}

	{{/with}}

</template>

<template name="sourceSelect">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
  <select id="src" class="dropdown" style="margin-top: 15px;">
    <option value="youtube">YouTube</option>
    <option value="soundcloud">SoundCloud</option>
  </select>
</template>

<template name="qrCode">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
  <button type="button" class="socialbutton">QR Code</button>

      {{> QrCode text=getCurrentUrl }}

</template>

<template name="searchBox">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

  <input type="text" class="search" id="search-box" placeholder="search youtube here">

  {{#each getSearchResults}}

          {{#if isYoutube}}

          {{else}}

          {{/if}}

          {{#if isYoutube}}

{{snippet.title}}

          {{else}}

{{title}}

          {{/if}}

    {{/each}}

</template>

<template name="prepopulate">
	<button type="button" id="populate-button" class="suggestionButton">Populate Queue</button>
</template>

<template name="suggestionModal">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<button type="button" id="largeCreate" class="suggestionButton" data-toggle="modal" data-target="#myModal2">Song Suggestions</button>

        <button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>

Suggested Songs

  			{{#each getRecSearchResults}}

{{snippet.title}}

    		{{/each}}

</template>

<template name="Moderator">

  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  {{#unless isYoutube source}}{{/unless}}

    <input id="playPauseButton" class="playskip" type="button" value="Pause"/>
    <input id="skipButton" class="playskip" type="button" value="Skip"/>
    <input id="CloseRoom" type="button" class="playskip" value="Close Room">

  {{#if isYoutube source}}

  {{else}}

  {{/if}}

</template>


text:
@interface MOBProjectionEPSG4312 : MOBProjection

@end


text:
#if !defined(MBED_CONF_NSAPI_PRESENT)
#error [NOT_SUPPORTED] A json configuration file is needed. Skipping this build.
#endif

#include "CellularUtil.h" // for CELLULAR_ helper macros
#include "CellularTargets.h"

#ifndef CELLULAR_DEVICE
#error [NOT_SUPPORTED] CELLULAR_DEVICE must be defined
#endif

#ifndef MBED_CONF_APP_CELLULAR_SIM_PIN
#error [NOT_SUPPORTED] SIM pin code is needed. Skipping this build.
#endif

#include "greentea-client/test_env.h"
#include "unity.h"
#include "utest.h"

#include "mbed.h"

#include "AT_CellularInformation.h"
#include "CellularConnectionFSM.h"
#include "CellularDevice.h"
#include "../../cellular_tests_common.h"

#define SIM_TIMEOUT (180*1000)

static UARTSerial cellular_serial(MDMTXD, MDMRXD, MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE);
static EventQueue queue(2 * EVENTS_EVENT_SIZE);
static CellularConnectionFSM cellular;
static CellularConnectionFSM::CellularState cellular_target_state;
static rtos::Semaphore fsm_semaphore(0);

static bool fsm_callback(int state, int next_state)
{
    if (next_state == CellularConnectionFSM::STATE_SIM_PIN) {
        TEST_ASSERT(fsm_semaphore.release() == osOK);
        return false;
    }
    return true;
}

static void init_to_sim_state()
{
    cellular.set_serial(&cellular_serial);
    TEST_ASSERT(cellular.init() == NSAPI_ERROR_OK);
#if defined (MDMRTS) && defined (MDMCTS)
    cellular_serial.set_flow_control(SerialBase::RTSCTS, MDMRTS, MDMCTS);
#endif
    cellular.set_callback(&fsm_callback);
    TEST_ASSERT(cellular.start_dispatch() == NSAPI_ERROR_OK);
    cellular_target_state = CellularConnectionFSM::STATE_SIM_PIN;
    TEST_ASSERT(cellular.continue_to_state(cellular_target_state) == NSAPI_ERROR_OK);
    TEST_ASSERT(fsm_semaphore.wait(SIM_TIMEOUT) == 1);
}

static void test_information_interface()
{
    CellularInformation *info = cellular.get_device()->open_information(&cellular_serial);
    const int kbuf_size = 100;
    char *buf = (char *)malloc(sizeof(char) * kbuf_size);

    TEST_ASSERT(info->get_manufacturer(buf, kbuf_size) == NSAPI_ERROR_OK);
    TEST_ASSERT(info->get_model(buf, kbuf_size) == NSAPI_ERROR_OK);
    TEST_ASSERT(info->get_revision(buf, kbuf_size) == NSAPI_ERROR_OK);
    TEST_ASSERT((info->get_serial_number(buf, kbuf_size, CellularInformation::SN) == NSAPI_ERROR_OK) ||
               ((((AT_CellularInformation *)info)->get_device_error().errType == 3) &&    // 3 == CME error from the modem
               (((AT_CellularInformation *)info)->get_device_error().errCode == 4)));     // 4 == "operation not supported"

    nsapi_error_t err = info->get_serial_number(buf, kbuf_size, CellularInformation::IMEI);
    TEST_ASSERT(err == NSAPI_ERROR_UNSUPPORTED || err == NSAPI_ERROR_OK);

    err = info->get_serial_number(buf, kbuf_size, CellularInformation::IMEISV);
    TEST_ASSERT(err == NSAPI_ERROR_UNSUPPORTED || err == NSAPI_ERROR_OK);

    err = info->get_serial_number(buf, kbuf_size, CellularInformation::SVN);
    TEST_ASSERT(err == NSAPI_ERROR_UNSUPPORTED || err == NSAPI_ERROR_OK);

    cellular.get_device()->close_information();

    free(buf);
}

using namespace utest::v1;

static utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason)
{
    greentea_case_failure_abort_handler(source, reason);
    return STATUS_ABORT;
}

static Case cases[] = {
    Case("CellularInformation init", init_to_sim_state, greentea_failure_handler),
    Case("CellularInformation test interface", test_information_interface, greentea_failure_handler)
};

static utest::v1::status_t test_setup(const size_t number_of_cases)
{
    GREENTEA_SETUP(10 * 60, "default_auto");
    return verbose_test_setup_handler(number_of_cases);
}

static Specification specification(test_setup, cases);

int main()
{
#if MBED_CONF_MBED_TRACE_ENABLE
    trace_open();
#endif
    int ret = Harness::run(specification);
#if MBED_CONF_MBED_TRACE_ENABLE
    trace_close();
#endif
    return ret;
}