Commit Graph

3667 Commits

Author SHA1 Message Date
William Benton 5df24e5eb2 Update documentation references to Ivy 2.3.0 2013-12-13 14:25:56 -06:00
William Benton 3a1ad44c45 Support Ivy 2.3.0-final.
This entailed modifying ResolutionCache and the CustomPomParser
to reflect changes to the ResolutionCacheManager interface and
DefaultExtendsDescriptor class between Ivy 2.3.0-rc1 and
2.3.0-rc2. Specifically,

1. ResolutionCacheManager now includes two additional methods
that needed implementations in ResolutionCache:
getResolvedModuleDescriptor(mrid: ModuleRevisionId) and
saveResolvedModuleDescriptor(md: ModuleDescriptor). I adapted
the implementations for these (which are expressed primarily in
terms of other interface methods) from Ivy 2.3.0's
DefaultResolutionCacheManager.

2. Instead of taking a ModuleRevisionIdentifier and a resolved
ModuleRevisionIdentifier as its first two arguments, the
DefaultExtendsDescriptor constructor now takes a
ModuleDescriptor. This was a trivial change.

Note that ResolutionCache.getResolvedModuleDescriptor does not
appear to be used by Ivy as sbt uses Ivy and there is thus no
test coverage for its implementation. Also note that the
DefaultResolutionCacheManager object created in
Update.configureResolutionCache now requires a reference to an
IvySettings object; DRCM expects this to be non-null.
2013-12-13 14:24:37 -06:00
Mark Harrah b09cf5b5e7 Fixes #1035 by catching the format error and returning the erased type as a backup.
Review by @gkossakowski.
2013-12-13 14:04:31 -05:00
Mark Harrah 05695824a5 test case for #1035 2013-12-13 14:04:18 -05:00
Mark Harrah 06deda06af Reorganized/commented proguard build configuration.
Review by @jsuereth.
2013-12-13 10:33:07 -05:00
Josh Suereth 8f22d7d580 Merge pull request #1037 from jsuereth/wip/launcher-improvements
Minor launcher improvements
2013-12-12 07:30:30 -08:00
Josh Suereth ff71bca75c Drop some of the stack size of the launcher.
* Remove needless chained methods
* Attempt to create re-usable parsing methods.
2013-12-12 10:16:48 -05:00
Josh Suereth cfe14444b8 Document ComponentProvider interface. 2013-12-12 09:51:58 -05:00
Mark Harrah 0c62483e74 launchconfigs for version bump 2013-12-10 11:59:51 -05:00
Mark Harrah 82dcf8d250 delete dependency-management/inherit-repo test
repository used in the test doesn't exist anymore and project delegation is deprecated
2013-12-10 11:59:29 -05:00
Mark Harrah 48fb98f2d1 0.13.1 2013-12-10 10:18:42 -05:00
Mark Harrah 90143986e4 Test for #1031 2013-12-10 08:40:37 -05:00
Mark Harrah c669606999 TaskKey[T].previous: Option[T], which returns the value of the task the last time it executed.
This requires a Format[T] to be implicitly available at the call site and requires the task
to be referenced statically (not in a settingDyn call).  References to previous task values
in the form of a ScopedKey[Task[T]] + Format[T] are collected at setting load time in the
'references' setting.  These are used to know which tasks should be persisted (the ScopedKey)
and how to persist them (the Format).

When checking/delegating previous references, rules are slightly different.

A normal reference from a task t in scope s cannot refer to t in s unless
there is an earlier definition of t in s.  However, a previous reference
does not have this restriction.  This commit modifies validateReferenced
to allow this.

TODO: user documentation
TODO: stable selection of the Format when there are multiple .previous calls on the same task
TODO: make it usable in InputTasks, specifically Parsers
2013-12-06 20:45:01 -05:00
Mark Harrah 5d49fcbe78 Include the key name in the streams backing file path to avoid collisions. 2013-12-06 20:43:48 -05:00
Mark Harrah a677448a6c Fix closeable streams to recreate streams for a key if the delegate was closed. 2013-12-06 20:43:48 -05:00
Mark Harrah 21a05978de Fix parsing and evaluation of 'all' and 'show'. See comment in evaluatingParser. 2013-12-06 20:43:48 -05:00
Mark Harrah 140ce04809 Fix #1024. Use log.debug instead of println in TrapExit. 2013-12-05 12:00:00 -05:00
Mark Harrah d8c15bb80e Merge remote-tracking branch 'gkossakowski/compute-name-hashes' into 0.13 2013-12-05 08:53:50 -05:00
Heikki Vesalainen 2cb4ed370c added sbt-mode to Community-Plugins 2013-12-05 08:14:02 -05:00
Grzegorz Kossakowski 50528e6000 Push down `toString` implementation in Relations hierarchy.
Each of Relations implementation should have specific `toString`
implementation. For example, only `MRelationsNameHashing` implementation
should be printing used names in toString representation.
2013-12-05 08:00:13 +01:00
Grzegorz Kossakowski 993aa5b26f Access `Relations.names` conditionally in TextAnalysisFormat
The `Relations.name` is available only when name hashing flag is enabled.

This fixes a regression introduced in
304796bb7a.
2013-12-05 07:49:14 +01:00
Grzegorz Kossakowski 1bbbbb38c9 Get rid of MurmurHash.finalizeHash import in HashAPI.
That import is shadowed by the local definition of `finalizeHash`
introduced to HashAPI class.
2013-12-04 12:50:29 +01:00
Grzegorz Kossakowski fa220f372a Add overloaded constructor to HashAPI for backwards compatibility.
Add a variant of constructor to `HashAPI` that is binary and source
backwards compatible with sbt 0.13.0.
2013-12-04 12:49:15 +01:00
Grzegorz Kossakowski a9a709ccc0 Add hashing of public names defined in a source file.
A hash for given name in a source file is computed by combining
hashes of all definitions with given name. When hashing a single
definition we take into account all information about it except nested
definitions. For example, if we have following definition

class Foo[T] {
  def bar(x: Int): Int = ???
}

hash sum for `Foo` will include the fact that we have a class with
a single type parameter but it won't include hash sum of `bar` method.

Computed hash sums are location-sensitive. Each definition is hashed along
with its location so we properly detect cases when definition's signature
stays the same but it's moved around in the same compilation unit.

The location is defined as sequence of selections. Each selection consists
of a name and name type. The name type is either term name or type name.
Scala specification (9.2) guarantees that each publicly visible definition
is uniquely identified by a sequence of such selectors.

For example, if we have:

object Foo {
  class Bar { def abc: Int }
}

then location of `abc` is Seq((TermName, Foo), (TypeName, Bar))

It's worth mentioning that we track name-hash pairs separately for
regular (non implicit) and implicit members. That's required for name
hashing algorithm because it does not apply its heuristic when implicit
members are being modified.

Another important characteristic is that we include all inherited members
when computing name hashes.

Here comes the detailed list of changes made in this commit:

  * HashAPI has new parameter `includeDefinitions` that allows
    shallow hashing of Structures (where we do not compute hashes
    recursively)
  * HashAPI exposes `finalizeHash` method that allow one to capture
    current hash at any time. This is useful if you want to hash a list of
    definitions and not just whole `SourceAPI`.
  * NameHashing implements actual extraction of public definitions,
    grouping them by simple name and computing hash sums for each group
    using HashAPI
  * `Source` class (defined in interface/other file) has been extended to
    include `_internalOnly_nameHashes` field. This field stores
    NameHashes data structure for given source file. The NameHashes
    stores two separate collections of name-hash pairs for regular and
    implicit members.
    The prefix `_internalOnly_` is used to indicate that this is not an
    official incremental compiler's or sbt's API and it's for use by
    incremental compiler internals only. We had to use such a prefix
    because the `datatype` code generator doesn't support emitting access
    modifiers
  * `AnalysisCallback` implementation has been modified to gather all
    name hashes and store them in the Source object
  * TestCaseGenerators has been modified to implement generation of
    NameHashes
  * The NameHashingSpecification contains a few unit tests that make sure
    that the basic functionality works properly
2013-12-04 01:34:18 +01:00
Grzegorz Kossakowski ec40eab92d Merge pull request #1013 from gkossakowski/used-names-extraction
Used names extraction logic
2013-12-03 03:30:21 -08:00
Grzegorz Kossakowski 304796bb7a Add support for tracking names used in Scala source files.
Tracking of used names is a component needed by the name hashing
algorithm. The extraction and storage of used names is active only when
`AnalysisCallback.nameHashing` flag is enabled and it's disabled by
default.

This change constists of two parts:

  1. Modification of Relations to include a new `names` relation
     that allows us to track used names in Scala source files
  2. Implementation of logic that extracts used names from Scala
     compilation units (that correspond to Scala source files)

The first part is straightforward: add standard set of methods in
Relations (along with their implementation) and update the logic which
serializes and deserializes Relations.

The second part is implemented as tree walk that collects all symbols
associated with trees. For each symbol we extract a simple, decoded name
and add it to a set of extracted names. Check documentation of
`ExtractUsedNames` for discussion of implementation details.

The `ExtractUsedNames` comes with unit tests grouped in
`ExtractUsedNamesSpecification`. Check that class for details.

Given the fact that we fork while running tests in `compiler-interface`
subproject and tests are ran in parallel which involves allocating
multiple Scala compiler instances we had to bump the default memory limit.

This commit contains fixes for gkossakowski/sbt#3, gkossakowski/sbt#5 and
gkossakowski/sbt#6 issues.
2013-12-03 12:27:29 +01:00
Grzegorz Kossakowski cbd57040ad Merge pull request #1019 from gkossakowski/scala-2.11-compat
Make incremental compiler compatible with Scala 2.11.
2013-12-02 09:37:27 -08:00
Grzegorz Kossakowski 7e303f8692 Add more documentation to Compat class in compiler interface.
Add documentation which explains how a general technique using implicits
conversions is employed in Compat class. Previously, it was hidden inside
of Compat class.

Also, I changed `toplevelClass` implementation to call
`sourceCompatibilityOnly` method that is designed for the purpose
of being a compatibility stub.
2013-12-02 17:55:11 +01:00
Pierre DAL-PRA 621f9dc568 Documentation : use isSnapshot setting instead of "version.value.trim.endsWith("SNAPSHOT")"
Since SBT provides the `isSnapshot` setting to check whether the current version is a snapshot version or not, I thought it could be nice to use it here instead of reimplementing it :)
2013-12-01 16:48:50 -05:00
Grzegorz Kossakowski ff9dd6e9dd Make incremental compiler compatible with Scala 2.11.
The scala/scala@2d4f0f1859 removes the
`toplevelClass` method. The recent change from
aac19fd02b introduces dependency on that
method. Combination of both changes makes incremental compiler incompatible
with Scala 2.11.

This change introduces a compatibility hack that brings back source
compatibility of incremental compiler with Scala 2.8, 2.9, 2.10 and 2.11.

The compatibility hack is making clever use implicit conversions that
can provide dummy method definitions for methods removed from Scala
compiler.

Also, the code that depends on `enclosingTopLevelClass` has been refactored
so the dependency is more centralized.
2013-11-30 13:58:03 +01:00
Dan Sanduleac 6a31b6acc4 Removed unnecessary catch for exception 2013-11-28 11:04:46 -05:00
Dan Sanduleac 9cfc7a4d91 Added test case for derived settings 2013-11-28 11:04:46 -05:00
Dan Sanduleac d740965ea1 Fix deriveAndLocal bug 2013-11-28 11:04:46 -05:00
Mark Harrah 8160dbda8a Merge remote-tracking branch 'gk/analysis-generator-fix' into 0.13 2013-11-28 11:03:16 -05:00
Alexey Alekhin a212fc68bf Added literator-plugin to the list of community plugins 2013-11-28 11:01:08 -05:00
Heejong Lee df3328edbd add sbt-antlr4 to community plugin list
add sbt-antlr4 to community plugin list
2013-11-28 11:01:01 -05:00
Grzegorz Kossakowski 88444f2b46 Fix access modifiers for newly introduced members in Relations.
We introduced some new members (related to name hashing) with an intent
to not expose them as public API. However, I missed some modifiers and
some members (like `memberRef` and `inheritance`) are public.

This commit fixes access modifiers to agree with the intent.
2013-11-28 13:49:12 +01:00
Grzegorz Kossakowski 2a3a3d0d7a Rename Relations.{memberRefAndInheritanceDeps => nameHashing}
The previous name of the flag was rather specific: it indicated
whether the new source dependency tracking is supported by given Relations
object. However, there will be more functionality added to Relations that
is specific to name hashing algorithm. Therefore it makes sense to name
the flag as just `nameHashing`.

I decided to rename Relations implementation classes to be more
consistent with the name of the flag and with the purpose they serve.

The flag in AnalysisCallback (and classes implementing it) has been
renamed as well.
2013-11-28 13:42:39 +01:00
Grzegorz Kossakowski 4b0123f9ec Merge pull request #1002 from gkossakowski/deps-by-treewalking
Extract dependencies by tree walking
2013-11-27 06:51:05 -08:00
Mark Harrah e16864f2e7 Drop Thread.getName from use in computeID(thread) in TrapExit SecurityManager to fix #997. 2013-11-27 08:53:52 -05:00
Mark Harrah ad60e6c794 Basic predicate combinators for Tags 2013-11-26 22:46:50 -05:00
Mark Harrah d38450b41f Command to run multiple tasks concurrently: 'all a b'. Fixes #628. 2013-11-26 22:46:49 -05:00
Grzegorz Kossakowski 331fffbb19 Add test for trait as a first parent scenario in dep tracking.
The documentation of `Relations.inheritance` mentions an oddity of Scala's
type checker which manifests itself in what is being tracked by that
relation in case of traits being first parent for a class/trait.

Add a test case which verifies that this oddity actually exists and it's
not harmful because it doesn't break an invariant between `memberRef`
and `inheritance` relations.
2013-11-26 18:39:24 +01:00
Grzegorz Kossakowski 2226fccd4f Test `memberRef` and `inheritance` in DependencySpecification.
Flip `memberRefAndInheritanceDeps` flag to true which allows us to
test `memberRef` and `inheritance` relations instead of `direct` and
`publicInherited` as it was previously done.

There a few changes to extracted dependencies from public members:

  * F doesn't depend on C by inheritance anymore. The dependency on
    C was coming from self type. This shows that dependencies from self
    types are not considered to be dependencies introduces by inheritance
    anymore.
  * G depends on B by member reference now. This dependency is introduced
    by applying type constructor `G.T` and expanding the result of the
    application.
  * H doesn't depend on D by inheritance anymore. That dependency was
    introduced through B which inherits from D. This shows that only
    parents (and not all base classes) are included in `inheritance`
    relation.

NOTE: The second bullet highlights a bug in the old dependency tracking
logic. The dependency on B was recorded in `publicInherited` but not in
`direct` relation. This breaks the contract which says that
`publicInherited` is a subset of `direct` relation.

This a change to dependencies extracted from non-public members:

  * C depends on A by inheritance and D depends on B by inheritance now;
    both changes are of the same kind: dependencies introduced by
    inheritance are tracked for non-public members now. This is necessary
    for name hashing correctness algorithm
2013-11-26 18:39:24 +01:00
Grzegorz Kossakowski 533a5b8c23 Add specification for extracted source dependencies.
Add specs2 specification (unit test) which documents current dependency
extraction logic's behavior. It exercises `direct` and `publicInherited`
relations.

This test is akin to `source-dependencies/inherited-dependencies` scripted
test. We keep both because this test will diverge in next commit to test
`memberRef` and `inheritance` relations.

The idea behind adding this test and then modifying the
`memberRefAndInheritanceDeps` flag so we test `memberRef` and `inheritance`
is that we can show precisely the differences between those two dependency
tracking mechanisms.
2013-11-26 18:39:23 +01:00
Grzegorz Kossakowski 2551eb2a63 Do not add source dependencies on itself.
Adding source dependency on itself doesn't really bring any value so
there's no reason to do it. We avoided recording that kind of dependencies
by performing a check in `AnalysisCallback` implementation. However, if we
have another implementation like `TestCallback` used for testing we do
not benefit from that check.

Therefore, the check has been moved to dependency phase were dependencies
are collected.
2013-11-26 18:39:23 +01:00
Grzegorz Kossakowski de1c5a4aed Add support for unit testing of extracted source dependencies.
Add `extractDependenciesFromSrcs` method to ScalaCompilerForUnitTest
class which allows us to unit test dependency extraction logic.

See the comment attached to the method that explain the details of
how it should be used.
2013-11-26 18:39:23 +01:00
Grzegorz Kossakowski 89914975e1 Refactor ScalaCompilerForUnitTesting.
Refactor ScalaCompilerForUnitTesting by introducing a new method
`extractApiFromSrc` which better describes the intent than
`compileSrc`. The `compileSrc` becomes a private, utility method.

Also, `compileSrc` method changed it's signature so it can take
multiple source code snippets as input. This functionality will
be used in future commits.
2013-11-26 18:39:23 +01:00
Grzegorz Kossakowski aac19fd02b Extract source code dependencies by tree walking.
Previously incremental compiler was extracting source code
dependencies by inspecting `CompilationUnit.depends` set. This set is
constructed by Scala compiler and it contains all symbols that given
compilation unit refers or even saw (in case of implicit search).
There are a few problems with this approach:

  * The contract for `CompilationUnit.depend` is not clearly defined
    in Scala compiler and there are no tests around it. Read: it's
    not an official, maintained API.
  * Improvements to incremental compiler require more context
    information about given dependency. For example, we want to
    distinguish between dependency on a class when you just select
    members from it or inherit from it. The other example is that
    we might want to know dependencies of a given class instead of
    the whole compilation unit to make the invalidation logic more
    precise.

That led to the idea of pushing dependency extracting logic to
incremental compiler side so it can evolve indepedently from Scala
compiler releases and can be refined as needed. We extract
dependencies of a compilation unit by walking a type-checked tree
and gathering symbols attached to them.

Specifically, the tree walk is implemented as a separate phase that
runs after pickler and extracts symbols from following tree nodes:

  * `Import` so we can track dependencies on unused imports
  * `Select` which is used for selecting all terms
  * `Ident` used for referring to local terms, package-local terms
            and top-level packages
  * `TypeTree` which is used for referring to all types

Note that we do not extract just a single symbol assigned to `TypeTree`
node because it might represent a complex type that mentions
several symbols. We collect all those symbols by traversing the type
with CollectTypeTraverser. The implementation of the traverser is inspired
by `CollectTypeCollector` from Scala 2.10. The
`source-dependencies/typeref-only` test covers a scenario where the
dependency is introduced through a TypeRef only.
2013-11-26 18:39:23 +01:00
Grzegorz Kossakowski b8371691f2 Introduce `memberRef` and `inheritance` relations.
Introduce an alternative source dependency tracking mechanism that is
needed by upcoming name hashing algorithm. This new mechanism is
implemented by introducing two new source dependency relations called
`memberRef` and `inheritance`.

Those relations are very similar to existing `direct` and
`publicInherited` relations in some subtle ways. Those differences
will be highlighted in the description below.

Dependencies between source files are tracked in two distinct
categories:

  * dependencies introduced by inheriting from a class/trait
    defined in other source file
  * dependencies introduced by referring (selecting) a member
    defined in other source file (that covers all other
    kinds of dependencies)

Due to invalidation algorithm implementation details sbt would need to
track inheritance dependencies of public classes only. Thus, we had
relation called `publicInherited`. The name hashing algorithm which
improves invalidation logic will need more precise information about
dependencies introduced by inheritance including dependencies of non-public
classes. That's one difference between `inheritance` and `publicInherited`
relations.

One surprising (to me) thing about `publicInherited` is that it includes
all base classes of a given class and not just parents. In that sense
`publicInherited` is transitive. This is a bit irregular because
everything else in Relations doesn't include transitive dependencies.

Since we are introducing new relations we have an excellent chance to
make things more regular. Therefore `inheritance` relation is
non-transitive and includes only extracted parent classes.

The access to `direct`, `publicInherited`, `memberRef` and `inheritance`
relations is dependent upon the value of `memberRefAndInheritanceDeps`
flag. Check documentation of that flag for details.

The two alternatives for source dependency tracking are implemented by
introduction of two subclasses that implement Relations trait and one
abstract class that contains some common logic shared between those two
subclasses. The two new subclasses are needed for the time being when we
are slowly migrating to the name hashing algorithm which requires
subtle changes to dependency tracking as explained above. For some time we
plan to keep both algorithms side-by-side and have a runtime switch which
allows to pick one. So we need logic for both old and new dependency
tracking to be available. That's exactly what two subclasses of
MRelationsCommon implement. Once name hashing is proven to be stable and
reliable we'll phase out the old algorithm and the old dependency tracking
logic.
2013-11-26 18:39:13 +01:00