mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-10-31 06:54:35 +00:00
* refactor: standardize C# Tree-Sitter parser tests This commit standardizes the C# Tree-Sitter parser tests to ensure: - Variable/function names in sample code match the tests - Each test only verifies specific identifiers relevant to that test - Test names clearly indicate what they're testing - No skipped tests remain - Only one test exists per structure or combination of structures - All debug output uses debugLog from helpers.ts The standardization improves maintainability and clarity while preserving all existing functionality. Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org> * refactor: standardize C Tree-Sitter parser tests This commit standardizes the C Tree-Sitter parser tests to ensure: - Variable/function names in sample code match the tests (using snake_case) - Each test only verifies specific identifiers relevant to that test - Test names clearly indicate what they're testing - No skipped tests remain - tests for unsupported features are removed - Only one test exists per structure or combination of structures - All debug output uses debugLog from helpers.ts The standardization improves maintainability and clarity while preserving all existing functionality. Documentation has been added for C language constructs that are not currently supported by the parser. Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org> * feat: standardize Kotlin Tree-Sitter parser Standardized Kotlin Tree-Sitter parser to ensure consistent naming and structure: - Renamed identifiers to clearly indicate what they're testing - Ensured all code sections are at least 4 lines long - Organized query patterns logically with clear comments - Removed skipped tests and unused query patterns - Ensured only one test per structure or combination of structures Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org> * feat: standardize PHP Tree-Sitter parser Standardized PHP Tree-Sitter parser to ensure consistent naming and structure: - Renamed identifiers to clearly indicate what they're testing - Ensured all code sections are at least 4 lines long - Organized query patterns logically with clear comments - Consolidated related tests to ensure only one test per structure - Ensured all debug output uses debugLog from helpers.ts Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org> * feat: standardize Ruby Tree-Sitter parser Standardized Ruby Tree-Sitter parser to ensure consistent naming and structure: - Expanded query to support many more Ruby language constructs - Added comprehensive test file with clear section headers - Ensured all code sections are at least 4 lines long - Added tests for each language construct - Used consistent naming conventions for test identifiers Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org> * feat: standardize Swift Tree-Sitter parser Standardized Swift Tree-Sitter parser to ensure consistent naming and structure: - Renamed identifiers to clearly indicate what they're testing - Ensured all code sections are at least 4 lines long - Organized query patterns logically with clear comments - Removed skipped tests and unused query patterns - Ensured only one test per structure or combination of structures Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org> * feat: dynamically include all tree-sitter WASM files in build process - Modified esbuild.js to dynamically read and copy all WASM files from tree-sitter-wasms package - Added error handling and logging for better debugging - Ensures all language parsers are automatically included without requiring manual updates * refactor: move test mocks and fixtures to shared locations Move test mocks to helpers.ts to be shared between test files Create fixtures directory for shared test data Move sample TSX content to fixtures/sample-tsx.ts Update test files to use shared mocks and fixtures Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org> * refactor: simplify tree-sitter debug output - Remove detailed node inspection to reduce noise - Keep only essential tree structure output - Remove duplicate content logging Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org> * refactor: standardize C# tree-sitter test structure Move C# sample code to dedicated fixture file and create inspectCSharp test following the same pattern as other language tests. This improves test organization and maintainability by: - Extracting sample C# code to fixtures/sample-c-sharp.ts - Adding inspectCSharp.test.ts for tree structure inspection - Updating parseSourceCodeDefinitions.c-sharp.test.ts to use fixture Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org> * feat: add language-specific capture processing - Add language parameter to processCaptures for language-specific handling - Implement selective HTML filtering for jsx/tsx files - Update all call sites to pass correct language parameter - Fix type safety by properly passing language strings Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org> * refactor: move tree-sitter test samples to fixtures Move sample code from parseSourceCodeDefinitions test files into dedicated fixtures directory for better organization and reuse: - Created fixtures directory for language samples - Moved sample code for C#, C, JSON, Kotlin, PHP, Ruby, Rust, and Swift - Created inspect test files for each language - Updated original test files to import from fixtures - Standardized test options across languages - No behavior changes, all tests passing Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org> * refactor: standardize tree-sitter test code across languages Standardize test code structure and naming across all language parsers: - Rename identifiers to clearly indicate test purpose - Ensure each code section has descriptive comments - Group related code sections together - Maintain language-specific naming conventions - Keep test structure consistent across languages - Remove tests for unsupported features Changes made to: - C, JSON, Kotlin, PHP, Ruby, Rust, and Swift test files - Sample code fixtures - Parser definition tests - Inspect structure tests No functional changes - all tests passing with improved maintainability. Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org> * refactor: standardize tree-sitter parser tests across all languages - Ensure all test structures span at least 4 lines for better parsing - Create exactly one consolidated test per data structure type - Use descriptive names that clearly indicate test purpose - Improve query pattern organization and documentation - Simplify inspect test files to focus on structure validation - Implement result caching in test files for better performance - Remove duplicate and skipped tests - Follow consistent naming conventions across all languages Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org> * first pass all but elm-bash * test: inspectTreeStructure helper now returns a string Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org> * refactor: establish single source of truth for MIN_COMPONENT_LINES - Move minComponentLines parameter to a file-level constant - Remove parameter passing to processCaptures function - Update all references to use the global constant - Remove redundant local constant declaration in parseFile Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org> * refactor: improve MIN_COMPONENT_LINES implementation - Changed MIN_COMPONENT_LINES constant to use getter/setter functions - Updated references to use getMinComponentLines() function - Modified test helper to set value to 0 during tests - This establishes a single source of truth while making testing easier Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org> * feat: standardize tree-sitter test implementations Standardized tree-sitter test implementations across all supported languages: - Removed debugLog calls from test files - Implemented consistent line number pattern matching - Ensured proper test structure and execution order - Added comprehensive test coverage for supported structures - Maintained 1:1 mapping between queries, tests and samples - Documented unsupported features in TODO sections Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org> * docs: document tree-sitter parseable but unsupported structures Added TODO sections in test files documenting structures that can be parsed by tree-sitter but currently lack query pattern support: - Python: f-strings, complex type annotations, pattern matching - C++: virtual methods, field initializers, base class clauses - Java: import declarations, field declarations with modifiers - TSX: React hooks, context providers, event handlers Added examples and clarifying comments to existing TODO sections. Enhanced Java query patterns for better structure capture including lambda expressions, field declarations, and type parameters. Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org> * fix: use correct distDir variable for WASM file copying The copyWasmFiles plugin was using an undefined targetDir variable when copying tree-sitter WASM files. Changed to use the correctly defined distDir variable, fixing the build process. Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org> * lint: remove unused imports and variables from tree-sitter tests Removed unused imports and variables from tree-sitter test files to fix linting errors: - Removed unused goQuery import from helpers.ts - Removed unused imports and mockedFs variables from language-specific test files - Cleaned up test files to only import what they use Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org> --------- Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org> Co-authored-by: Eric Wheeler <roo-code@z.ewheeler.org>
24 lines
800 B
TypeScript
24 lines
800 B
TypeScript
import { describe, it } from "@jest/globals"
|
|
import { inspectTreeStructure, testParseSourceCodeDefinitions } from "./helpers"
|
|
import { javaQuery } from "../queries"
|
|
import sampleJavaContent from "./fixtures/sample-java"
|
|
|
|
describe("inspectJava", () => {
|
|
const testOptions = {
|
|
language: "java",
|
|
wasmFile: "tree-sitter-java.wasm",
|
|
queryString: javaQuery,
|
|
extKey: "java",
|
|
}
|
|
|
|
it("should inspect Java tree structure", async () => {
|
|
const result = await inspectTreeStructure(sampleJavaContent, "java")
|
|
expect(result).toBeTruthy()
|
|
})
|
|
|
|
it("should parse Java definitions", async () => {
|
|
const result = await testParseSourceCodeDefinitions("test.java", sampleJavaContent, testOptions)
|
|
expect(result).toBeTruthy()
|
|
expect(result).toMatch(/\d+--\d+ \| /) // Verify line number format
|
|
})
|
|
})
|