Skip to content
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

Merged
merged 4 commits into from Mar 8, 2024

Conversation

jkciesluk
Copy link
Member

No description provided.

@jkciesluk jkciesluk force-pushed the unify-bazel branch 3 times, most recently from 3313918 to 473223a Compare February 28, 2024 09:16
@jkciesluk jkciesluk marked this pull request as ready for review February 28, 2024 10:16
@@ -400,6 +401,11 @@ object MetalsEnrichments
workspace.resolve(Directories.readonly).toNIO
)

def isInTmpDirectory(workspace: AbsolutePath): Boolean =
Copy link
Member Author

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?)

@@ -2058,7 +2051,10 @@ class MetalsLspService(
buildTool,
chosenBuildServer,
)
} yield buildChange
} yield {
buildServerPromise.trySuccess(())
Copy link
Contributor

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?

Copy link
Member Author

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.

@@ -63,6 +63,7 @@ class ScalaCliBuildTool(

override def possibleBuildServerNames = ScalaCli.names.toList

override def isAutoConnectable: Boolean = true
Copy link
Contributor

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.

Copy link
Member Author

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

scribe.warn(
"No build session currently active to reload. Attempting to reconnect."
)
reconnectToBuildServer()
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

@kasiaMarek kasiaMarek left a 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(())
Copy link
Contributor

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

@jkciesluk jkciesluk force-pushed the unify-bazel branch 3 times, most recently from eb8166a to 05c6d04 Compare March 7, 2024 09:26
@jkciesluk jkciesluk merged commit 79d276c into scalameta:main Mar 8, 2024
21 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants