Commit Graph

111 Commits

Author SHA1 Message Date
Ethan Atkins ae978b9337 Remove TaskProgressFormats autogenerated file
This file somehow got stuck in the repo although it wasn't actually
used. In fact, it fails to compile at all because
sbt.internal.util.TaskProgress is defined in main, not util-logging. I
noticed this because metals wasn't working well because it was failing
to compile util-logging because of this file. I think the file was
checked in by accident in e28e052b5b.
2020-05-05 08:23:56 -07:00
Ethan Atkins 079cf2178c Add ClearScreenAfterCursor
This communicates intent better than clearScreen(0).
2020-05-01 13:02:48 -07:00
Ethan Atkins 58822cc3f5 Add virtual System.out for supershell
In order to make supershell work with println, this commit introduces a
virtual System.out to sbt. While sbt is running, we override the default
java.lang.System.out, java.lang.System.in, scala.Console.out and
scala.Console.in (unless the property `sbt.io.virtual` is set to
something other than true). When using virtual io, we buffer all of the
bytes that are written to System.out and Console.out until flush is
called. When flushing the output, we check if there are any progress
lines. If so, we interleave them with the new lines to print.

The flushing happens on a background thread so it should hopefully not
impede task progress.

This commit also adds logic for handling progress when the cursor is not
all the way to the left. We now track all of the bytes that have been
written since the last new line. Supershell will then calculate the
cursor position from those bytes* and move the cursor back to the
correct position. The motivation for this was to make the run command
work with supershell even when multiple main classes were specified.

* This might not be completely reliable if the string contains ansi
cursor movement characters.
2020-05-01 12:35:43 -07:00
Ethan Atkins 293e83ef9f Add Delete line to terminal prompt 2020-05-01 12:35:43 -07:00
Ethan Atkins 2e3a1e767d Don't poll System.in in ConsoleChannel
The ask user thread is a background thread so it's fine for it to block
on System.in. By blocking rather than polling, the cpu utilization of
sbt drops to 0 on idle. We have to explicitly handle <ctrl+d> if we
block though because the JLine console reader will return null both if
the input stream returns -1
2020-05-01 12:35:43 -07:00
Ethan Atkins 7902ec3b7d Add Terminal abstraction
This commit aims to centralize all of the terminal interactions
throughout sbt. It also seeks to hide the jline implementation details
and only expose the apis that sbt needs for interacting with the
terminal.

In general, we should be able to assume that the terminal is in
canonical (line buffered) mode with echo enabled. To switch to raw mode
or to enable/disable echo, there are apis: Terminal.withRawSystemIn and
Terminal.withEcho that take a thunk as parameter to ensure that the
terminal is reset back to the canonical mode afterwards.
2020-05-01 12:35:43 -07:00
Eugene Yokota 2396b449fe Contraband 0.4.6 2020-04-24 17:44:15 -04:00
Ethan Atkins aecdc44909 Update contraband sources
In 8bfae66b9d I upgraded contraband but
not all of the sources were regenerated because I didn't run clean
before recompiling.
2019-12-12 11:34:53 -08:00
Eugene Yokota 1ef83e9140 Fixes sbt new by restoring the terminal
Fixes https://github.com/sbt/sbt/issues/5063

This fixes "sbt new" on Ubuntu by restoring the terminal state after supershell querying for the terminal width.
2019-12-11 13:05:20 -05:00
Ethan Atkins ad59e71b1a Add util headers
None of the util files had headers.
2019-12-08 10:29:22 -08:00
Ethan Atkins 8bfae66b9d Update build.sbt to handle util projects
As part of re-integrating util into the sbt main project, I had to
update the build.sbt and a few dependencies (like the contraband plugin).
2019-12-08 10:28:31 -08:00
Diego E. Alonso-Blas 3657910063 ConsoleAppender: reuse/recycle StringBuilder storage.
A StringBuilder is a mutable data structure to create a String.
When the String is created, the new String does not share any
storage with the StringBuilder. Thus, we can keep a same
StringBuilder, and reuse its internal storage between different
iterations.
2019-10-22 23:30:09 +02:00
Ethan Atkins 43f25520a0 Don't include DeleteLine in progress length
I incorrectly included the DeleteLine in the progress line length and
this could cause certain progress lines to be incorrectly reported as
multi line when they actually fit on a single terminal line.
2019-10-07 09:30:41 -07:00
Ethan Atkins 9c2dd05b6a Avoid possible divide by zero
On the off chance that in some configurations the terminal width is set
to zero, avoid an exception by returning 0 for terminal lines. It is
likely that supershell will not work well if terminal width is zero, but
that's better than a potential crash (I think the crash would be in the
progress background thread, so I'm not sure how bad it would be, but
still its good to avoid).
2019-09-24 16:35:03 -07:00
Ethan Atkins 5cfab4c9a9 Cleanup implementation of progress report
It was a bit cleaner to consolidate `extra` and
(previousLines|info).length into prevLength and currentLength.
2019-09-24 16:33:42 -07:00
Ethan Atkins 7597cdb19b Take terminal width into account in supershell
Sometimes if the progress lines are wider than the terminal width,
the supershell blank zone can expand indefinitely because be do not move
the cursor far enough up to properly re-fill the blank zone.
2019-09-24 10:59:53 -07:00
eugene yokota 3f20cc1583
Merge pull request #221 from eatkins/lazy-success-event-tag
Load SuccessEventTag lazily
2019-09-18 22:14:28 -04:00
Ethan Atkins b3165b5c8c Load SuccessEventTag lazily
It takes about a second to load scala.reflect.runtime.universe. If we
lazy load here, we can load scala.relect.runtime.universe in the
background to speed up the sbt start up time. See
0ebb7a5662.
2019-09-18 15:33:42 -07:00
Ethan Atkins f20b275045 Fix supershell position bug
The previous implementation of supershell log line interlacing with
regular line interlacing relied on state in a global object. A somewhat
better approach is for each appender to hold a reference to a state
object. Every time tasks run, new appenders are created, so the state
should always reflect the current progress state.
2019-09-03 13:07:51 -07:00
Ethan Atkins 635316902d Allow supershell to work in no color mode
Supershell actually works quite well in no color mode. On the sbt side,
we still want to disable supershell automatically if the output is not a
terminal or no color is set, but this commit allows the user to force
supershell through -Dsbt.supershell or the useSuperShell setting even
when no color is set.
2019-09-02 11:10:42 -07:00
Ethan Atkins a5666e97b6 Manage progress padding
With this commit, I improved the padding management so that padding is
now added above the progress report. Whenever a line is logged at the
info or greater level, we can reduce the padding level by one since that
line has effectively filled in the padding.
2019-09-01 22:26:57 -07:00
Ethan Atkins d9fe5540f5 Interlace log lines with task progress
With the current supershell implementation, the progress display
flickers when there is heavy console logging during task evaluation.
This is because the console appender clears out the task progress and it
isn't restored until the next periodic super shell report (which
runs every 100ms by default). To remove the flickering, I reworked the
implementation to interlace the log lines with progress reports. In
order to ensure that the log lines remained contiguous, I had to apply
padding at the bottom of the supershell region whenever the new report
contained fewer lines than the old report. The report shifts down as new
log lines are appended. This isn't optimal, but I think removing
the flickering while preserving contiguous log lines is worth it.
2019-09-01 21:06:48 -07:00
Eugene Yokota 39fdf70c21 reimplement stacktrace suppression
Ref https://github.com/sbt/sbt/issues/4964
2019-08-20 12:35:13 -04:00
Eugene Yokota 7de45416fa Scala 2.13.0 2019-07-14 12:47:43 -04:00
Eugene Yokota e28e052b5b move super shell rendering to ConsoleAppender
Ref https://github.com/sbt/sbt/issues/4583
This moves the super shell rendering to ConsoleAppender with several improvements.

Instead of scrolling up, supershell is now changed to normal scrolling down, with more traditional cursor position. Before printing out the logs, last known progress reports are wiped out. In addition, there's now 5 lines of blank lines to accomodate for `println(...)` by tasks.
2019-04-21 03:59:19 -04:00
Eugene Yokota 98ec0075f4 apply formatting 2019-04-20 23:23:13 -04:00
Eugene Yokota d496a5dff5 Make showProgress configurable 2019-03-07 16:49:54 -05:00
Eugene Yokota 8215026bc3 Account for log line longer than the terminal width
widthHolder will hold on to the terminal width if supplied by sbt.
This avoids adding dependencies to JLine.
2019-03-07 16:42:10 -05:00
Eugene Yokota 8c85744d67 Use IO.Newline for stack trace 2019-03-07 16:39:47 -05:00
Eugene Yokota 3a6aa57747 log4j 2.11.2 2019-02-23 14:21:07 -05:00
Eugene Yokota 9f202397e4 expose ANSI control sequences 2018-11-16 23:03:25 -08:00
eugene yokota f16997d3a9
Merge pull request #184 from eed3si9n/wip/progress
Adds sbt.color flag and sbt.progress flag
2018-10-02 08:58:38 -04:00
Eugene Yokota efe04c1cde Cleaning up code 2018-10-02 08:51:17 -04:00
Eugene Yokota 9bb244314d implement sbt.progress
This implements a logger that grows upward, instead towards bottom.
2018-10-01 05:50:35 -04:00
Eugene Yokota 53c9b84858 add sbt.color flag
This implements a new sbt.color flag that takes always/auto/never/true/false value as a replacement of current sbt.log.format=true/false flag.

When neither flags are set, the default behavior is to enable color when the terminal supports ANSI and it detects an stdout console (as opposed to redirects).

Fixes https://github.com/sbt/sbt/issues/4284
2018-09-30 21:00:09 -04:00
Eugene Yokota ab674321dc Scala 2.12.7 2018-09-28 02:27:45 -04:00
Eugene Yokota e121d969c4 openjdk11 2018-09-22 00:55:00 -04:00
Eugene Yokota 9f876009c8 Fix 2.10 build
Fixes #179
2018-09-22 00:35:20 -04:00
Eugene Yokota cf0467609d -Xfatal-warnings 2018-09-19 22:46:38 -04:00
eugene yokota 965de89c64
Merge pull request #176 from sbt/1.2.x
Merge 1.2.x
2018-08-29 03:27:16 -04:00
Guillaume Martres 15522a0cbe Add Problem#rendered to customize how problems are shown
Dotty has its own logic for displaying problems with the proper file
path, position, and caret, but if we store this information in
Problem#message we end up with duplicated information in the output
since Zinc will prepend/append similar things (see
sbt.internal.inc.ProblemStringFormats). So far, we worked around this in
Dotty by using an empty position in the sbt bridge reporter, but this
means that crucial semantic information that could be used by a Build
Server Protocol implementation and other tools is lost. This commit
allows us to avoid by adding an optional `rendered` field to `Problem`:
when this field is set, its value controls what the user sees, otherwise
we fallback to the default behavior (the logic to do this will be added to
Zinc after this PR is merged and a new release of sbt-util is made).
2018-08-28 03:58:15 +09:00
Guillaume Martres e905b44a33 Follow-up to the fields added in #173
It turns out that there is more boilerplate to fill that I missed.

Also add deprecation notices.
2018-08-28 02:04:10 +09:00
Eugene Yokota 494f384c49 Formatting 2018-08-16 16:36:41 -04:00
Guillaume Martres 5e3a102606 xsbti.Position: Also add {start,end}{Line,Column}
Positions in the Language Server Protocol and Build Server Protocol are
line/column-based instead of offset-based, so this is more convenient.
Computing the line/column from the offset is possible but requires
reading the source file.
2018-08-14 02:04:55 +09:00
Guillaume Martres 78834527df xsbti.Position: add startOffset and endOffset
A position now has a start, an end, and a point (the existing `offset`),
just like it does in the Scala compiler. This information is especially
useful for displaying squiggly lines in an IDE.

This commit and the next one are required for https://github.com/sbt/zinc/pull/571
2018-08-14 02:04:43 +09:00
Dale Wijnand b1d02bee30
Make checkTypeTag lenient on "scala." type prefix 2018-08-02 07:52:13 +01:00
Eugene Yokota 434e294f28 Fixes the stacktrace trimming
Ref https://github.com/sbt/sbt/issues/4121
Ref https://github.com/sbt/sbt/pull/4232
2018-06-27 06:37:36 -04:00
Eugene Yokota 2b52c7dea0 Merge branch '1.1.x' into wip/merge-1.1.x 2018-06-14 01:11:49 -04:00
Eugene Yokota d2e59fa165 Scala 2.12.6 and other dependencies
sbt 1.1.4
Scala 2.12.6
ScalaCheck 1.14.0
ScalaTest 3.0.5
Contraband 0.4.0
2018-04-28 03:52:33 -04:00
Dale Wijnand 029952895b
Enforce invariant in StringTypeTag optimisation
Or, put differently, "Add a test for sbt/util#153".
2018-04-05 09:43:22 +01:00