Commit Graph

356 Commits

Author SHA1 Message Date
Mark Harrah 3e1142843e Translate errors from logic system to Natures system. 2014-01-24 14:36:46 -05:00
Mark Harrah 6a2e8947bb Acyclic negation checking in logic system that backs auto-plugins. 2014-01-24 14:36:36 -05:00
Mark Harrah ca3877e138 Logic system supporting auto plugins and initial outline of AutoPlugin and Natures types.
* Not integrated into project loading
 * Doesn't yet check that negation is acyclic before execution
2014-01-24 14:30:12 -05:00
Mark Harrah 5dcd8bd913 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
Dan Sanduleac ee8089f4a9 Removed unnecessary catch for exception 2013-11-28 11:04:46 -05:00
Dan Sanduleac 9b1727889b Added test case for derived settings 2013-11-28 11:04:46 -05:00
Dan Sanduleac d1678e7cac Fix deriveAndLocal bug 2013-11-28 11:04:46 -05:00
Mark Harrah 8857a4fb9a Add -Dsbt.cli.nodelegation option to experiment with no delegation for running/showing tasks/settings from the command line.
With this set to true, the following is no longer allowed for example:

> compile:update
2013-11-25 21:03:40 -05:00
Mark Harrah 4ec88dba43 Remove the need for resetLocalAttrs. Fixes #994, #952.
The fix was made possible by the very helpful information provided by @retronym.

This commit does two key things:
 1. changes the owner when splicing original trees into new trees
 2. ensures the synthetic trees that get spliced into original trees do not need typechecking

Given this original source (from Defaults.scala):

  ...
  lazy val sourceConfigPaths = Seq(
    ...
    unmanagedSourceDirectories := Seq(scalaSource.value, javaSource.value),
    ...
  )
  ...

After expansion of .value, this looks something like:

    unmanagedSourceDirectories := Seq(
      InputWrapper.wrapInit[File](scalaSource),
      InputWrapper.wrapInit[File](javaSource)
    )

where wrapInit is something like:

    def wrapInit[T](a: Any): T

After expansion of := we have (approximately):

    unmanagedSourceDirectories <<=
      Instance.app( (scalaSource, javaSource) ) {
        $p1: (File, File) =>
          val $q4: File = $p1._1
          val $q3: File = $p1._2
          Seq($q3, $q4)
      }

So,

 a) `scalaSource` and `javaSource` are user trees that are spliced into a tuple constructor after being temporarily held in `InputWrapper.wrapInit`
 b) the constructed tuple `(scalaSource, javaSource)` is passed as an argument to another method call (without going through a val or anything) and shouldn't need owner changing
 c) the synthetic vals $q3 and $q4 need their owner properly set to the anonymous function
 d) the references (Idents) $q3 and $q4 are spliced into the user tree `Seq(..., ...)` and their symbols need to be the Symbol for the referenced vals
 e) generally, treeCopy needs to be used when substituting Trees in order to preserve attributes, like Types and Positions

changeOwner is called on the body `Seq($q3, $q4)` with the original owner sourceConfigPaths to be changed to the new anonymous function.
In this example, no owners are actually changed, but when the body contains vals or anonymous functions, they will.

An example of the compiler crash seen when the symbol of the references is not that of the vals:

symbol value $q3 does not exist in sbt.Defaults.sourceConfigPaths$lzycompute
	at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:49)
	at scala.tools.nsc.Global.abort(Global.scala:254)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.genLoadIdent$1(GenICode.scala:1038)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:1044)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$genLoadArguments$1.apply(GenICode.scala:1246)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$genLoadArguments$1.apply(GenICode.scala:1244)
   ...

Other problems with the synthetic tree when it is spliced under the original tree often result in type mismatches or some other compiler error that doesn't result in a crash.

If the owner is not changed correctly on the original tree that gets spliced under a synthetic tree, one way it can crash the compiler is:

java.lang.IllegalArgumentException: Could not find proxy for val $q23: java.io.File in List(value $q23, method apply, anonymous class $anonfun$globalCore$5, value globalCore, object Defaults, package sbt, package <root>) (currentOwner= value dir )
   ...
     while compiling: /home/mark/code/sbt/main/src/main/scala/sbt/Defaults.scala
        during phase: global=lambdalift, atPhase=constructors
   ...
  last tree to typer: term $outer
              symbol: value $outer (flags: <synthetic> <paramaccessor> <triedcooking> private[this])
   symbol definition: private[this] val $outer: sbt.BuildCommon
                 tpe: <notype>
       symbol owners: value $outer -> anonymous class $anonfun$87 -> value x$298 -> method derive -> class BuildCommon$class -> package sbt
      context owners: value dir -> value globalCore -> object Defaults -> package sbt
   ...

The problem here is the difference between context owners and the proxy search chain.
2013-11-22 13:08:10 -05:00
Mark Harrah cfe5f3cebc update to ScalaCheck 1.11.0 2013-11-04 11:28:40 -05:00
Benjy 57f87fe6c1 Fix implementation of Relation.size.
Nothing was actually using it yet, fortunately.
2013-11-04 09:29:38 -05:00
Bruno Bieth 9fefc18e2d avoid deadlock in ConsoleOut.systemOutOverwrite
System.out can be reset after being captured by `val lockObject`.
Then locking `lockObject` and calling `println()` could lead to a
deadlock.
2013-11-01 13:27:23 -04:00
Mark Harrah cb7c12a4ad Transfer logging,trace levels from old to new global loggers. 2013-10-24 16:34:16 -04:00
Mark Harrah 8dc24826d3 shortcut heterogeneous AList to KList.toList 2013-10-23 09:46:43 -04:00
Mark Harrah a0540f5ce9 cleanups in Settings 2013-10-23 09:46:43 -04:00
Mark Harrah d30a3f3bfd drop view for iterator in IMap 2013-10-23 09:46:43 -04:00
Benjy 41e96dbc66 Test for Analysis split/merge.
Requires scalacheck generators for Analysis and its subobjects. These
may be useful for other tests in the future.

Also fixes a bug in RelationTest.
2013-10-17 11:56:10 -07:00
Benjy 3cbe4f942b Add merge, partition and groupBy methods to Relation.
Also add equals/hashCode to Relation.

Also add a basic test for groupBy.
2013-10-10 21:05:20 -07:00
Mark Harrah 5ac9390be6 TrapExit support for multiple, concurrent managed applications. Fixes #831. 2013-10-02 09:13:45 -04:00
James Roper a3a3dc1226 String upper/lower case no longer locale dependent
Fixed many instances of the Turkish i bug.

Spare a thought for the poor Turks!
2013-09-24 08:14:15 -04:00
Mark Harrah 8883ab324b The Process methods that are redirection-like should not discard the exit code of the input.
Only piping should do that.  This addresses an inconsistency with Fork, where using the CustomOutput
OutputStrategy makes the exit code always zero.
2013-09-19 12:38:16 -04:00
Mark Harrah 62137f708f Show source position of undefined setting. 2013-08-30 18:34:54 -04:00
Mark Harrah b71af2150e API docs for Attributes.scala 2013-08-16 14:22:14 -04:00
Mark Harrah a2ab8a3630 Cleaned up API docs for Relation. 2013-08-16 14:22:14 -04:00
Mark Harrah 9614c4f95a API docs for Parser(s). 2013-08-16 14:22:14 -04:00
Mark Harrah dae220ecad Restore lower case hex digits to HexDigit Parser, accidentally removed in 8545e912da. 2013-08-16 14:22:14 -04:00
Mark Harrah 3781820dda init/restore instead of setEchoEnabled in order to handle full jline customizations. Fixes #822. 2013-07-19 20:03:06 -04:00
Mark Harrah 1d829e2512 specify explicit type to work around 2.11 volatile override error 2013-07-18 22:38:16 -04:00
Mark Harrah 577424fe70 disable JLine event expansion 2013-07-12 09:42:16 -04:00
Mark Harrah e805eb919d Provide a better error message when an older launcher is used with 0.13 and JLine classes are incompatible. 2013-07-08 18:42:00 -04:00
Mark Harrah 874a357f25 jline/jansi fixes for windows. Fixes #763, fixes #562.
The startup script should set sbt.cygwin=true if running from cygwin.
This will set the terminal type properly for JLine if not already set.
If sbt.cygwin=false or unset and os.name includes "windows", JAnsi is
downloaded by the launcher and installed on standard out/err.

The value for jline.terminal is transformed from explicit jline.X to
the basic types "windows", "unix", or "none".  Now that sbt uses JLine
2.0, these types are understood by both sbt's JLine and Scala's.
Older Scala versions shaded the classes but not the terminal property
so both couldn't be configured with a class name at the same time.
2013-06-26 13:40:33 -04:00
Mark Harrah a17c747415 deprecate xml process constructors, which are replaced by proper string interpolation in Scala 2.10 2013-06-24 17:48:44 -04:00
Mark Harrah f47ad3fb72 Experimental task progress interface. Fixes #592.
Set sbt.task.timings=true to print timings for tasks.
This sample progress handler shows how to get names for tasks and
deal with flatMapped tasks.  There are still some tasks that make
it through as anonymous, which needs to be investigated.

A setting to provide a custom handler should come in a subsequent commit.
2013-06-23 19:57:30 -04:00
Mark Harrah e7cdcc2deb set position on parameter references in task/setting macros 2013-06-19 11:53:11 -04:00
Mark Harrah 169a88dd30 Require projects to have unique target directories.
Configuring projects so that target directories overlap is usually
unintentional and the error message that results is usually unrelated
to the cause.
2013-06-18 18:43:50 -04:00
Mark Harrah aa2bd76e5e Support dynamic evaluations of optional settings (Initialize.evaluate). 2013-06-18 18:29:01 -04:00
Mark Harrah de63a2c448 SoftInvalid parser, which defers being invalid in order to preserve a failure message on empty input. 2013-06-17 12:06:13 -04:00
Mark Harrah 0f088ab25a invalid/failure Parser construction methods now accept definitive flag 2013-06-17 12:06:13 -04:00
Mark Harrah ac3bfc16ae Merge failures from a,b in a|b when a,b fail on the same input position.
Previously, only the failures from b were used.
2013-06-17 12:06:13 -04:00
Mark Harrah d4f6b9cf78 'definitive' Parser failures
Support a definitive flag for Failure that ignores later failures
instead of appending them.  This is useful to override the default
behavior of listing the failures of alternative parsers.
2013-06-17 12:06:13 -04:00
Mark Harrah 3dd714b1fa Fully implement StaticScopes subclass of Initialize in order to support use in Task flatMap. Fixes #784. 2013-06-15 23:55:05 -04:00
Mark Harrah 6b0bc78fd9 local SyncVar implementation to deal with std lib deprecations 2013-05-27 19:12:39 -04:00
Mark Harrah 61decef972 Derived settings: handle scopeLocal in derive and allow triggering dependencies to be filtered 2013-05-09 17:28:50 -04:00
Mark Harrah 19c78ac413 Show defining locations when there are cycles between derived settings 2013-05-09 17:28:50 -04:00
Mark Harrah ed11008126 only derive settings when all dependencies are defined 2013-05-09 17:28:49 -04:00
Mark Harrah 7a10aeca37 Default settings, which give internal sbt settings something like Plugin.globalSettings. 2013-05-09 17:28:40 -04:00
Mark Harrah 6ffff6fb35 support filtering the Scopes that a derived setting is applied in 2013-05-09 17:28:39 -04:00
Mark Harrah 08e4e3786f more specific error when dependencies of a derived setting are undefined 2013-05-09 17:28:39 -04:00
Mark Harrah 68ca419a7c require dynamic initialization to be explicitly enabled for derived settings 2013-05-09 17:28:39 -04:00
Mark Harrah 962a163f33 ensure a derived setting is only injected into a scope once 2013-05-09 17:28:39 -04:00
Mark Harrah 94f4d4e8c0 display derived settings information in 'inspect' 2013-05-09 17:28:39 -04:00
Mark Harrah 1c741a2e06 Derived settings, which allows injecting settings wherever their dependencies are defined.
This is an advanced feature initially intended for internal sbt use.
2013-05-09 17:27:43 -04:00
cheeseng b0bd2e838e Normalize line endings. 2013-04-25 00:06:52 +08:00
Mark Harrah 9d21724129 API for evaluating a setting or task in multiple scopes 2013-03-27 09:17:53 -04:00
Mark Harrah 033fd23314 Logger.Null that discards logged messages 2013-03-13 12:40:03 -04:00
Mark Harrah b951c2c2cc Construct input tasks in multiple steps to allow input task reuse. Fixes #407. 2013-03-08 14:23:30 -05:00
Mark Harrah 4abc8f3d7b make classpaths exported 2013-02-28 17:59:38 -05:00
Mark Harrah 829d6b7513 changes needed for tests for jline 2.10 2013-02-26 09:27:57 -05:00
Mark Harrah cb9266d05a add Jline.createReader() back for source compatibility 2013-02-26 09:27:56 -05:00
Alex Dupre ae3690676e Switch from JLine 1.0 to 2.10. 2013-02-26 07:39:33 -05:00
Mark Harrah 3b93691476 Move GlobalLogBacking.newLogger to GlobalLogging to make the role of GlobalLogBacking clearer. 2013-02-25 09:24:05 -05:00
Mark Harrah 1aacd4b86d make GlobalLogging.backed less specific: AbstractLogger is fine 2013-02-25 09:24:05 -05:00
Mark Harrah d69db30af7 deprecations 2013-02-25 09:24:04 -05:00
Mark Harrah 67010fa0b2 Split ConsoleOut into its own file, track the global ConsoleOut and use it instead of StandardMain.console 2013-02-25 09:24:04 -05:00
Mark Harrah 4e4455d03a Use @compileTimeOnly for .value and .parsed methods.
Needed to set position on wrapper method for correct error message position.
2013-02-19 08:54:40 -05:00
Mark Harrah badee8bacd Update to 2.10.1-RC1
Needed an explicit type in PMap to workaround an error.
Need to drop tuple assignment of parser.parsed in input task macro as a workaround
  for macro/resetAllAttrs/pattern matching/annotation issue in RC1.
2013-02-13 07:17:20 -05:00
Mark Harrah 3e2aa82fde -Xlint 2013-02-04 17:30:31 -05:00
Mark Harrah 4a08ec9c60 use standard Context.weakTypeOf 2013-01-28 17:14:53 -05:00
Mark Harrah 37063924ec Reduce InputTask to the ideal wrapper around 'State => Parser[Initialize[Task[T]]]'
Ref #407.
2013-01-28 17:14:53 -05:00
Mark Harrah 89c645db44 remove deprecated Initialize.scoped method 2013-01-28 17:14:53 -05:00
Paolo G. Giarrusso ef84332a51 Silence boring Eclipse warnings: catching all exceptions, part 2
These warning fixes are new since my last pull request, please verify.
2013-01-22 09:05:15 -05:00
Paolo G. Giarrusso e5673f7426 Silence boring Eclipse warnings: catching all exceptions
Here I make explicit where catching all exceptions is intended.
Mark Harrah corrected one decision during review.
2013-01-22 09:05:15 -05:00
Paolo G. Giarrusso cf08f2dd18 Don't catch org.scalacheck.Prop.Exception 2013-01-22 09:05:14 -05:00
Mark Harrah c826078002 Convert references to harrah/xsbt to sbt/sbt 2013-01-04 17:22:40 -05:00
Mark Harrah 169a08df55 update version for backported Parser deprecations 2013-01-03 17:40:07 -05:00
Mark Harrah 4fa45f957d require a failure message for parser 2013-01-03 11:37:40 -05:00
Mark Harrah 89ad7d720a minor cleanup of previous commit: var->val in sbt.JLine 2012-12-20 09:25:35 -05:00
Anthony 4ad81e9d04 Multi-line prompt text offset issue (ticket #625) 2012-12-20 08:56:20 -05:00
Grzegorz Kossakowski 6c5e4ae21c 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 9890f71102 Explicitly specify type parameters in calls to KCons in KList builder.
scalac couldn't infer the type constructor otherwise.
2012-11-18 09:20:26 -05:00
Mark Harrah 237b80eb22 Transition to all camelCase key labels.
1. Hyphenated labels are still accepted when parsing scoped keys (so 'sbt test-only' still works)
   There is currently no timeline for removing this support for hyphenated keys.
2. Only camelCase is shown for tab completion.
3. AttributeKey.rawLabel provides the unnormalized label.
   This should only be used to implement support for accepting hyphenated keys as input for compatibility.
4. AttributeKey.normLabel provides the normalized label (hyphenated converted to camelCase)
2012-11-17 20:23:07 -05:00
Mark Harrah ed41547a47 InputTask macro
Similar to task macros, the parsed value is accessed by calling `parsed`
on a Parser[T], Initialize[Parser[T]], or Initialize[State => Parser[T]].
Values of tasks and settings may be accessed as usual via `value`.
2012-11-17 20:23:07 -05:00
Mark Harrah 981ada6f4b AbsTypeTag -> WeakTypeTag and converted more settings 2012-11-17 20:23:06 -05:00
Mark Harrah 530e125a9e Scala 2.10.0-M7 2012-11-17 20:23:06 -05:00
Mark Harrah 64e000a37d Properly apply transformations to dynamic tasks.
That is, implement Initialize[Task[T]].flatten correctly.
This requires preserving the transformations applied in a scope so that
they can be applied to an Initialize value after static settings have been
evaluated.
2012-11-17 20:23:06 -05:00
Mark Harrah ec34ec580f move explicit task/setting macros to Def, move to AbsTypeTag 2012-11-17 20:23:06 -05:00
Mark Harrah 72a580d7e8 Task macro cleanup
* use normal TypeTree constructor
* remove unnecessary 'with Singleton' in macro utility
* integrate changes suggested by @xeno-by
* add refVar back and call asTypeConstructor instead of asType to refer to a type variable
2012-11-17 20:22:39 -05:00
Mark Harrah c95df4681b task setting macros for :=, +=, ++=
also, bump to 2.10.0-M6
2012-11-17 20:19:24 -05:00
Mark Harrah 15fec197c3 2.10.0-M5, different arity generalization
1. KList[M[_]] now instead of KList[HL <: HList, M[_]]
  a. head, tail work properly in this variant
  b. disadvantage is that full type not easily transformed to new type constructor
2. AList abstracts on K[L[x]], a higher order type constructor.
 A. Instances written for:
  a. KList
  b. Seq[M[T]] for a fixed T
  c. TupleN
  d. single values
  e. operate on one type constructor when nested
 B. Main disadvantage is type inference.  It just doesn't happen for K[L[x]].
    This is mitigated by AList being used internally and rarely needing to construct a K.
2012-11-17 20:19:24 -05:00
Mark Harrah dbe4b74c10 reorganization of main/
* split several source files
* move base settings sources (Scope, Structure, ...) into main/settings/
* breaks cycles.  In particular, setting system moved from Project to Def
2012-11-17 20:19:24 -05:00
Mark Harrah 19315265c1 taking care of deprecations removed in Scala master 2012-11-14 11:48:06 -05:00
Benjy 0e472a99f9 Analysis.groupBy implementation. 2012-11-10 19:01:41 -05:00
Mark Harrah 1f88fe9d7c Parser.failOnException method, don't let rhs of alias fail the parse. Fixes #572.
alias only parses the right hand side for tab completion help.
The assignment should happen whether or not the parse is successful because the
context may change by the time the alias is actually evaluated.
In particular, the 'set' command uses the loaded project for tab completion in 0.12.1.
When a .sbtrc file is processed, the project has not been loaded yet, so aliases
involving set fail.  Wrapping the rhs in failOnException addresses this.
2012-10-15 12:42:27 -04:00
Jason Zaugg efa362c583 Fix #552 Compensate for JLine's absent EOF detection.
In the unsupported terminal mode, JLine treats a broken
stdin as an endless stream of empty lines. This is problematic
for idea-sbt-plugin: if the IntelliJ process is forcibly killed
and leaves the child SBT process running, it consumes considerable
CPU processing these.

Patching JLine itself would be the cleanest solution (the change
has already been applied to JLine 2), but I've shied away from that
and instead wrapped the InputStream that is read by JLine to
intercept the result of -1 from read(). When this happens, the
flat `inputEof` is set to true.
2012-09-23 15:58:15 -04:00
Mark Harrah c8ffd6a54d better error message for null setting values 2012-09-18 13:22:40 -04:00
Mark Harrah d17de8e83a back all ConsoleLoggers by a common ConsoleOut
The common ConsoleOut merges (overwrites) consecutive Resolving xxxx ... lines
when ansi codes are enabled.
2012-09-01 09:56:09 -04:00
Eugene Vigdorchik b65a7078f1 Fix compilation error for 2.10.0-M5 for all but main project. 2012-07-17 15:20:37 -04:00
Mark Harrah e5ffceaef8 clean up token completions and make providing a general completion function easier 2012-07-13 14:33:27 -04:00
Mark Harrah fa97cc0d22 basic code for cleaning up Manifest.toString 2012-07-13 14:33:27 -04:00
Mark Harrah 73166e2e57 clean up Completions and allow arbitrary 'display' for Token 2012-07-13 14:33:27 -04:00