Commit Graph

66 Commits

Author SHA1 Message Date
Grzegorz Kossakowski 4b43110a2c Represent api changes as values and cleanup APIChanges class.
The main motivation behind this commit is to reify information about
api changes that incremental compiler considers. We introduce a new
sealed class `APIChange` that has (at the moment) two subtypes:

  * APIChangeDueToMacroDefinition - as the name explains, this represents
    the case where incremental compiler considers an api to be changed
    just because given source file contains a macro definition
  * SourceAPIChange - this represents the case of regular api change;
    at the moment it's just a simple wrapper around value representing
    source file but in the future it will get expanded to contain more
    detailed information about API changes (e.g. collection of changed
    name hashes)

The APIChanges becomes just a collection of APIChange instances.
In particular, I removed `names` field that seems to be a dead code in
incremental compiler. The `NameChanges` class and methods that refer to
it in `SameAPI` has been deprecated.

The Incremental.scala has been adapted to changed signature of APIChanges
class. The `sameSource` method returns representation of APIChange
(if there's one) instead of just simple boolean. One notable change is
that information about APIChanges is pushed deeper into invalidation logic.
This will allow us to treat the APIChangeDueToMacroDefinition case properly
once name hashing scheme arrives.

This commit shouldn't change any behavior and is purely a refactoring.
2013-11-11 15:43:28 +01:00
Grzegorz Kossakowski a37d8d4770 Fix unstable existential type names bug.
Fix the problem with unstable names synthesized for existential
types (declared with underscore syntax) by renaming type variables
to a scheme that is guaranteed to be stable no matter where given
the existential type appears.

The sheme we use are De Bruijn-like indices that capture both position
of type variable declarion within single existential type and nesting
level of nested existential type. This way we properly support nested
existential types by avoiding name clashes.

In general, we can perform renamings like that because type variables
declared in existential types are scoped to those types so the renaming
operation is local.

There's a specs2 unit test covering instability of existential types.
The test is included in compiler-interface project and the build
definition has been modified to enable building and executing tests
in compiler-interface project. Some dependencies has been modified:

  * compiler-interface project depends on api project for testing
    (test makes us of SameAPI)
  * dependency on junit has been introduced because it's needed
    for `@RunWith` annotation which declares that specs2 unit
    test should be ran with JUnitRunner

SameAPI has been modified to expose a method that allows us to
compare two definitions.

This commit also adds `ScalaCompilerForUnitTesting` class that allows
to compile a piece of Scala code and inspect information recorded
callbacks defined in  `AnalysisCallback` interface. That class uses
existing ConsoleLogger for logging. I considered doing the same for
ConsoleReporter. There's LoggingReporter defined which would fit our
usecase but it's defined in compile subproject that compiler-interface
doesn't depend on so we roll our own.

ScalaCompilerForUnit testing uses TestCallback from compiler-interface
subproject for recording information passed to callbacks. In order
to be able to access TestCallback from compiler-interface
subproject I had to tweak dependencies between interface and
compiler-interface so test classes from the former are visible in the
latter. I also modified the TestCallback itself to accumulate apis in
a HashMap instead of a buffer of tuples for easier lookup.

An integration test has been added which tests scenario
mentioned in #823.

This commit fixes #823.
2013-10-29 16:39:50 +01:00
Mark Harrah b8b6426cf9 Allow main class to be non-public. Fixes #883. 2013-09-26 09:42:30 -04:00
Mark Harrah 4bf4a80b5e Deleted unused type parsing class 2013-07-09 14:55:30 -04:00
xuwei-k 3f2133729b allow java varargs main
http://docs.oracle.com/javase/specs/jls/se7/html/jls-12.html#jls-12.1.4
2013-06-16 15:47:47 -04:00
Mark Harrah d2d406969b Make imports from MurmurHash explicit for clarity. 2013-05-27 19:12:39 -04:00
Mark Harrah 7088a7dd5a test cases for Java inherited dependency extraction 2013-05-02 12:01:01 -04:00
Mark Harrah a867d8e87c extract public inherited dependencies from Java class files 2013-05-01 17:54:10 -04:00
Mark Harrah f6d73128fc deprecations 2013-02-25 09:24:04 -05:00
Mark Harrah 6e30bd7842 short-circuit the macro check in the incremental compiler if the source isn't a Scala source file 2013-02-22 16:31:32 -05:00
Grzegorz Kossakowski 4c261d360f Revert "Revert "Fix sbt/sbt#676: swapped declarations and members in `ClassToAPI`.""
This reverts commit 9dd5f076ea which was a revert
itself so we are back to the state before those two reverts.

The problem that caused revert that happened in 9dd5f076ea
has been fixed in 88061dd262.
2013-02-22 07:36:55 -05:00
Grzegorz Kossakowski 129df3e812 Fix problem with initialization order in `ClassToAPI.scala`.
In `ClassToAPI` both `Private` and `Protected` vals had forward
reference to `Unqualified` so they would get `null` as a result.
Fixed that by rearranging the order of vals being declared.

This fixes a problem described in 9dd5f076ea.
2013-02-22 07:36:55 -05:00
Mark Harrah 9dd5f076ea Revert "Fix sbt/sbt#676: swapped declarations and members in `ClassToAPI`."
This reverts commit beb87f2789.  It causes java/options to fail.

CC @gkossakowski
2013-02-21 20:44:54 -05:00
Grzegorz Kossakowski 5119ea2574 Mark inherited definitions in `ShowAPI`.
Mark every inherited definition with `^inherited^` marker. This helps
understanding `ShowAPI`s output.
2013-02-20 10:52:28 -05:00
Grzegorz Kossakowski f101bcd3d0 Show some of inherited members of a structure in `ShowAPI.scala`
Showing inherited members of a structure was disabled so we would not
run into cycles. To best of my knowledge, we can run into cycles only
if inherited member is `ClassLike`. We filter out those and let
anything else to be shown.
2013-02-20 10:52:27 -05:00
Grzegorz Kossakowski beb87f2789 Fix sbt/sbt#676: swapped declarations and members in `ClassToAPI`.
As described in sbt/sbt#676, arguments to `mergeMap` and `merge` methods
were swapped causing wrong structures being created for Java compiled
class files.

This commit fixes sbt/sbt#676 and makes pending test to pass now.
2013-02-20 10:52:27 -05:00
Mark Harrah 71f12fbcdb 2.9 compatibility for incremental compilation modules 2012-12-11 14:41:22 -05:00
Grzegorz Kossakowski ef39aeb9c1 Follow source layout convention supported by Eclipse.
Moved source files so directory structure follow package
structure. That makes it possible to use Scala Eclipse plugin
with sbt's source code.
2012-12-07 10:27:08 -08:00
Mark Harrah 1c22478edc task setting macros for :=, +=, ++=
also, bump to 2.10.0-M6
2012-11-17 20:19:24 -05:00
Mark Harrah 18a03f0e25 API extraction: handle any type that is annotated, not just the spec'd simple type. Fixes #559. 2012-10-05 09:06:35 -04:00
Mark Harrah 864580aae1 approximate type parameters and references by name
not as accurate, but simpler.
2012-05-12 23:12:29 -04:00
Mark Harrah ddcf885fb9 fresh scope for each inherited definition when tagging type variables 2012-04-28 18:58:52 -04:00
Indrajit Raychaudhuri 89678735e1 Improved implementation for `parents` accumulation for java classes
It now considers `ParameterizedType` and includes all interfaces recursively
2012-03-27 01:40:10 +05:30
Indrajit Raychaudhuri 2525eeb7e6 Ensure that `parents` for java classes have all the ancestors
Currently, only immediate parents classes are picked up for java classes.
This could be problematic, for example, in detecting Fingerprint for test frameworks.
So far, Scala types are not affected –– all the ancestors are available for them.
2012-03-25 15:44:16 +05:30
Jason Zaugg 17eeec6876 Move condition out of SameAPI.
It was tenuously relying on the caller short-circuiting with `shortcutSameSource`.
2012-03-04 21:28:01 +01:00
Jason Zaugg 72e41c3329 whitespace 2012-03-04 17:41:39 +01:00
Jason Zaugg 067917a0fb Macro def aware recompilation.
- Read macro modifier from method definition.
 - Always recompile downstream files after a file containing macro defs is recompiled.
 - Source is extended with a hasMacro attribute. Mark suggests that this might be better
   tracked in Relations, but I'm not sure how to make that change.
2012-03-04 17:35:51 +01:00
Thomas Koch 9e8c441159 missing(?) imports, fix emacs syntax highlighting
While trying to build sbt without sbt, I got compile errors claiming that
util.Random would not be a member of util. The added import statements fixed
this.

The inserted spaces in the comments in project/Sbt.scala are a work around in a
bug in emacs scala syntax highlighting.
2011-12-14 14:35:17 +01:00
Mark Harrah 82ad44a701 preserve API information needed for detecting annotations on defs. fixes #232 2011-10-19 22:23:47 -04:00
Mark Harrah f70b68d3b4 fix symmetric hashing 2011-10-09 21:48:15 -04:00
Mark Harrah c74ecb55e9 finalize hash 2011-10-05 21:04:34 -04:00
Mark Harrah e4848efcc8 store hashes of API instead of full API. fixes #21 2011-10-05 18:09:27 -04:00
Paul Phillips 528b4ed342 Limit unnecessary Array allocations from ClassToAPI.
+----------------------------------------------------------------------------+----------------+
|                                    Name                                    |  Shallow Size  |
+----------------------------------------------------------------------------+----------------+
|  +---1571683 zero length arrays xsbti.api.Annotation[]                     |    25,146,928  |
|  |                                                                         |                |
|  +---1373273 zero length arrays xsbti.api.TypeParameter[]                  |    21,972,368  |
|  |                                                                         |                |
|  +---305126 zero length arrays xsbti.api.ParameterList[]                   |     4,882,016  |
|  |                                                                         |                |
|  +---295294 zero length arrays xsbti.api.MethodParameter[]                 |     4,724,704  |
|  |                                                                         |                |
2011-09-07 13:09:53 -07:00
Mark Harrah c0a21c1524 implement shortcut for API equality checking, fixes #18 2011-06-01 02:19:46 -04:00
Mark Harrah 58d9f3b0a0 fix structural type comparison 2011-05-25 22:44:22 -04:00
Mark Harrah 24dfb69400 an annotation can reference a non-simple type, fixes #24 2011-05-23 18:40:03 -04:00
Mark Harrah 1d36be9b00 properly handle nested class cycles in Java sources, fixes #22 2011-05-21 21:16:18 -04:00
Mark Harrah 9dec02ee51 fix analysis of Java sources being overwritten 2011-04-26 21:19:56 -04:00
Mark Harrah d719c7d6a9 add missing debug case for SameAPI 2011-03-11 16:55:23 -05:00
Mark Harrah 0935fba0b5 better cycle handling in SameAPI 2011-03-08 17:51:14 -05:00
Mark Harrah 9db4afd222 bring more integration tests back online with associated fixes 2011-02-23 19:19:44 -05:00
Mark Harrah cc06667f3e handle constant types 2011-02-14 18:59:54 -05:00
Mark Harrah 89c557d0b5 temporary workaround for dangling type parameter references 2010-11-09 20:45:26 -05:00
Mark Harrah f788437164 fill out Visit some more 2010-10-30 17:52:18 -04:00
Mark Harrah 730b613007 make serializable abstract Lazy template 2010-10-30 11:56:40 -04:00
Mark Harrah 5ed8f3c042 improving incremental compilation
support lazy arguments in data type generator
SafeLazy implementation that explicitly clears the reference to the thunk
in API representation, drop synthetic modifier and merge deferred into abstract
handle cyclic structures in API generation, display, comparison, persistence
gzip compile cache file
bump to 2.8.1.RC3, project definition cleanup
fix main method detection to check for the right name
properly view inherited definitions
exclude constructors of ancestors
2010-10-22 21:55:16 -04:00
Mark Harrah ce068d7fbc Java source support
generate API for Java sources from class files (currently, uses reflection)
hook into partial recompilation process
2010-09-27 18:57:00 -04:00
Mark Harrah 4db2c1df6a merge Pkg into Private
this better represents the original source
2010-09-17 21:29:29 -04:00
Mark Harrah 9bcd68d28c rework REPL support
allow bindings, which requires specifying the parent class loader
same code can be used for both 'console' and 'console-project' now
provide interface through main/Console
2010-09-04 08:18:06 -04:00
Mark Harrah 767a1e47c1 adding more commands 2010-07-27 23:01:45 -04:00