fix: Support creating new project when no workspace folder (#1163)
This commit is contained in:
Родитель
b63118547a
Коммит
058fe3e484
|
@ -38,7 +38,8 @@
|
|||
"workspaceContains:build.gradle",
|
||||
"workspaceContains:settings.gradle",
|
||||
"workspaceContains:build.gradle.kts",
|
||||
"workspaceContains:settings.gradle.kts"
|
||||
"workspaceContains:settings.gradle.kts",
|
||||
"onCommand:gradle.createProject"
|
||||
],
|
||||
"main": "./dist/index.js",
|
||||
"contributes": {
|
||||
|
@ -479,11 +480,7 @@
|
|||
},
|
||||
{
|
||||
"command": "gradle.createProject",
|
||||
"when": "gradle:extensionActivated && !java:projectManagerActivated"
|
||||
},
|
||||
{
|
||||
"command": "gradle.createProjectAdvanced",
|
||||
"when": "gradle:extensionActivated"
|
||||
"when": "!java:projectManagerActivated"
|
||||
}
|
||||
],
|
||||
"view/title": [
|
||||
|
|
|
@ -240,7 +240,7 @@ export class Extension {
|
|||
|
||||
private async activate(): Promise<void> {
|
||||
const activated = !!(await this.rootProjectsStore.getProjectRoots()).length;
|
||||
if (activated && !this.server.isReady()) {
|
||||
if (!this.server.isReady()) {
|
||||
await this.server.start();
|
||||
}
|
||||
await vscode.commands.executeCommand("setContext", "gradle:activated", activated);
|
||||
|
|
|
@ -47,7 +47,7 @@ export class CreateProjectCommand extends Command {
|
|||
const success = await this.runSteps(metadata);
|
||||
if (success) {
|
||||
await this.createProject(metadata);
|
||||
const openInNewWindow = !(folders && folders.length);
|
||||
const openInNewWindow = folders !== undefined;
|
||||
vscode.commands.executeCommand(
|
||||
"vscode.openFolder",
|
||||
vscode.Uri.file(metadata.targetFolder),
|
||||
|
|
|
@ -71,10 +71,12 @@ public class GradleLanguageServer implements LanguageServer, LanguageClientAware
|
|||
Map<?, ?> initOptions = new Gson().fromJson((JsonElement) params.getInitializationOptions(), Map.class);
|
||||
// TODO: support multiple workspace folders
|
||||
List<WorkspaceFolder> workspaceFolders = params.getWorkspaceFolders();
|
||||
for (WorkspaceFolder folder : workspaceFolders) {
|
||||
URI uri = URI.create(folder.getUri());
|
||||
this.gradleServices.getLibraryResolver().setWorkspacePath(Paths.get(uri));
|
||||
break;
|
||||
if (workspaceFolders != null) {
|
||||
for (WorkspaceFolder folder : workspaceFolders) {
|
||||
URI uri = URI.create(folder.getUri());
|
||||
this.gradleServices.getLibraryResolver().setWorkspacePath(Paths.get(uri));
|
||||
break;
|
||||
}
|
||||
}
|
||||
Object settings = initOptions.get("settings");
|
||||
this.gradleServices.applySetting(settings);
|
||||
|
|
Загрузка…
Ссылка в новой задаче