Skip to content

Commit

Permalink
read new setting and use default for language
Browse files Browse the repository at this point in the history
  • Loading branch information
brunovieira97 committed Feb 9, 2024
1 parent 8f1fb37 commit 087abac
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/handler/SpecifyLanguageStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { workspace } from "vscode";
import { instrumentOperationStep } from "vscode-extension-telemetry-wrapper";
import { serviceManager } from "../model";
import { Language, MatadataType } from "../model/Metadata";
import { Language, MetadataType } from "../model/Metadata";
import { IPickMetadata, IProjectMetadata, IStep } from "./HandlerInterfaces";
import { SpecifyGroupIdStep } from "./SpecifyGroupIdStep";
import { createPickBox } from "./utils";
Expand All @@ -30,17 +30,27 @@ export class SpecifyLanguageStep implements IStep {

private async specifyLanguage(projectMetadata: IProjectMetadata): Promise<boolean> {
const language: string = projectMetadata.defaults.language || workspace.getConfiguration("spring.initializr").get<string>("defaultLanguage");

if (language) {
projectMetadata.language = language && language.toLowerCase();
return true;
}

const items = await serviceManager.getItems(projectMetadata.serviceUrl, MetadataType.LANGUAGE);

if (projectMetadata.enableSmartDefaults === true) {
projectMetadata.language = items.find(x => x.default === true)?.label.toLowerCase();
return true;
}

const pickMetaData: IPickMetadata<Language> = {
metadata: projectMetadata,
title: "Spring Initializr: Specify project language",
pickStep: SpecifyLanguageStep.getInstance(),
placeholder: "Specify project language.",
items: serviceManager.getItems(projectMetadata.serviceUrl, MatadataType.LANGUAGE),
items: items
};

return await createPickBox(pickMetaData);
}
}

0 comments on commit 087abac

Please sign in to comment.