Commit Graph

140 Commits

Author SHA1 Message Date
Eugene Yokota c81d269ed2 Merge branch '1.10.x' into wip/merge-1.10.x 2024-05-07 04:39:25 -04:00
Adrien Piquerez 02df82840a add noOp field in BSP compile report 2024-02-15 15:50:02 +01:00
Adrien Piquerez 5515619ecc Implement buildTarget/javacOptions 2023-08-10 16:11:28 +02: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
Eugene Yokota 93bd66b673 Forward ScalaDiagnostic
**Problem**
Zinc added actions in Problem, but it's not yet forwarded to BSP
clients.

**Solution**
As discussed in
https://contributors.scala-lang.org/t/roadmap-for-actionable-diagnostics/6172,
the plan seems to be to use the `data` field with `actions` inside it,
so this implements that.
2023-05-22 00:33:46 -04:00
Eugene Yokota 32ac1ef7da Formatting 2023-03-11 17:02:07 -05:00
Eugene Yokota e5dd518deb Adjust to changes in develop branch 2023-01-16 00:23:05 -05:00
Eugene Yokota 54c12819df Adjust to the code changes 2023-01-15 23:48:13 -05:00
Eugene Yokota 7a5533e8fa Contraband 0.5.3 2023-01-15 23:42:03 -05:00
Eugene Yokota 50b062b795 Port util-logging 2023-01-15 23:40:57 -05:00
Eugene Yokota bb40e1bc87 Merge branch '1.9.x' into wip/merge-1.9.x 2022-12-31 16:28:47 -05:00
Chris Kipp 4a6832f281 fix: ensure sbt server says it's a debugProvider
I believe this was just an oversight that it's not marked as true since
sbt can handle `debugSession/start`. This change just ensures that
during the initialization process sbt says it's a `debugProvider` for
the same languages as `runProvider` and `testProvider`. It also
correctly marks the build targets as `canDebug`, unless they are sbt
targets.
2022-12-29 17:08:22 +01:00
Vadim Chelyshov a2de0643a6 fix: bspConfig sbt.script - use `Path` env variable as a fallback for Windows
Originally reported in https://github.com/scalameta/metals/issues/4702#issuecomment-1339137772
2022-12-06 20:41:14 +03:00
Krzysztof Pado 2bffb2731e Add support for BSP's buildTarget/outputPaths method 2022-08-03 10:13:48 +02:00
Krzysztof Pado 58f0ff612c Add support for BSP's buildTarget/outputPaths method 2022-08-01 19:31:43 -07:00
Kamil Podsiadlo faf8dfde72 bsp: add JVM test/run env capabilities to BSP 2022-04-16 13:46:12 +02:00
Kamil Podsiadlo 85efc87879 feat: generate JVM environment requests 2022-04-12 20:09:26 +02:00
Kamil Podsiadlo 23b50688ba feat: add optional framework field to the bsp 2022-03-04 10:53:25 +01:00
gontard 990fa9530f Ensure sbtConfig argv does not need sbt in PATH
Before, the BSP config .bsp/sbt.json generated by `sbt bspConfig`
contained a command line which required the sbt binary in the PATH.
This fix changes the nature of the -Dsbt.script option. It was
an argument of the main class xsbt.boot.Boot, it's now a system
property and thus it's used to launch the sbt server.

Fixes https://github.com/sbt/sbt/issues/6760
2021-12-26 01:47:21 -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 535b15b83e fix Scala 2.13 warnings 2021-11-14 22:59:34 +09:00
Amina Adewusi 3c81e08fa2 Migrates Treeview.scala to use Contraband
Migrates TreeView.scala to use Contraband from scala.util.parsing.json,
because this is now deprecated.
The TreeView logic is used in the dependencyBrowseTree task.
2021-11-12 16:52:12 +00:00
Igal Tabachnik f209d0093c BSP tasks report progress during compilation 2021-09-09 23:25:06 +03:00
Igal Tabachnik c55880d795 Implementing `buildTarget/cleanCache` to support Rebuild operations from IntelliJ 2021-08-27 17:46:41 +03:00
Adrien Piquerez 2287f3e384 Find sbt.bat in windows $PATH 2021-07-22 09:17:22 +02:00
Adrien Piquerez c4e6cf54d2 Use java to start BSP client 2021-07-22 09:17:22 +02:00
Adrien Piquerez c9ca2d4afa Use `-Dsbt.script` to start sbt server
In order to start the sbt server we must use the sbt script because
it is the only way to load the .sbtopts and the .jvmopts file properly.

To do so the sbt script can pass a -Dsbt.script prop to the java server.
It is used in the NetworkClient to start the server, and it is replicated
in the BuildServerConnection file (.bsp/sbt.json).
2021-07-12 14:20:17 +02:00
Samuel CLARENC c9562cb1c3
Merge branch 'develop' into bspBuildTargetResources 2021-06-21 16:52:58 +02:00
Samuel CLARENC f3ec202a06 Add resourcesProvider flag to BuildServerCapabilities in BSP contra 2021-06-21 16:51:34 +02:00
Samuel CLARENC 56632c3893 Add resources items to BSP contra 2021-06-17 11:15:32 +02:00
Samuel CLARENC e6c2ce084a Add the tag "integration-test" to the it configuration in BSP. 2021-06-17 09:00:15 +02:00
eugene yokota b8691cba88
Merge pull request #6397 from arixmkii/bsp-env-var
Environment variables support in BSP debug session
2021-03-19 11:45:01 -04:00
Adrien Piquerez 503e09ce00 sanitize sbt-launch-jar 2021-03-17 17:44:33 +01:00
Arthur Sengileyev 970ce22aca Environment variables support in BSP debug session 2021-03-15 13:41:50 +02:00
Adrien Piquerez f4d181de22 Add --sb-launch-jar in bsp connection details 2021-01-11 14:38:02 +01:00
Eugene Yokota 45ebeb6d32 Adjust to new Contraband 2020-12-23 13:41:29 -05:00
Eric Peters bc53ea45b2 Add bsp DebugSession messages 2020-12-22 14:16:49 -08:00
João Ferreira 08eaa9fb3b regen contraband 2020-12-21 17:21:54 +00:00
Ethan Atkins bb8b9a1c99 Fix switching between raw and canonical input
There were a number of issues with swithcing between raw and canonical
issues that affected both the server and the thin client. These were
reported in #5863 and #5856. In both cases, there were issues with
reading input or having the input be displayed. Debugging those issues
revealed a number of issues with how we were using the jline 3 system
terminal and the hybrid interaction with the jline 2 terminal. This
commit eliminates all of our internal jline 2 usage. The only remaining
jline 2 usage is that we create and override the global terminal for the
scala console for scala versions < 2.13. By moving away from jline 2, I
was also able to fix #5828, which reported that the home, end and delete
keys were not working.

One of the big issues that this commit addresses is that the
NetworkClient was always performing blocking reads on System.in. This
was problematic because it turns out that you can't switch between raw
and canonical modes when there is a read present. To fix this, the
server now sends a message to the client when it wants to read bytes and
only then does the client create a background thread to read a single
byte.

I also figured out how to set the terminal type properly for the thin
client on windows where we had been manually setting the capabilities to
ansi, which only worked for some keys. This fix required switching to
the WindowsInputStream that I introduced in a prior commit. Before we
were using the jline 2 wrapped input stream which was converting some
system events, like home and end, to the wrong escape sequence mappings.

The remainder of the commit is mostly just converting from jline 2 apis
to jline 3 apis.

I verified that tab completions, the scala console, the ammonite console
and a run task that read from System.in all work with both the server
and the thin client on mac, linux and windows after these changes.

Fixes #5828, #5863, #5856
2020-09-21 13:42:03 -07:00
Adrien Piquerez f5753f763c Add BSP buildTarget/test endpoint 2020-09-21 12:17:20 +02:00
Adrien Piquerez 50cf74cc67 Add BSP `buildTarget/scalaTestClasses` endpoint 2020-09-21 12:17:20 +02:00
Adrien Piquerez 9f04358fce Add BSP buildTarget/run endpoint 2020-09-17 13:40:50 +02:00
Adrien Piquerez 92fb69f370 Add BSP buildTarget/scalaMainClasses endpoint 2020-09-17 13:32:30 +02:00
Adrien Piquerez ac85117841 Add BSP workspace/reload 2020-09-14 13:10:11 +02:00
Adrien Piquerez 97b0347c15 Add bspConfig task 2020-08-17 17:33:48 +02:00
Ethan Atkins 90dacc339c Support scala 2.13 console in thin client
In order to make the console task work with scala 2.13 and the thin
client, we need to provide a way for the scala repl to use an sbt
provided jline3 terminal instead of the default terminal typically built
by the repl. We also need to put jline 3 higher up in the classloading
hierarchy to ensure that two versions of jline 3 are not loaded (which
makes it impossible to share the sbt terminal with the scala terminal).

One impact of this change is the decoupling of the version of
jline-terminal used by the in process scala console and the version
of jline-terminal specified by the scala version itself. It is possible
to override this by setting the `useScalaReplJLine` flag to true. When
that is set, the scala REPL will run in a fully isolated classloader. That
will ensure that the versions are consistent. It will, however, for sure
break the thin client and may interfere with the embedded shell ui.

As part of this work, I also discovered that jline 3 Terminal.getSize is
very slow. In jline 2, the terminal attributes were automatically cached with a
timeout of, I think, 1 second so it wasn't a big deal to call
Terminal.getAttributes. The getSize method in jline 3 is not cached and
it shells out to run a tty command. This caused a significant
performance regression in sbt because when progress is enabled, we call
Terminal.getSize whenever we log any messages. I added caching of
getSize at the TerminalImpl level to address this. The timeout is 1
second, which seems responsive enough for most use cases. We could also
move the calculation onto a background thread and have it periodically
updated, but that seems like overkill.
2020-08-09 17:12:15 -07:00
Ethan Atkins e82c3405b9 Support System.err in thin client
I noticed that when reloading the build, that certain errors are logged
by sbt to System.err. These were not shown to a thin client because we
weren't forwarding System.err. This change remedies that.

System.err is handled more simply than System.out. We do not put
System.err through the progress state because generally System.err is
tends to be unbuffered. I had hesitated to add System.err to the
Terminal interface at all to give users an escape hatch but I couldn't
get project loading to work well with the thin client without it.
2020-07-21 13:27:32 -07:00
adpi2 2c0d09dfb3 Specify full java path in BSP connection details
Use System properties to add java path and classpath to BSP connection details
2020-07-13 13:13:54 +02:00
Ethan Atkins 2ecf5967ee Upgrade LineReader to JLine3
This commit upgrades sbt to using jline3. The advantage to jline3 is
that it has a significantly better tab completion engine that is more
similar to what you get from zsh or fish.

The diff is bigger than I'd hoped because there are a number of
behaviors that are different in jline3 vs jline2 in how the library
consumes input streams and implements various features. I also was
unable to remove jline2 because we need it for older versions of the
scala console to work correctly with the thin client. As a result, the
changes are largely additive.

A good amount of this commit was in adding more protocol so that the
remote client can forward its jline3 terminal information to the server.

There were a number of minor changes that I made that either fixed
outstanding ui bugs from #5620 or regressions due to differences between
jline3 and jline2.

The number one thing that caused problems is that the jline3 LineReader
insists on using a NonBlockingInputStream. The implementation ofo
NonBlockingInputStream seems buggy. Moreover, sbt internally uses a
non blocking input stream for system in so jline is adding non blocking
to an already non blocking stream, which is frustrating.

A long term solution might be to consider insourcing LineReader.java
from jline3 and just adapting it to use an sbt terminal rather than
fighting with the jline3 api. This would also have the advantage of not
conflicting with other versions of jline3. Even if we don't, we may want to
shade jline3 if that is possible.
2020-07-10 13:37:53 -07:00