SI-7345 Represent the boolean modes in Context in ContextMode.

 - This is a value class in the same spirit of Mode.
 - Code that temporarily changes mode can be simplified
   by saving and restoring this one field.
SI-7345 Rationalize overloads of Context#make

Used default arguments and removed of variations only used
in one place.

I couldn't eliminate them all: one remaining overload avoids
allocating a new context when the scope/owner/tree don't change,
but moving this optimizatin to the primary overload of make breaks
things. This is noted in a TODO comment.
SI-7345 Remove comment that appears obsolete.

Obsolete since ee02ad59c, as best as I can judge.
SI-7345 Use combinator to find next enclosing non-template.
SI-7345 Add Context#isLocal, akin to Symbol#isLocal

Out with the old, in with the new. `isLocal()`, which
has been removed, was unused. `isLocal`, the new entry,
has the same semantics as `Symbol#isLocal`.
SI-7345 Encapsulate warning and error buffers in ReportBuffer.

  - merge `Context#{buffer, warningBuffer}` into `Context#reportBuffer`.
  - only expose immutable copies of the error and warnings buffers
  - Introduce a convenience method, `firstError`.
  - replace `condBufferFlush` more specific methods to retain or
    clear errors by error kind.
SI-7345 Exploit named/default args
  - Collapse overloads of `rootContext`
  - make `atOwner` more concise
SI-7345 More refactoring and documentation in Contexts

  - Use `firstError match {}` rather than `if (c.hasErrors) c.firstError ..`
  - Convert implementation comments to doc comments
  - Add new doc comments
  - Refactor `Context#make` for better readability.
  - Note a few TODOs.
  - Roughly delineate the internal structure of Contexts with comments.
  - Combine `mode` and `state` methods into `contextMode`.
  - Move `isNameInScope` closer to its compadres.
  - Improving alignment, tightening access.
SI-7345 Prefer using a throwaway silent context over buffer flushing.

When we are using a throwaway silent context, we can just let it drift out of
scope and over the horizon, rather than ceremoniously flushing its buffers
on completion.

 - Applied to Scaladoc.
 - Applied to Infer#isApplicableSafe. Less manual error buffer management
   affords greater opportunity to cleanly express the logic.
 - Applied to `typerReportAnyContextErrors`.

The reasoning for the last case is as follows:

 - There were only two callers to `typerReportAnyContextErrors`, and
   they both passed in as `c` a child context of `context`.
 - That child context must share the error reporting mode and buffer
   with `context`.
 - Therefore, extracting an error from `c` and issuing it into `context`
   is a no-op. Because the error buffer is Set, it was harmless.

This part will probably textually conflict with the same change made in
SI-7319, but the end results are identical.
SI-7345 remove unused methods.
SI-7345 Move `inSilentMode` from Infer to Context.
SI-7345 Refactor manual iteration to use foreach.
SI-7345 Produce Context#imports from the context chain

Rather than keeping a List[ImportInfo] around as a field.

This sort of change reduces our bug exposure by structurally
enforcing the invariant that `Context#imports` must mirror
the `outer` chain.

This entails changing a few elements of Contexts from mutable
vars to constructor pararameters, which seems desirable anyway.

We no longer need `makeNewImport`, as `make` now inspects
the provided tree and determines does import specific things
(tracking of used imports / mixin of ImportContext) when
appropriate.

The only wrinkle in this commit is the unfortunate need to pass
`owner = null` in the extends clause of NoContext. I don't see
cleaner way around this.

Applied minor rework to `implicitss` to avoid needlessly re-evaluating
`imports` and `nextOuter`.
SI-7345 Doc and TODO comments around Context.
SI-7345 Remove unneeded warning.

According to Hubert, during normal operation we can start buffering
errors in a context with existing errors. So the warning would be noisy.
SI-7345 Factor out method to clear and restore undetparams.

Also refactored `handleOverloaded` to avoid use of a mutable Buffer
SI-7345 Drive by refactoring of pattern matching for `arg: _*`.
SI-7345 Eliminate the `depth` var.

In favour of a val calculated during construction. Internalizes
the depth calculation into the Context constructor rather than
leaving it in the hands of the factory method `make`.

Also touched a few unrelated doc comments.
SI-7345 Improved Context.toString

    ticket/7345-2 ~/code/scala qbin/scala
    Welcome to Scala version 2.11.0-20130416-231609-7829011884 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_37).
    Type in expressions to have them evaluated.
    Type :help for more information.

    scala> import language.experimental._import language.experimental._

    scala> import reflect.macros.Contextimport reflect.macros.Context

    scala> def showContextImpl(c: Context) = {println(c.asInstanceOf[reflect.macros.runtime.Context].callsiteTyper.context.enclosingContextChain.mkString("\n\n")); c.literalUnit}
    showContextImpl: (c: scala.reflect.macros.Context)c.Expr[Unit]

    scala> def showContext = macro showContextImpldefined term macro showContext: Unit

    scala> object Foo { def foo(a: Any) { {class C { println("") }; showContext } } }Context(<console>) {
       owner       = method foo
       tree        = Block:{ class C extends scala.AnyRef { def <init>(): C = { super.<init>(); (
       scope       = 1 decls
       contextMode = AmbiguousErrors ImplicitsEnabled MacrosEnabled ReportErrors
       outer.owner = method foo
    }

    Context(<console>) {
       owner       = method foo
       tree        = DefDef:def foo(a: Any): Unit = { class C extends scala.AnyRef { def <init>():
       scope       = 1 decls
       contextMode = AmbiguousErrors ImplicitsEnabled MacrosEnabled ReportErrors
       outer.owner = object Foo
    }

    Context(<console>) {
       owner       = object Foo
       tree        = Template(scala.AnyRef, _, 2 stats)
       scope       = 0 decls
       contextMode = AmbiguousErrors ImplicitsEnabled MacrosEnabled ReportErrors
       outer.owner = object Foo
    }

    Context(<console>) {
       owner       = object Foo
       tree        = ModuleDef:object Foo extends scala.AnyRef { def <init>(): Foo.type = { super.<in
       scope       = 0 decls
       contextMode = AmbiguousErrors ImplicitsEnabled MacrosEnabled ReportErrors
       outer.owner = object $iw
    }

    Context(<console>) {
       owner       = object $iw
       tree        = Template(scala.AnyRef, _, 2 stats)
       scope       = 0 decls
       contextMode = AmbiguousErrors ImplicitsEnabled MacrosEnabled ReportErrors
       outer.owner = object $iw
    }

    Context(<console>) {
       owner       = object $iw
       tree        = ModuleDef:object $iw extends scala.AnyRef { def <init>(): type = { super.<init>(
       scope       = 0 decls
       contextMode = AmbiguousErrors ImplicitsEnabled MacrosEnabled ReportErrors
       outer.owner = object $iw
    }

    ImportContext { import $line18.$read.$iw.$iw.$iw.$iw.showContext; outer.owner = object $iw }

    ImportContext { import $line17.$read.$iw.$iw.$iw.$iw.showContextImpl; outer.owner = object $iw }

    ImportContext { import reflect.macros.Context; outer.owner = object $iw }

    Context(<console>) {
       owner       = object $iw
       tree        = Template(scala.AnyRef, _, 5 stats)
       scope       = 0 decls
       contextMode = AmbiguousErrors ImplicitsEnabled MacrosEnabled ReportErrors
       outer.owner = object $iw
    }

    Context(<console>) {
       owner       = object $iw
       tree        = ModuleDef:object $iw extends scala.AnyRef { def <init>(): type = { super.<init>(
       scope       = 0 decls
       contextMode = AmbiguousErrors ImplicitsEnabled MacrosEnabled ReportErrors
       outer.owner = object $iw
    }

    ImportContext { import language.experimental._; outer.owner = object $iw }

    Context(<console>) {
       owner       = object $iw
       tree        = Template(scala.AnyRef, _, 3 stats)
       scope       = 0 decls
       contextMode = AmbiguousErrors ImplicitsEnabled MacrosEnabled ReportErrors
       outer.owner = object $iw
    }

    Context(<console>) {
       owner       = object $iw
       tree        = ModuleDef:object $iw extends scala.AnyRef { def <init>(): type = { super.<init>(
       scope       = 0 decls
       contextMode = AmbiguousErrors ImplicitsEnabled MacrosEnabled ReportErrors
       outer.owner = object $iw
    }

    Context(<console>) {
       owner       = object $iw
       tree        = Template(scala.AnyRef, _, 2 stats)
       scope       = 0 decls
       contextMode = AmbiguousErrors ImplicitsEnabled MacrosEnabled ReportErrors
       outer.owner = object $iw
    }

    Context(<console>) {
       owner       = object $iw
       tree        = ModuleDef:object $iw extends scala.AnyRef { def <init>(): type = { super.<init>(
       scope       = 0 decls
       contextMode = AmbiguousErrors ImplicitsEnabled MacrosEnabled ReportErrors
       outer.owner = object $read
    }

    Context(<console>) {
       owner       = object $read
       tree        = Template(scala.AnyRef, _, 2 stats)
       scope       = 0 decls
       contextMode = AmbiguousErrors ImplicitsEnabled MacrosEnabled ReportErrors
       outer.owner = object $read
    }

    Context(<console>) {
       owner       = object $read
       tree        = ModuleDef:object $read extends scala.AnyRef { def <init>(): $line19.$read.type =
       scope       = 1 decls
       contextMode = AmbiguousErrors ImplicitsEnabled MacrosEnabled ReportErrors
       outer.owner = package $line19
    }

    Context(<console>) {
       owner       = package $line19
       tree        = PackageDef:package $line19 { object $read extends scala.AnyRef { def <init>(): $l
       scope       = 1 decls
       contextMode = AmbiguousErrors ImplicitsEnabled MacrosEnabled ReportErrors
       outer.owner = package <root>
    }

    Context(<console>) {
       owner       = package <root>
       tree        = EmptyTree:<empty>
       scope       = 50 decls
       contextMode = AmbiguousErrors ImplicitsEnabled MacrosEnabled ReportErrors
       outer.owner = package <root>
    }

    ImportContext { import scala.this.Predef._; outer.owner = package <root> }

    ImportContext { import scala._; outer.owner = package <root> }

    ImportContext { import java.this.lang._; outer.owner = package <root> }

    Context(NoCompilationUnit) {
       owner       = package <root>
       tree        = Template(Nil, _, 0 stats)
       scope       = 50 decls
       contextMode = MacrosEnabled
       outer.owner = <none>
    }
    defined object Foo
SI-7345 Address review comments.