Skip to content

Commit

Permalink
enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
chunyu3 committed Jan 15, 2025
1 parent 72dc2a9 commit 5e07e08
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions packages/typespec-vscode/src/vscode-cmd/emit-code/emit-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,19 @@ async function configureEmitter(
context: vscode.ExtensionContext,
existingEmitters: string[],
): Promise<Emitter | undefined> {
const emitterKinds = getRegisterEmitterTypes();
const emitterKinds = getRegisterEmitterTypes().filter((kind) => {
return (
getRegisterEmitters(kind).filter((emitter) => !existingEmitters.includes(emitter.package))
.length > 0
);
});
if (emitterKinds.length === 0) {
logger.info("No new emitter available. All emitters are already configured.", [], {
showOutput: true,
showPopup: true,
});
return undefined;
}
const toEmitterTypeQuickPickItem = (kind: EmitterKind): any => {
const registerEmitters = getRegisterEmitters(kind);
const supportedLanguages = registerEmitters.map((e) => e.language).join(", ");
Expand Down Expand Up @@ -290,7 +302,7 @@ async function doEmit(mainTspFile: string, emitter: Emitter) {
return;
}
/*Config emitter output dir and emit in tspconfig.yaml. */
const defaultEmitOutputDirInConfig = `{project-root}/${emitter.kind}/${getLanguageAlias(emitter.language)}`;
const defaultEmitOutputDirInConfig = `{output-dir}/${emitter.package}`;
const tspConfigFile = path.join(baseDir, TspConfigFileName);
let configYaml = parseDocument(""); //generate a empty yaml
if (await isFile(tspConfigFile)) {
Expand Down Expand Up @@ -532,12 +544,7 @@ export async function emitCode(context: vscode.ExtensionContext, uri: vscode.Uri
fromConfig: false,
package: "",
kind: vscode.QuickPickItemKind.Default,
buttons: [
{
iconPath: new vscode.ThemeIcon("settings-gear"),
tooltip: "Configure a new emitter for code generation",
},
],
iconPath: new vscode.ThemeIcon("settings-gear"),
};

const allPickItems = [];
Expand Down

0 comments on commit 5e07e08

Please sign in to comment.