Skip to content

Commit 86096e7

Browse files
committed
Refactor multiple files parser helpers into individual module files and remove the barrel export file
- rename text processing to 'process-conflict-markers' - in helpers, file names should follow exported function names. make sure each file exports only one function └── apps └── editor └── src └── commands └── apply-response-command └── utils └── response-parser └── parsers └── multiple-files-parser ├── helpers │ ├── create-or-update-file-item.ts │ ├── extract-and-set-workspace-path.ts │ ├── flush-text-block.ts │ ├── item-management.ts │ └── process-conflict-markers.ts └── multiple-files-parser.ts
1 parent abb14f6 commit 86096e7

6 files changed

Lines changed: 21 additions & 25 deletions

File tree

apps/editor/src/commands/apply-response-command/utils/response-parser/parsers/multiple-files-parser/helpers/item-management.ts renamed to apps/editor/src/commands/apply-response-command/utils/response-parser/parsers/multiple-files-parser/helpers/create-or-update-file-item.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { FileItem, TextItem, InlineFileItem } from '../../../response-parser'
2-
import { process_conflict_markers } from './text-processing'
2+
import { process_conflict_markers } from './process-conflict-markers'
33

44
export const create_or_update_file_item = (params: {
55
file_name: string
@@ -93,19 +93,3 @@ export const create_or_update_file_item = (params: {
9393
params.results.push(new_file)
9494
}
9595
}
96-
97-
export const flush_text_block = (params: {
98-
text_block: string
99-
results: (FileItem | TextItem | InlineFileItem)[]
100-
}) => {
101-
if (!params.text_block.trim()) {
102-
return
103-
}
104-
105-
const content =
106-
params.results.length == 0
107-
? params.text_block.trim()
108-
: params.text_block.trimEnd()
109-
110-
params.results.push({ type: 'text', content })
111-
}

apps/editor/src/commands/apply-response-command/utils/response-parser/parsers/multiple-files-parser/helpers/path-utils.ts renamed to apps/editor/src/commands/apply-response-command/utils/response-parser/parsers/multiple-files-parser/helpers/extract-and-set-workspace-path.ts

File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { FileItem, TextItem, InlineFileItem } from '../../../response-parser'
2+
3+
export const flush_text_block = (params: {
4+
text_block: string
5+
results: (FileItem | TextItem | InlineFileItem)[]
6+
}) => {
7+
if (!params.text_block.trim()) {
8+
return
9+
}
10+
11+
const content =
12+
params.results.length == 0
13+
? params.text_block.trim()
14+
: params.text_block.trimEnd()
15+
16+
params.results.push({ type: 'text', content })
17+
}

‎apps/editor/src/commands/apply-response-command/utils/response-parser/parsers/multiple-files-parser/helpers/index.ts‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

apps/editor/src/commands/apply-response-command/utils/response-parser/parsers/multiple-files-parser/helpers/text-processing.ts renamed to apps/editor/src/commands/apply-response-command/utils/response-parser/parsers/multiple-files-parser/helpers/process-conflict-markers.ts

File renamed without changes.

‎apps/editor/src/commands/apply-response-command/utils/response-parser/parsers/multiple-files-parser/multiple-files-parser.ts‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import { extract_path_from_line_of_code } from '@shared/utils/extract-path-from-line-of-code'
22
import { FileItem, TextItem, InlineFileItem } from '../../response-parser'
3-
import {
4-
extract_and_set_workspace_path,
5-
create_or_update_file_item,
6-
flush_text_block
7-
} from './helpers'
3+
import { create_or_update_file_item } from './helpers/create-or-update-file-item'
4+
import { flush_text_block } from './helpers/flush-text-block'
5+
import { extract_and_set_workspace_path } from './helpers/extract-and-set-workspace-path'
86

97
export const parse_multiple_files = (params: {
108
response: string

0 commit comments

Comments
 (0)