-
Notifications
You must be signed in to change notification settings - Fork 414
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
Ask users to import projects when opening a new folder #1501
Conversation
const config = getJavaConfiguration(); | ||
const isMavenImporterEnabled: boolean = config.get<boolean>("import.maven.enabled"); | ||
const isGradleImporterEnabled: boolean = config.get<boolean>("import.gradle.enabled"); | ||
const patterns: string[] = []; | ||
if (isMavenImporterEnabled) { | ||
patterns.push("**/pom.xml"); | ||
} | ||
if (isGradleImporterEnabled) { | ||
patterns.push("**/build.gradle"); | ||
} |
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.
we need to figure out a way to let 3rd party extensions (eg. bazel) register patterns/import prefs from their package.json (something similar to extension jars)
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.
Something like this?
"contributes": {
"javaConfigurationFiles": [
{
"name": "BUILD",
"contentPattern": "java_binary\\s*\\([\\s\\S]*\\)" <--- optional
}
],
"javaExtensions": [
...
],
...
}
where contentPattern
is optional, since for Bazel
, the BUILD
file can also be used to build other language's project, so we need a regex pattern to test towards the file content.
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.
IMO, you doesn't need test against the file content, because vscode-java won't be automatically activated when detecting BUILD file.
"contributes": {
"javaBuildFiles": [
{
"fileNamePattern": "BUILD"
}
]
}
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.
Hard to say... If the third-party extension depends on vscode-java, then it will be activated.
@@ -30,8 +30,7 @@ | |||
"onLanguage:java", | |||
"workspaceContains:pom.xml", | |||
"workspaceContains:build.gradle", | |||
"workspaceContains:.classpath", | |||
"onCommand:java.project.import" |
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.
why would you remove it? If you start from an empty folder, then add a pom.xml, you'd want to be able to trigger import even though vscode-java hasn't started yet
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.
There is no API to let the extension know which event activates it. When VS Code Java is activated by this command, the user will be asked again to confirm the import again. Is it acceptable?
Maybe a better solution is to let VS Code check the adding files for workspaceContains
: microsoft/vscode#28122.
0c5653a
to
a3d5266
Compare
@jdneo can you please fix the conflict? |
Signed-off-by: Sheng Chen <sheche@microsoft.com>
Signed-off-by: Sheng Chen <sheche@microsoft.com>
Signed-off-by: Sheng Chen <sheche@microsoft.com>
Signed-off-by: Sheng Chen <sheche@microsoft.com>
Signed-off-by: Sheng Chen <sheche@microsoft.com>
@fbricon Sure, rebased. |
Everytime I close the vscode window, the syntax server fails to stop on its own, looks like it never receives the shutdown request |
Signed-off-by: Sheng Chen <sheche@microsoft.com>
I tried using |
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.
Everytime I close the vscode window, the syntax server fails to stop on its own, looks like it never receives the shutdown request
+1, I observed similar behavior before. Not sure if it's related to this change but I would suggest that we work on a safety net that ensures all Java processes created by vscode-java are closed upon exit. Maybe in a separate PR?
I observed the lightweight server is still running for a while after i forced to close VS Code window. However, it would automatically exit after about 1 minute. Below is the log.
|
The Standard mode looks like the same behavior as "Parent process stopped running, forcing server exit". |
Signed-off-by: Sheng Chen <sheche@microsoft.com>
I see the standard server receiving
but never for the syntax server |
From the client log, I can see the shutdown command is never sent for the syntax client, but it is for the standard client, which explains my previous comment. But looking at the code, I don't see why this is not working the same for both. |
The server shutting down on its own after about 30 sec is thanks to https://github.com/eclipse/eclipse.jdt.ls/blob/master/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/ParentProcessWatcher.java#L49 |
@fbricon @testforstephen @akaroml @jdneo could you try the following Java LS patch:
|
The issue happens when ResourcesPlugin.getWorkspace().save(true, monitor) takes more than five seconds in which case VS Code doesn't send the exit command. |
OK, I can now repro this on Mac. Seems this issue is not reproduceable on Windows. |
@snjeza Thank you for the patch! It works while it has a limitation. It ensures the language serve will be shut down if the initialize request is finished. If the VS Code is closed before the initialize response is sent from the language server, the client will not send the shutdown event to the server -- which is a restriction of LSP. Thus the servers will still be running. (to simply repro this, you can close the VS Code at the moment when the spinning icon shows at the staus-bar). // BTW, I suggest to discuss this topic in another new issue thread, since it's out of this PR's scope. |
so I found out the extension.deactivate() function is never called when the server is started in hybrid mode but the projects have not been imported. So the syntax server client is never stopped, so never sends the shutdown signal. I just can't figure out why |
please open a PR in jdt.ls, that's a different issue |
Signed-off-by: Sheng Chen <sheche@microsoft.com>
In case the user may not select an option when asking import. I did some more changes to make sure the vscode java will resolve the API when the asking is needed. |
Signed-off-by: Sheng Chen <sheche@microsoft.com>
Signed-off-by: Sheng Chen <sheche@microsoft.com>
|
||
async function promptUserForStandardServer(config: WorkspaceConfiguration): Promise<boolean> { | ||
const choice: string = await window.showInformationMessage("The workspace contains Java projects, would you like to import them?", "Yes", "Always", "Later"); | ||
switch (choice) { |
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.
should we add Never?
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.
Hmm... Personal option is not including Never here. Since our final goal is to let users to use all the features of VS Code Java.
Thanks @jdneo! |
|
Signed-off-by: Sheng Chen sheche@microsoft.com