Skip to content

Commit 243e07a

Browse files
committed
refactor: Move fallback extensions to supported-extensions.ts
- Consolidate fallback extensions functionality into supported-extensions.ts - Update imports in parser.ts and test files - Remove separate fallback-extensions.ts file - All functionality remains the same, just better organized
1 parent b98ab9c commit 243e07a

File tree

4 files changed

+31
-30
lines changed

4 files changed

+31
-30
lines changed

src/services/code-index/processors/__tests__/parser.vb.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ vi.mock("../../../../../packages/telemetry/src/TelemetryService", () => ({
1111
},
1212
}))
1313

14-
import { shouldUseFallbackChunking } from "../../shared/fallback-extensions"
14+
import { shouldUseFallbackChunking } from "../../shared/supported-extensions"
1515

1616
describe("CodeParser - VB.NET and Fallback Extensions Support", () => {
1717
let parser: CodeParser

src/services/code-index/processors/parser.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import { Node } from "web-tree-sitter"
55
import { LanguageParser, loadRequiredLanguageParsers } from "../../tree-sitter/languageParser"
66
import { parseMarkdown } from "../../tree-sitter/markdownParser"
77
import { ICodeParser, CodeBlock } from "../interfaces"
8-
import { scannerExtensions } from "../shared/supported-extensions"
9-
import { shouldUseFallbackChunking } from "../shared/fallback-extensions"
8+
import { scannerExtensions, shouldUseFallbackChunking } from "../shared/supported-extensions"
109
import { MAX_BLOCK_CHARS, MIN_BLOCK_CHARS, MIN_CHUNK_REMAINDER_CHARS, MAX_CHARS_TOLERANCE_FACTOR } from "../constants"
1110
import { TelemetryService } from "@roo-code/telemetry"
1211
import { TelemetryEventName } from "@roo-code/types"

src/services/code-index/shared/fallback-extensions.ts

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

src/services/code-index/shared/supported-extensions.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,32 @@ import { extensions as allExtensions } from "../../tree-sitter"
22

33
// Include all extensions including markdown for the scanner
44
export const scannerExtensions = allExtensions
5+
6+
/**
7+
* Extensions that should always use fallback chunking instead of tree-sitter parsing.
8+
* These are typically languages that don't have a proper WASM parser available
9+
* or where the parser doesn't work correctly.
10+
*
11+
* NOTE: Only extensions that are already in the supported extensions list can be added here.
12+
* To add support for new file types, they must first be added to the tree-sitter extensions list.
13+
*
14+
* HOW TO ADD A NEW FALLBACK EXTENSION:
15+
* 1. First ensure the extension is in src/services/tree-sitter/index.ts extensions array
16+
* 2. Add the extension to the fallbackExtensions array below
17+
* 3. The file will automatically use length-based chunking for indexing
18+
*
19+
* Note: Do NOT remove parser cases from languageParser.ts as they may be used elsewhere
20+
*/
21+
export const fallbackExtensions = [
22+
".vb", // Visual Basic .NET - no dedicated WASM parser
23+
".scala", // Scala - uses fallback chunking instead of Lua query workaround
24+
]
25+
26+
/**
27+
* Check if a file extension should use fallback chunking
28+
* @param extension File extension (including the dot)
29+
* @returns true if the extension should use fallback chunking
30+
*/
31+
export function shouldUseFallbackChunking(extension: string): boolean {
32+
return fallbackExtensions.includes(extension.toLowerCase())
33+
}

0 commit comments

Comments
 (0)