Skip to content

Commit 472c975

Browse files
committed
refactor(xlsform2lstsv): Group helpers into GroupHelpers struct
handleBeginGroup had 6 parameters. Bundle sanitizeName and convertRelevance into a GroupHelpers struct; drops to 5 parameters. Also drops an unused TypeInfo import from AppearanceHandler. All 707 tests pass.
1 parent 9452021 commit 472c975

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

src/pipelines/xlsform2lstsv/appearanceHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { APPEARANCES } from '../../generated/Appearances.js';
2-
import { LSType, TypeInfo } from './typeMapper.js';
2+
import { LSType } from './typeMapper.js';
33

44
/**
55
* Surfaces appearance-attribute handling: validates against the registry

src/pipelines/xlsform2lstsv/groupEmitter.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ import { Counters } from './counters.js';
1313
*/
1414
export type GroupCounters = Counters;
1515

16+
/** Helpers passed to handleBeginGroup for name resolution + relevance. */
17+
export interface GroupHelpers {
18+
sanitizeName: (name: string) => string;
19+
convertRelevance: (relevant?: string) => Promise<string>;
20+
}
21+
1622
/**
1723
* Emits G (group) rows and the X-row (note) placeholders that parent-only
1824
* groups become. Owns the group stack, current-group pointer, and pending
@@ -182,10 +188,10 @@ export class GroupEmitter {
182188
row: SurveyRow,
183189
isMessageOnly: boolean,
184190
isParentOnly: boolean,
185-
sanitizeName: (name: string) => string,
186-
convertRelevance: (relevant?: string) => Promise<string>,
191+
helpers: GroupHelpers,
187192
onTableList: (sanitizedName: string) => Promise<void>,
188193
): Promise<void> {
194+
const { sanitizeName, convertRelevance } = helpers;
189195
const originalName = (row.name || '').trim();
190196
const sanitizedName = originalName
191197
? sanitizeName(originalName)

src/pipelines/xlsform2lstsv/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,11 @@ export class XLSFormToTSVConverter {
322322
row,
323323
this.groupProcessor.getMessageOnlyGroups().has(originalName),
324324
this.groupProcessor.getParentOnlyGroups().has(originalName),
325-
(name) => this.fieldNameHandler.sanitizeName(name),
326-
(relevant) => this.transpilerHelper.convertRelevance(relevant),
325+
{
326+
sanitizeName: (name) => this.fieldNameHandler.sanitizeName(name),
327+
convertRelevance: (relevant) =>
328+
this.transpilerHelper.convertRelevance(relevant),
329+
},
327330
(sanitizedName) =>
328331
this.matrixHandler.addTableListHeader(
329332
row,

0 commit comments

Comments
 (0)