New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
improvement: Unify connecting to bazelbsp with other build servers #6164
Conversation
3313918
to
473223a
Compare
473223a
to
e968088
Compare
@@ -400,6 +401,11 @@ object MetalsEnrichments | |||
workspace.resolve(Directories.readonly).toNIO | |||
) | |||
|
|||
def isInTmpDirectory(workspace: AbsolutePath): Boolean = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Bazel I was getting errors like
ERROR: no such target '//:.metals/.tmp/Main-5012603866797659764.scala': target '.metals/.tmp/Main-5012603866797659764.scala' not declared in package '' defined by /.../BUILD;
however, a source file of this name exists. (Perhaps add 'exports_files([".metals/.tmp/Main-5012603866797659764.scala"])' to /BUILD?)
metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala
Outdated
Show resolved
Hide resolved
@@ -2058,7 +2051,10 @@ class MetalsLspService( | |||
buildTool, | |||
chosenBuildServer, | |||
) | |||
} yield buildChange | |||
} yield { | |||
buildServerPromise.trySuccess(()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't that happen only on success?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In quickConnectToBuildServer
it happens even if build server is not auto connectable, so I've used similar logic here.
metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala
Outdated
Show resolved
Hide resolved
@@ -63,6 +63,7 @@ class ScalaCliBuildTool( | |||
|
|||
override def possibleBuildServerNames = ScalaCli.names.toList | |||
|
|||
override def isAutoConnectable: Boolean = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scala CLI is only auto-connectable if bsp config exists, and we discover Scala CLI also if project.scala
exists.
On the other hand BspOnly
is definitely auto-connectable.
To me it feels like buildTool.isBspGenerated(folder)
and buildTool.isAutoConnectable
should be the same thing. But my problem might be just with the name.
Let's at least add comments to such things so we know what it means.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I've removed this method and used isBspGenerated
instead
metals/src/main/scala/scala/meta/internal/metals/MetalsEnrichments.scala
Outdated
Show resolved
Hide resolved
scribe.warn( | ||
"No build session currently active to reload. Attempting to reconnect." | ||
) | ||
reconnectToBuildServer() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is now a part of a happy path, I don't think we should emit a warning here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's part of the happy path only on initialize. I think its best to leave the warning here, its still unhappy path is something breaks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overloading slowConnectToBuildServer
is no longer needed to you can probably merge those methods to cleanup a little further. Otherwise, looks good, nice simplification of the logic 馃憤 .
) | ||
} yield () | ||
_ <- slowConnectToBuildServer(forceImport = false), | ||
} yield buildServerPromise.trySuccess(()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
buildServerPromise.trySuccess(())
already happens in slowConnectToBuildServer
eb8166a
to
05c6d04
Compare
No description provided.