Commit Graph

514 Commits

Author SHA1 Message Date
xuwei-k 6c032b8283 some trivial refactoring
- remove unused type params
- use `withFilter` if possible
- use `collectFirst` instead of `collect` and `headOption`
- use `length` instead of `size` if `Array` or `String`
- use `foreach` instead of `map`
2023-06-25 08:57:41 +09:00
xuwei-k 2edb4dcbb6 fix typo 2023-06-24 20:05:52 +09:00
Julien Richard-Foy 72bfb3f45a Transfer copyright to Scala Center 2023-06-20 16:39:07 +02:00
​Andrzej Ressel 4cf2b7269d Cache echoEnabled 2023-06-03 22:44:19 +02:00
Eugene Yokota 9d87f3f596 Add concrete impl for Action 2023-05-14 14:06:46 -04:00
Chris Kipp fa8dfd225d fix: get rid of the `FileChanges` abstraction
I don't believe this is actually needed. We can simplify the
`WorkspaceEdit` further and put together the mapping for `changes`
according to the LSP spec later on down the line. This will allow us to
remove the need for the `URI`, which is problematic.

closes #7252
2023-05-14 09:52:16 +02:00
eugene yokota cf6fac7692
Merge pull request #7242 from ckipp01/action
feat: add in `actions()` to `Problem`
2023-05-12 00:03:49 -04:00
Chris Kipp aeb168aa93 feat: add in `actions()` to `Problem`
This adds a new field into `xsbti.Problem` allowing for the compiler to
forward "actions" that can address diagnostics. The idea largely mimics
a very minimal `CodeAction` that can be found in the [LSP
Spec](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeAction)
in order to ensure it will work with a variety of difference clients
that use LSP, and those that don't. In the future the `WorkspaceEdit`
that was created here could also be expanded to handle more advanced
changes, aka resource operations, like creating/moving/deleting files.
For now we only focus on a small subset of these features.
2023-05-10 14:14:13 +02:00
Chris Kipp 300b770ea4 fix: deprecate misspelled diagnosticRelatedInforamation and add in a new one
Relates to https://github.com/sbt/sbt/discussions/7063
2023-05-08 13:38:15 +02:00
Eugene Yokota 51591bde5b Make new more interactive
If the terminal supports ANSI control sequence,
this displays the template list in an interactive way.
The focused template is rendered reversed,
and arrow key can be used to move the focus up/down.
2023-05-06 20:07:47 -04:00
Adrien Piquerez da4ce68142 Fix dead lock between LoggerContext and Terminal 2023-03-28 14:08:15 +02:00
Chris Kipp dadfee5846 fix: also include diagnosticCode and related info in InterfaceUtil
Looks like I missed this in https://github.com/sbt/sbt/pull/6874 and I
hit on it in Mill when I couldn't figure out why it was also empty, and
thanks to @adpi realized it was because of the `LoggedReporter` in zinc
not taking it into account. However before I can bump that this needs to
be bumped as well.

refs: https://github.com/lampepfl/dotty/issues/14904
2022-10-02 04:50:44 -04:00
Adrien Piquerez 634e8799e7 Catch ClosedChannelException in background job logger
We want the background job to stay alive even if its terminal
has been closed and we cannot write to it anymore
2022-08-05 14:45:38 +02:00
Adrien Piquerez 592086b889 Don't use ProxyTerminal in background job
If we use the ProxyTerminal in the background jobs, the logs
would be spread across different terminals, switching from active
client to active client. We want the logs to stick
to the client that started the job.
2022-08-04 16:48:13 +02:00
Adrien Piquerez 6bcda6684a Use BackgroundJobService context instead of MainLoop context
A new context is created and closed for each state of the MainLoop.
But the context of the backgroundJob must stay alive.
So we use a context that is owned by the BackgroundJobService.
It creates a new logger for each background job and cleans it when
the job stops.
2022-08-04 16:48:13 +02:00
Eugene Yokota 2462d5fbcf Fix proxyInputStream#available
proxyInputStream does not override available,
which broke sbt-site previewSite.
This fixes that.
2022-07-10 04:35:57 -04:00
eugene yokota 910ab1951f
Merge pull request #6846 from Nirvikalpa108/fix-deadlock
[1.7.x] Attempts to fix sbt#6810 - deadlock issue
2022-06-26 22:50:22 -04:00
Chris Kipp f90b09f1ee feat: update Problem to account for related information and code
This PR makes changes to the existing `xsbti.Problem` to account for an
optional diagnostic code that the compiler can return for a given
diagnostic and also related information.

Given a piece of code like:

```scala
try {}
```

You'll receive the following:

```
-- [E002] Syntax Warning: /Users/ckipp/Documents/scala-workspace/dotty-error-index/examples/002_EmptyCatchAndFinallyBlockID.scala:3:2
3 |  try {}
  |  ^^^^^^
  |  A try without catch or finally is equivalent to putting
  |  its body in a block; no exceptions are handled.
```

The `E002` here is the actual code. Right now there would be no
description.

Some diagnostics have multiple positions that they need to represent.
You can see an example of this
[here](lampepfl/dotty#14002) in Dotty with the
use of inlining. Instead of needing to rely on including all of that
information in the diagnostic message it can now be extracted out into
a `DiagnosticRelatedInformation`.

These changes reference the conversation in #6868
2022-04-12 11:13:19 +02:00
Amina Adewusi 020385d917 Attempts to fix sbt#6810 - deadlock issue 2022-03-18 17:23:30 +00:00
Amina Adewusi ca8fd354bd Fixes parsing command args quote problem
Fixes #6802.
2022-02-04 17:52:39 +00:00
tpetillot 4f9fe2af64 fix: propagate `InterruptedException` from JLine.readLine
Motivation:
Cannot exit from InteractionService.readLine

Modification:
Remove try/catch of InterruptedException mapped to None in JLine.readLine
2022-01-31 21:40:32 -05:00
David Francoeur a448b1caab
Load credentials from SBT_CREDENTIALS (#6724)
Load credentials from SBT_CREDENTIALS
Prefer sys.env to System.getenv
2021-11-27 02:44:49 -05:00
xuwei-k 5c90a84c72 SourcePositionMacro for Scala 3 2021-11-16 16:32:31 +09:00
eugene yokota b3aae681bf
Merge pull request #6711 from xuwei-k/fix-scala-2-13-warn
fix Scala 2.13 warnings
2021-11-14 21:53:57 -05:00
xuwei-k 535b15b83e fix Scala 2.13 warnings 2021-11-14 22:59:34 +09:00
xuwei-k aa8b1141f8 Update scalatest 2021-11-14 22:03:59 +09:00
Eric Peters c1ed109f89 Update MainAppender.defaulScreen to use passed in console arg #6678 2021-09-29 07:39:09 -07:00
Eric Peters 804bd4b8b5 Rename internal/util-logging/src/main/scala/sbt/internal/util/MainLogging.scala to MainAppender.scala to match contents 2021-09-29 07:34:20 -07:00
Amina Adewusi 696a19f5d7 Virtualize Sync.sync so it can be cached remotely for resources dir syncing
An alternative to https://github.com/sbt/sbt/pull/6554.
2021-07-31 18:23:30 +01:00
eugene yokota d3db8388b6
Merge branch 'develop' into fix-carriage-return 2021-06-20 18:07:29 -04:00
Eugene Yokota 8628f95e66 lazily initialize ProxyTerminal to SimpleTerminal
Problem
-------
Console.systemOut is hooked up to Terminal.get, which internally calls
ProxyTerminal, which lets us deffer the wiring of terminal to
activeTerminal. This mechanism allows us to swap out the terminal
capable of standard out forwarding for sbtn.
However, as it stands this breaks the contract of being able to use
Console.systemOut with wrapped inside of `Terminal.withStreams() {...}`.

Solution
--------
Check if `activeTerminal.get` returns `null`, and if so initialize it to
the conventional `Terminal.SimpleTerminal`, which behaves as expected.
2021-06-20 17:32:42 -04:00
Sebastian Alfers d339863041 Fix carriage return in supershell progress state 2021-06-20 15:41:59 +02:00
Adrien Piquerez bf29e2a908 Fix size of server running message 2021-02-24 17:31:28 +01:00
Eugene Yokota 22d12f6618 Use nowarn annotation 2021-02-06 22:31:47 -05:00
Eugene Yokota 61a077e3a6 Scala 2.12.13 2021-01-31 12:59:31 -05:00
Sam Halliday 816208f081 Terminal support for GNU Emacs 2021-01-21 10:50:57 +00:00
Eugene Yokota 58dfca6e27 Avoid the whitespace after completion 2021-01-15 16:43:19 -05:00
Eugene Yokota 8f5759e48d Cross build to Scala 2.13 2021-01-10 20:24:05 -05:00
João Ferreira 08eaa9fb3b regen contraband 2020-12-21 17:21:54 +00:00
Eugene Yokota 76c4ae56f0 Revert "Set complete flag in completions"
This reverts commit edf43a473b.
This fixes performance regression of tab completion observerd in https://github.com/sbt/sbt/issues/6204
2020-12-19 00:01:16 -05:00
Ethan Atkins 90ca463c70 Add signal registration in LineReader
It is possible for the signal handler to get in a state where it has no
effect in the shell. When this happens, entering ctrl+c does not exit
the shell. To ensure that ctrl+c always exits the shell, we can register
a signal handler in the line reader that write -1 to the terminal input
stream, which should cause the line reader to return an exit command.
2020-11-25 14:31:29 -08:00
Ethan Atkins c24e7da844 Rethrow InterruptedException instead of ClosedException
There are cases where sbt will incorrectly shutdown if the jline reader
is interrupted while filling the input buffer. To fix this we can throw
an InterruptedException instead of a ClosedException.

The repro for this was start `sbt`, input `~compile` and while sbt was
starting up, open a source file with vim using the metals bsp
integration. sbt server would end up shutting down everytime after a
single compilation iteration.
2020-11-25 14:31:29 -08:00
Eugene Yokota bd7a2e05bf Use `Global / localCacheDirectory` for remote caching
Fixes https://github.com/sbt/sbt/issues/6102

https://github.com/sbt/sbt/pull/6026 changed the implementation of remote cache to NOT use dependency resolution (Coursier), and directly use Ivy resolver for efficiency. This was good, but when I made the change, I've changed the cache directory to be `crossTarget.value / "remote-cache"`. This was ok for local testing purpose, but not great for real usage since we don't want the cache to be wiped out either in the CI machines or on a local laptop.

This adds a new Global key called `localCacheDirectory`. Similar to Coursier cache, this is meant to be shared across all builds running on a machine. Also similar to Coursier cache this will try to follow the operating system specifc caching directory.

### localCacheDirectory location

- Environment variable: `SBT_LOCAL_CACHE`
- System property: `sbt.global.localcache`
- Windows: %LOCALAPPDATA%\sbt\v1
- macOS: $HOME/Library/Caches/sbt/v1
- Linux: $HOME/.cache/sbt/v1
2020-11-22 14:35:20 -05:00
Ethan Atkins 2cf431ee8a Print empty newlines with progress
With the latest sbt code, the `last` command displayed all of the output
without line separators. This occurred because the logic for appending
bytes to System.out split the input bytes on the line separator but if
there was nothing but the line separator in the input bytes then the
result was empty.
2020-11-20 11:35:20 -08:00
Ethan Atkins 3ff85b175d Only evaluate log message thunk once
When there are multiple console appenders for a logger, we inadvertently
evaluated the message thunk for each appender which would cause side
effects to be unexpectedely evaluated multiple times.

Fixes part of #6126.
2020-11-19 14:58:48 -08:00
eugene yokota f4921e3dd7
Merge pull request #6105 from eatkins/jline3-upgrade
JLine 3.17.1
2020-11-18 22:31:02 -05:00
eugene yokota 9985cb4b1c
Merge pull request #6115 from eatkins/thin-client-startup
Fix thin client sbt process startup output
2020-11-18 18:26:28 -05:00
Ethan Atkins f3120f8f15 Fix supershell blowing away lines on windows
In 85d17889b6, I attempted to fix
supershell messages getting interlaced with log lines. It turned out
that that approach didn't work with windows and was causing all of the
output to bet blown away. A better approach is to check if the bytes
we're writing contain one or more line separators. If so, we can wrap
the bytes in a string and split the string into lines. Then we can
append a ClearScreenAfterCursor before every newline.

I think the problem with windows was that the ClearScreenAfterCursor was
coming between the carraige return and the newline.
2020-11-18 13:42:52 -08:00
Ethan Atkins 8137c80782 Fix thin client sbt process startup output
The boot server socket was not working correctly when the sbt server was
started by the thin client. This was because it is necessary for us to
create a ConsoleTerminal in order for System.out and System.err to be
properly forwarded to the clients connected over the boot server socket.
As a result, if you started a server instance of sbt with the thin
client, you wouldn't see any output util you connected to the server.
The fix is to just make sure that we create a console terminal if sbt is
run as a subprocess.
2020-11-18 12:38:44 -08:00
Ethan Atkins c34678e9db Upgrade jline 3
We no longer need to use the forked version of jline because they have
merged in our required changes. The latest version of jline does upgrade
jansi, however, and some of the apis we were relying on for windows were
removed so they had to be manually implemented. I verified that console
input still worked on my windows vm after this change.
2020-11-18 12:18:08 -08:00