Skip to content

Configure IDE with sbt server #5160

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Oct 17, 2018

Conversation

Duhemm
Copy link
Contributor

@Duhemm Duhemm commented Sep 25, 2018

  • When there's no sbt project, offer to create a new sbt project:
    • build.sbt
    • project/build.properties
    • project/plugins.sbt
  • Try to connect to a running sbt server instance or start a new server.
    • If vscode cannot connect to sbt, ask the user to try again.
  • Run configureIDE using sbt/exec
    • Report error when it fails, asking the user to try again
  • Periodically check that sbt is still alive; start a new instance otherwise.

const sbtCheckIntervalMs = 10 * 1000

/** A command that we use to check that sbt is still alive. */
export const nopCommand = "nop"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is the way to do things:

  • If the connection with sbt is closed, we don't need this since we can have a callback on connection.onClose
  • If sbt blocks while running something, then we will never get a response since there's no timeout for a response
  • We can't add a timeout for the response, because an sbt command can take an arbitrarily long time to finish (e.g. running tests) and sbt cannot execute more than one command at once.

I think a real solution will require changes to sbt, but I don't know what exactly.

@Duhemm Duhemm force-pushed the wip/vscode-create-config branch from 3f453b4 to 1601cda Compare October 1, 2018 12:50
@Duhemm
Copy link
Contributor Author

Duhemm commented Oct 1, 2018

Remove nop. It's now relying on connection.close to reconnect.

This commis adds a status bar that shows the status of sbt server, and a
timer that periodically checks that sbt server is still alive, starting
a new instance if necessary.
We use `connection.onClose` to automatically reconnect when the
connection with sbt is closed.
@Duhemm Duhemm force-pushed the wip/vscode-create-config branch from 1601cda to c1f0e75 Compare October 10, 2018 06:32
@Duhemm
Copy link
Contributor Author

Duhemm commented Oct 10, 2018

@smarter Everything seems to work on Windows now!

@@ -71,7 +71,7 @@
"scala-lang.scala"
],
"dependencies": {
"child-process-promise": "^2.2.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -3,7 +3,7 @@
import * as fs from 'fs';
import * as path from 'path';

import * as cpp from 'child-process-promise';
import * as cpp from 'promisify-child-process';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be pcp instead of cpp, or childProcess if we want to be explicit.

const sbtBuildSbtFile = path.join(workspaceRoot, "build.sbt")
const languageServerArtifactFile = path.join(workspaceRoot, ".dotty-ide-artifact")

function isUnconfiguredProject() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe call this isConfiguredProject to avoid too many negations ?

}
})
}

configuredProject
.then(_ => connectToSbt(coursierPath))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since starting sbt and running configureIDE might be very slow, I suggest we do not do it if the project has already been configured once (i.e., .dotty-ide-artifact, .dotty-ide.json are present). In the future, the Dotty Language Server will decide itself if it should query the build tool for configuration options.

@Duhemm
Copy link
Contributor Author

Duhemm commented Oct 17, 2018

@smarter I removed some of the stuff that dealt with sbt server (but we're still using it).
d27f5a4 is the commit to revert if/when we decide to revive that.

@Duhemm Duhemm force-pushed the wip/vscode-create-config branch 2 times, most recently from b7aa9fd to d57c16a Compare October 17, 2018 13:35
@Duhemm
Copy link
Contributor Author

Duhemm commented Oct 17, 2018

Why {} instead of void ?

Right, I changed it.

If disableDottyIDEFile then the project is not configured, but we should not try to configure it either and just quit the extension, the logic to do this seems to have been lost.

Argh, thanks, I fixed it too.

@@ -83,7 +82,7 @@ export function activate(context: ExtensionContext) {

} else {
let configuredProject: Thenable<void> = Promise.resolve()
if (isUnconfiguredProject()) {
if (!isConfiguredProject()) {
configuredProject = vscode.window.showInformationMessage(
"This looks like an unconfigured Scala project. Would you like to start the Dotty IDE?",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this message is still going to be shown if disableDottyIDEFile is present

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️

This commit changes the behavior of the IDE so that it runs
`configureIDE` only if the project hasn't been configured yet. sbt will
now be started only if necessary, and the server will not be kept alive
longer than necessary.
@Duhemm Duhemm force-pushed the wip/vscode-create-config branch from d57c16a to d27f5a4 Compare October 17, 2018 14:03
@smarter smarter merged commit c63cbd5 into scala:master Oct 17, 2018
@allanrenucci allanrenucci deleted the wip/vscode-create-config branch October 17, 2018 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants