Skip to content

Commit 8d3b397

Browse files
authored
Merge pull request #1976 from obsidian-tasks-group/simplify-grouping-code
refactor: Simplify grouping code in Field.ts
2 parents 650cd22 + 2c486f5 commit 8d3b397

File tree

2 files changed

+1
-38
lines changed

2 files changed

+1
-38
lines changed

src/Query/Filter/Field.ts

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -264,41 +264,6 @@ export abstract class Field {
264264
return false;
265265
}
266266

267-
/**
268-
* Parse a 'group by' line and return a {@link Grouper} object.
269-
*
270-
* Returns null line does not match this field or is invalid,
271-
* or this field does not support grouping.
272-
*/
273-
public parseGroupLine(line: string): Grouper | null {
274-
if (!this.supportsGrouping()) {
275-
return null;
276-
}
277-
278-
if (!this.canCreateGrouperForLine(line)) {
279-
return null;
280-
}
281-
282-
return this.createGrouperFromLine(line);
283-
}
284-
285-
/**
286-
* Returns true if the class can parse the given 'group by' instruction line.
287-
*
288-
* Current implementation simply checks whether the class does support grouping,
289-
* and whether the line matches this.grouperRegExp().
290-
* @param line - A line from a ```tasks``` block.
291-
*
292-
* @see {@link createGrouperFromLine}
293-
*/
294-
public canCreateGrouperForLine(line: string): boolean {
295-
if (!this.supportsGrouping()) {
296-
return false;
297-
}
298-
299-
return Field.lineMatchesFilter(this.grouperRegExp(), line);
300-
}
301-
302267
/**
303268
* Parse the line, and return either a {@link Grouper} object or null.
304269
*
@@ -309,8 +274,6 @@ export abstract class Field {
309274
* this method.
310275
*
311276
* @param line - A 'group by' line from a ```tasks``` block.
312-
*
313-
* @see {@link canCreateGrouperForLine}
314277
*/
315278
public createGrouperFromLine(line: string): Grouper | null {
316279
if (!this.supportsGrouping()) {

src/Query/FilterParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export function parseGrouper(line: string): Grouper | null {
101101
// See if any of the fields can parse the line.
102102
for (const creator of fieldCreators) {
103103
const field = creator();
104-
const grouper = field.parseGroupLine(line);
104+
const grouper = field.createGrouperFromLine(line);
105105
if (grouper) {
106106
return grouper;
107107
}

0 commit comments

Comments
 (0)