From 5703f0278610f836a0b07f1c577cbcbe107f55ca Mon Sep 17 00:00:00 2001 From: Alex Rosengarten Date: Wed, 4 Mar 2020 12:07:18 -0800 Subject: [PATCH] rm generator --- src/tools/recipe2plan.ts | 4 ++-- src/tools/storage-key-recipe-resolver.ts | 6 ++++-- src/tools/tests/storage-key-recipe-resolver-test.ts | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/tools/recipe2plan.ts b/src/tools/recipe2plan.ts index ecec24960f6..b03977723df 100644 --- a/src/tools/recipe2plan.ts +++ b/src/tools/recipe2plan.ts @@ -21,7 +21,7 @@ import {StorageKeyRecipeResolver} from './storage-key-recipe-resolver.js'; export async function recipe2plan(path: string): Promise { const manifest = await Runtime.parseFile(path); - const recipes = new StorageKeyRecipeResolver(manifest).resolve(); + const recipes = await (new StorageKeyRecipeResolver(manifest)).resolve(); const plans = await generatePlans(recipes); @@ -35,7 +35,7 @@ export async function recipe2plan(path: string): Promise { * @param resolutions A series of resolved recipes. * @return List of generated Kotlin plans */ -async function generatePlans(resolutions: AsyncIterator): Promise { +async function generatePlans(resolutions: Recipe[]): Promise { // TODO Implement return ['']; } diff --git a/src/tools/storage-key-recipe-resolver.ts b/src/tools/storage-key-recipe-resolver.ts index 3b2b8e1c612..12f58262dbf 100644 --- a/src/tools/storage-key-recipe-resolver.ts +++ b/src/tools/storage-key-recipe-resolver.ts @@ -36,7 +36,8 @@ export class StorageKeyRecipeResolver { * @throws Error if recipe fails to resolve on first or second pass. * @yields Resolved recipes with storage keys */ - async* resolve(): AsyncGenerator { + async resolve(): Promise { + const recipes = []; for (const recipe of this.runtime.context.allRecipes) { const arc = this.runtime.newArc(this.getArcId(recipe), ramDiskStorageKeyPrefixForTest()); const opts = {errors: new Map()}; @@ -49,8 +50,9 @@ export class StorageKeyRecipeResolver { if (!resolved.isResolved()) { throw Error(`Recipe ${resolved.name} did not properly resolve!\n${resolved.toString({showUnresolved: true})}`); } - yield resolved; + recipes.push(resolved) } + return recipes; } /** diff --git a/src/tools/tests/storage-key-recipe-resolver-test.ts b/src/tools/tests/storage-key-recipe-resolver-test.ts index 44e11b41b11..1fb12a44f59 100644 --- a/src/tools/tests/storage-key-recipe-resolver-test.ts +++ b/src/tools/tests/storage-key-recipe-resolver-test.ts @@ -42,7 +42,7 @@ describe('recipe2plan', () => { data: reads data`); const resolver = new StorageKeyRecipeResolver(manifest); - for await (const it of resolver.resolve()) { + for (const it of (await resolver.resolve())) { assert.isTrue(it.isResolved()); } });