refactor-864370: Convert date type to 'literal' format

Previously types had to be created as a subclass of an existing class
in the 'type' hierarchy. This made it hard to use and fragile, so we
have a 'literal' syntax which most of the internal types now use.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Help on running tests on server start

I frequently lookup the command to run tests just after I start the
server, so I made the server tell me when it starts.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
docs-796881: Update documentation

Signed-off-by: Joe Walker <jwalker@mozilla.com>
undelete-910690: Replace delete with set undefined

"delete foo" is bad for performance in several JS engines, in ways that
are close to inherent in the design of JavaScript, so using
"foo = undefined" in its place seems like a reasonable thing to do.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
easyview-910680: Allow creation of views without createView()

If we add a check that the input to the view → dom converter is a view
and call context.createView() if not then we can remove the calls to
context.createView from all commands.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
threadstack-691011: stack are now per 'thread' not 'class'

Previously asynchronous operations (particularly those in a loop) could
use the wrong stack data (used to explain where things went wrong).
In general we should clone class data when we go async, which makes the
class structure here a problem.

So this patch does a number of things:
* It converts function names from Templater.prototype._funcName to
  funcName, and removes the class structure which wasn't used properly
* It adds a 'state' parameter to the start of most functions which does
  the equivalent of 'this' but is easily cloned
* When we act asynchronously, the state is cloned for use in the callback
* It adds a cloneState function to help with this state cloning
* It inlines a number of regexp definitions which were just separated
  from where they were used, talking to JimB it seems that this is not a
  useful performance optimisation, and it made the code less readable.
* It adds a number of blank lines at the start to keep the error line
  numbers in sync with other implementations (i.e. firefox) which have
  a longer module header.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
descratch-911455: Remove open scratchpad function

We've never used it, and now the integration with Firefox is changing
so the UI is handled differently we're not going to use it here.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Use 'object literal' format for commands

Move the help and pref commands to use the 'object literal' format. I'm
doing this now because I want to make the help command select html or
string output at runtime rather than as a result of what modules are
used, and this refactor will make that change easier.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
jsterm-911456: Adding missing this in error case

The code that handles cases when we force execute invalid code was
missing a ".bind(this)". This was not a problem for GCLI previously
because we didn't allow force execution of invalid code.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
jsterm-911456: Move getCompleterTemplateData to Requisition

The generic information about how to mark-up a user interface is
separate from the UI itself, so we promote getCompleterTemplateData to
Requisition so it can be shared by other UIs.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
jsterm-911456: Add stringView converter

Previously when we wanted to format something for string output (e.g.
when in NodeJS) we needed to inject a custom template which rendered to
string better. This made the output style something that was selected by
the configuration. This change adds a new stringView converter that
allows separate converters for string and dom output.

We use this to move the custom templates for help from server to gcli
which makes the help command usable from JSTerm.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
jsterm-911456: Make Output serializable to JSON

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Remove assignment.paramIndex

It wasn't actually used.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Minor tweaks

The Eclipse/Orion build system doesn't like trailing commas.
Removed some documentation that was there by cut and paste.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Use 'rank' to describe a chosen prediction

getPredictionAt() was confusing because at implies a location, and this
is just about which of the predictions has been chosen. Worse there is
a location (that of the cursor) to confuse things. Worse still, we had
a number of words to describe this: 'at', 'index', 'predictionChoice',
and 'choice'. Now we use 'rank' for everything.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
jsterm-911456: getStateData doesn't need 'typed'

getStateData was part of completion and it was easy to get the current
input from the element itself, but now it's part of requisition, which
has its own copy of this data we shouldn't pass it in.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
easyexec-767340: Export Requisition from gcli.jsm

Requisition was not exported from gcli.jsm because it's not considered
a 'stable' API, but we needed to use it a lot and it's hard to get at.

While it's not stable in that it is likely to change it's not too
unstable for use within Firefox developer tools, so it is OK to have
it exported from the JSM. Clearly difficulty to access isn't stopping us
accessing it when needed.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Re-order Requisition functions

Requisition was getting less and less logical in how the functions were
ordered and it was getting hard to know where to look. The order is
now, roughly: setup/shutdown, getters, setters, mutators, update, exec

Also removed unused: cloneAssignments()

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Move uncalled assert into tests and call it

Requisition._assertArgsAssigned wasn't used, but it's an invariant that
we should check more often, so move it to the test suite where we can
call it on each update.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
jsterm-911456: getStateData should return a promise

Previously it returned a object that contained both read data and
promises. All the promises were waiting for the same thing so we could
easily return a single promise instead.

We're doing this because we need to remote this function so the data
that it returns needs to be JSON or a promise of JSON, and there isn't
a great upside to the more complex way of doing things - only really
that we could display input markup directly before we knew about
predictions.

Signed-off-by: Joe Walker <jwalker@mozilla.com>