Commit Graph

100 Commits

Author SHA1 Message Date
Dale Wijnand 9f1d60be60
Rewrite to polymorphic function syntax 2017-10-25 10:23:46 +01:00
Dale Wijnand f662fdda8e
Rewrite to function syntax 2017-10-25 10:22:48 +01:00
Simon Schäfer 93e08b7ee7 Fix warnings about unused pattern vars in various projects 2017-10-19 13:07:24 +02:00
Dale Wijnand 668ace98ee
Remove some duplication when only Scoped is required 2017-10-08 19:07:38 +01:00
Dale Wijnand 5e0b080f51
Fix some minor errors 2017-10-07 18:42:26 +01:00
Dale Wijnand ef4828cfc2
Add slash syntax for AttrKey that parity with "in" syntax 2017-10-07 13:12:17 +01:00
Dale Wijnand d19c350687
Correct name of WithoutScope properties 2017-10-07 13:12:16 +01:00
Dale Wijnand 8af3110c00
Add .previous tests to SlashSyntaxTest 2017-10-07 13:12:16 +01:00
Dale Wijnand fb28c201c8
Make scoped keys more frequent 2017-10-07 13:12:16 +01:00
Dale Wijnand 74ac7d9e07
Drop redudant label in expectValue 2017-10-07 13:12:15 +01:00
Dale Wijnand 025075efd0
Dedup, cleanup & cover all key types 2017-10-07 13:12:15 +01:00
Dale Wijnand 165dc794ca
Extract gen{Input,Setting,Task}Key 2017-10-07 13:12:15 +01:00
Dale Wijnand 18d615701f
Remove WithScope wrapping 2017-10-07 13:12:15 +01:00
Dale Wijnand 0bcd7c3b6d
Remove boilerplate around sbtSlashSyntaxRichConfiguration 2017-10-07 12:08:32 +01:00
Dale Wijnand e5898111fe
Replace CanScope with Scoped.ScopingSetting 2017-10-07 12:07:19 +01:00
Eugene Yokota 2a6385fd94 Remove thunk for slash syntax
Ref #3606, #3611, and #3613

This removes unnecessary thunk for slash syntax.
The semantics using this approach is strictly better than the previous `in (ref, config, task)`. By removing the thunk, we retain `(a / b) / c == a / b / c`.

See the following example:

```scala
scala> import sbt._, Keys._
scala> val t: TaskKey[Unit] = (test in Test)
t: sbt.TaskKey[Unit] = TaskKey(This / Select(ConfigKey(test)) / This / test)

scala> ThisBuild / t
ThisBuild / t
res1: sbt.TaskKey[Unit] = TaskKey(Select(ThisBuild) / Select(ConfigKey(test)) / This / test)

scala> ThisBuild / t / name
ThisBuild / t / name
res2: sbt.SettingKey[String] = SettingKey(Select(ThisBuild) / Select(ConfigKey(test)) / Select(test) / name)
```

so far so good? Now look at this:

```
scala> scala> name in (ThisBuild, t)
name in (ThisBuild, t)
res3: sbt.SettingKey[String] = SettingKey(Select(ThisBuild) / This / Select(test) / name)
```

`Test` configuration knowledge is lost! For `in (..)` maybe it was ok because mostly we don't use unscoped keys, but that's the difference between `in (..)` and `/`.

Fixes #3605
2017-10-06 15:47:46 -04:00
Dale Wijnand 5b03379693
Extract withScope 2017-10-06 17:41:06 +01:00
Dale Wijnand 9b526f54bf
Rarely include custom scopes in key generators 2017-10-06 15:41:28 +01:00
Dale Wijnand db87e4c871
Add SlashSyntaxSpec to validate syntax parity 2017-10-06 15:07:18 +01:00
Dale Wijnand 97ddc1ffb7
Copy the non-runtime parts of project/unified to SlashSyntaxTest 2017-10-06 15:07:17 +01:00
Dale Wijnand f22843f91c
Move SlashSyntax to the settings component 2017-10-06 09:52:34 +01:00
eugene yokota 1251817cf2 Merge pull request #3612 from dwijnand/scope-toString
Handle Global in Scope#toString
2017-10-05 17:43:25 -04:00
Dale Wijnand 2a5ba9475d
Handle Global in Scope#toString
Print "Global" instead of "Zero / Zero / Zero".
2017-10-05 20:29:42 +01:00
Dale Wijnand f4b2fc4228
Correct handling of resolving ThisProject
In ca71b4b902 I went about fixing the
inexhaustive matching in Scope's resolveProjectBuild and
resolveProjectRef. Looking back the change was wrong.

For resolveProjectBuild the new implementation is less wrong, but still
not great, seeing as it doesn't actually do any build resolving.

For resolveProjectRef the new implementation now blows up instead of
lies. Which means it's less leneant, more "fail-fast".

isProjectThis is unused; remnant of the pre-AutoPlugin days when build
settings where defined in Plugin.settings.
2017-10-05 19:00:48 +01:00
Dale Wijnand a41727fb17
Add, configure & enforce file headers 2017-10-05 09:03:40 +01:00
Eugene Yokota 60f2498c0a Implement toString for keys
toString added for REPL testing:

```
scala> Zero / Zero / Zero / name
res0: sbt.SlashSyntax.ScopeAndKey[sbt.SettingKey[String]] = Zero / Zero / Zero / name
```
2017-10-05 02:46:09 -04:00
Eugene Yokota b0306b738e Add whitespaces in Show of scoped keys
```
Provided by:
    ProjectRef(uri("...."), "root") / Test / test
Dependencies:
    Test / executeTests
    Test / test / streams
    Test / state
    Test / test / testResultLogger
```
2017-09-28 03:34:49 -04:00
Eugene Yokota 33a01f3ceb Unified slash syntax
Fixes sbt/sbt#1812

This adds unified slash syntax for both sbt shell and the build.sbt DSL.
Instead of the current `<project-id>/config:intask::key`,
this adds `<project-id>/<config-ident>/intask/key` where <config-ident> is the Scala identifier notation for the configurations like `Compile` and `Test`.

This also adds a series of implicits called `SlashSyntax` that adds `/` operators to project refererences, configuration, and keys such that the same syntax works in build.sbt.

These examples work for both from the shell and in build.sbt.

    Global / cancelable
    ThisBuild / scalaVersion
    Test / test
    root / Compile / compile / scalacOptions
    ProjectRef(uri("file:/xxx/helloworld/"),"root")/Compile/scalacOptions
    Zero / Zero / name

The inspect command now outputs something that can be copy-pasted:

    > inspect compile
    [info] Task: sbt.inc.Analysis
    [info] Description:
    [info] 	Compiles sources.
    [info] Provided by:
    [info] 	ProjectRef(uri("file:/xxx/helloworld/"),"root")/Compile/compile
    [info] Defined at:
    [info] 	(sbt.Defaults) Defaults.scala:326
    [info] Dependencies:
    [info] 	Compile/manipulateBytecode
    [info] 	Compile/incCompileSetup
    [info] Reverse dependencies:
    [info] 	Compile/printWarnings
    [info] 	Compile/products
    [info] 	Compile/discoveredSbtPlugins
    [info] 	Compile/discoveredMainClasses
    [info] Delegates:
    [info] 	Compile/compile
    [info] 	compile
    [info] 	ThisBuild/Compile/compile
    [info] 	ThisBuild/compile
    [info] 	Zero/Compile/compile
    [info] 	Global/compile
    [info] Related:
    [info] 	Test/compile
2017-09-28 01:01:43 -04:00
eugene yokota 45765583a6 Merge branch '1.0.x' into 1.0.x 2017-09-15 19:47:08 -04:00
Răzvan Flavius Panda 0124a8ad0e Fix unused imports warnings 2017-09-15 16:35:08 +01:00
Dale Wijnand 936733b2b1
Cleanup 2017-09-13 16:03:51 +01:00
Dale Wijnand d3d105515a
Don't warn on by-name keys
.. which is apparently what the type of bare vals in *.sbt files are.

Fixes #3299, again.
2017-09-11 14:46:33 +01:00
Dale Wijnand 8d9a3a35d2
Fix warnings in TaskLinterDSL.scala 2017-09-11 14:45:40 +01:00
eugene yokota 33d3ba9d7c Merge pull request #3438 from Duhemm/source-appender
[1.0.x] `Append` instance to add `File` to `Seq[Source]`
2017-08-23 18:31:58 -04:00
Dale Wijnand 4f0d2f9ffd
Scalafmt 1.2.0 2017-08-14 15:47:52 +01:00
Martin Duhem 5815f1db0a
`Append` instance to add `File` to `Seq[Source]` 2017-08-14 15:47:17 +02:00
Dale Wijnand 805b76f3d4
Add back, re-configure & re-enable Scalafmt 2017-08-10 16:35:23 +01:00
Eugene Yokota 467617a4b9 Implement withRank 2017-07-25 01:50:53 -04:00
Martin Duhem 9dfe1a8406
Allow `.value` on SettingKey inside ifs & lambdas
Calling `.value` on a SettingKey doesn't trigger any execution and
doesn't have any side effect, so we can safely allow calls to `.value`
inside conditionals and lambdas.

Fixes #3299
2017-07-21 16:26:45 +02:00
Martin Duhem 347914191a Adapt to new library management API 2017-07-15 18:09:40 -04:00
Martin Duhem 3fe068a4c1 Adapt to changes in ConsoleAppender 2017-07-15 17:15:42 +02:00
Eugene Yokota 42a1e2a291 Improve the default prompt
Fixes #3313

This changes the default prompt to include "sbt:" + current project name.
See https://twitter.com/eed3si9n/status/884914670351659009
2017-07-13 14:58:10 -04:00
Dale Wijnand 0fe0de5fb3
Move the tuple enrichments into sbt.TupleSyntax
This undeprecates the syntax, but at the same times moves it out of
implicit scope, therefore requiring a 'import TupleSyntax._' to opt-in
to the old syntax.
2017-06-27 12:42:46 +01:00
Dale Wijnand c5b21ab9d9
Format Structure 2017-06-26 13:49:18 +01:00
jvican c85fb95851
Remove unnecessary infra for .value DSL check 2017-05-28 18:36:14 +02:00
jvican 6a31251a01
Add tests that check `sbtUnchecked` is respected 2017-05-28 18:31:45 +02:00
jvican b017eaee39
Support DSL detection for nested ifs and anons
Before, we were not preserving the value `insideXXX`. This commit makes
sure that we handle much more complex scenarios and we report them
successfully. Have a look at the tests.
2017-05-28 18:31:44 +02:00
jvican ded281b5c2
Add missing .value DSL check
The missing .value analysis is dumb on purpose because it's expensive.

Detecting valid use cases of idents whose type is an sbt key is
difficult and dangerous because we may miss some corner cases. Instead,
we report on the easiest cases in which we are certain that the user
does not want to have a stale key reference. Those are idents in the rhs
of val definitions with `_` as name and idents in statement position
inside blocks.

In the future, we can cover all val definitions no matter what their
name is. Unfortunately, doing so will come at the cost of speed: we have
to run the unused name analysis in `TypeDiagnostics` and expose it from
the power context in `ContextUtil`.

This is good enough for now. If users express interest in having a
smarter analysis, we can always consider trying the unused name
analysis. I am not sure how slow it will be -- hopefully it won't be
that much.
2017-05-28 18:08:58 +02:00
eugene yokota acf4a5ffc2 Merge pull request #3220 from eed3si9n/fport/3135
[fport] Fix += interference with sbt-buildinfo
2017-05-27 00:15:32 -04:00
Eugene Yokota bfc2d85d54 Fix += interference with sbt-buildinfo
The macro pattern match was too general. This makes it tighter.

Fixes #3132
2017-05-26 21:04:33 -04:00