Removes isDefined-get instance
Merge pull request #557 from skyluc/issue/bad-is-defined-match

Removes isDefined-get instance
Removed uneeded locking in `ScalaProject.failedCompilerInitialization`

The reason why we were using the instance locking was to avoid showing several
times the message dialog that occurs when the presentation compiler fails to
initialize.

If you look closely, you will notice that the lock is simply used to make sure
the update of the field `messageShowed` is atomic. Therefore, it is only
natural to replace the lock usage with an `AtomicBoolean` which has very handy
operation for atomically setting its content, and returning the old value.
Fixed race condition during presentation compiler restart

* In the former implementation, if a request to restart the presentation
  compiler was executed (concurrently) while the presentation compiler was being
  initialized, the reset request could get lost. This was the reason for
  flackyness of the hyperlinking test `HyperlinkDetectorTests.test1000656`.
  To prove this commit fixes the issue described above, I've reverted
  SHA: 35091aebfa2785a192742407003ce1064b20a784.

* This new implementation guarantes that:

  1) `askRestart` requests are never lost.
  2) If a call to `apply` is executed *after* an `askRestart` (by the same
     thread), the execution of the `apply` is guaranteed to be performed after
     the presentation compiler is reinitialized.

  In general, I believe it guarantees happens before semantic (see
  http://en.wikipedia.org/wiki/Happened-before).

* Created a `ScalaPresentationCompilerProxy` that is responsible of handling
  the presentation compiler's lifecycle. Interestingly, this new abstraction
  allows for further refinements. For instance, it should be much simpler now to
  add the logic for automatically shutting down a presentation compiler when it is
  not being used for some time (the net effect would be to reduce the memory
  footprint when a user has several opened Scala projects).

* Deleted `Cached` as it is now superseeded by `ScalaPresentationCompilerProxy`.

* Never shutdown the presentation compiler in the middle of a test run. If you
  need to reinitialize the state of the presentation compiler, `askRestart`
  should be called instead of `shutdown`. The reason is that when calling
  `shutdown`, the presentation compiler dumps all queued work items, and this
  can lead to lost updates.
  On the other hand, for test isolation reasons, it is absolutely fine to shutdown
  the presentation compiler *before*/*after* a test is executed.

* Deprecated `doWithPresentationCompiler` and `withPresentationCompiler` in
  ScalaProject. ScalaProject's methods `doWithPresentationCompiler` and
  `withPresentationCompiler` are superseeded by `presentationCompiler.apply`. The
  main reason for doing so is that I don't think it is useful to have ARM methods
  when the used resource is publicly accessible (i.e., the `presentationCompiler`
  field).
  While doing this refactoring, I noticed we need a 'null object' of a `Response`
  (look at `ScalaSourceFile.scheduleReconcile()`).  The only alternative to
  returning a 'null object' is to throw an exception, which I don't think is the
  right solution in this case. Unfortunately, creating a 'null object' for
  `Response` is currently cumbersome because `Response` is a concrete class, and
  not an interface. Hence, I'm deferring this further refactoring to a different
  pull request.

* Changed `InteractiveCompilationUnit.withSourceFile` return type to `Option`.
  This was needed after deprecating `ScalaProject.defaultOrElse`. Moreover, it
  makes sense as it matches the signature of
  `ScalaPresentationCompilerProxy.apply`, which is the underlying method being
  called.

Fixes #1001880
Re #1001875
Re #1001911