Skip to content

feat: add Object Pascal language support (server + CLI)#115

Open
siddsghosh wants to merge 2 commits intoSpillwaveSolutions:mainfrom
siddsghosh:object-pascal-support
Open

feat: add Object Pascal language support (server + CLI)#115
siddsghosh wants to merge 2 commits intoSpillwaveSolutions:mainfrom
siddsghosh:object-pascal-support

Conversation

@siddsghosh
Copy link

@siddsghosh siddsghosh commented Mar 2, 2026

Summary

  • Adds full AST-aware chunking for Object Pascal via tree-sitter-language-pack's bundled pascal grammar (tree-sitter-language-pack is already a dependency)
  • Implements manual AST walking (_collect_pascal_symbols + _pascal_proc_name) to correctly resolve both simple names (procedure Foo) and qualified names (procedure TClass.Method) via the genericDot grammar node
  • Adds file extension detection for .pas, .pp, .lpr (Lazarus), .dpr (Delphi) → "pascal"
  • Adds content-based fallback detection using unit/program/library header, procedure/function, and begin patterns
  • Adds a "pascal" file type preset and extends the "code" union preset in both the server (file_type_presets.py) and the CLI (types.py), keeping them in sync
  • Includes a representative sample.pas fixture (TShape/TCircle class hierarchy, TPoint record, standalone routines, ~115 lines)

Test plan

  • test_pascal_code_chunker_initialization — tree-sitter grammar loads
  • test_pascal_symbol_extraction_basic — standalone procedure/function names extracted
  • test_pascal_symbol_extraction_class — class/record type names + qualified method names extracted; kind values match grammar node names
  • test_pascal_fixture_file_symbols — all key declarations from sample.pas present
  • test_pascal_code_chunker_chunking — async full pipeline produces chunks with symbol metadata
  • TestPascalExtensionDetection — all four extensions detected correctly (case-insensitive)
  • TestPascalIsSupported — language appears in get_supported_languages()
  • TestPascalContentDetection — unit/program header and procedure/function patterns score highest
  • test_file_type_presets (server) — "pascal" preset exists; "code" preset includes *.pas
  • test_pascal_preset_patterns (CLI) — all four Pascal extensions present in CLI preset
  • test_all_expected_presets_exist (CLI) — "pascal" included in expected preset set
  • task before-push equivalent: Black ✓, Ruff ✓, mypy ✓, all tests pass

🤖 Generated with Claude Code

Siddhartha Ghosh and others added 2 commits March 2, 2026 08:25
Adds full AST-aware support for Object Pascal via tree-sitter-language-pack's
bundled `pascal` grammar (Isopod/tree-sitter-pascal).

Changes:
- document_loader.py: register .pas/.pp/.lpr/.dpr extensions → "pascal";
  add pascal CONTENT_PATTERNS (unit/program/library header, procedure/function,
  begin); add extensions to CODE_EXTENSIONS; update LanguageDetector docstring
- chunking.py: add "pascal" to lang_map; implement _collect_pascal_symbols()
  (recursive AST walk) and _pascal_proc_name() (handles both simple and
  qualified TClass.Method names via genericDot); annotate symbols list type
- file_type_presets.py: add "pascal" preset [*.pas *.pp *.lpr *.dpr]; extend
  "code" union preset with the same four patterns
- tests/fixtures/sample.pas: new ~115-line representative Object Pascal unit
  (TShape/TCircle classes, TPoint record, standalone routines)
- tests/unit/test_chunking.py: 5 Pascal tests (init, basic symbol extraction,
  class/record types, fixture file symbols, async chunking pipeline)
- tests/unit/test_document_loader.py: Pascal extension, support, and content
  detection test classes
- tests/test_file_type_presets.py: update preset count to 15; add pascal to
  code preset coverage check

All 783 tests pass; mypy, ruff, black clean; 74% coverage.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds 'pascal' preset ["*.pas", "*.pp", "*.lpr", "*.dpr"] to the CLI's
FILE_TYPE_PRESETS dict in types.py, keeping it in sync with the server's
file_type_presets.py. Also extends the 'code' union preset with the four
Pascal extensions.

Updates test_types_cli.py: adds "pascal" to the expected preset set and
adds test_pascal_preset_patterns to verify all four extensions are present.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@siddsghosh siddsghosh changed the title feat: add Object Pascal (Delphi/Free Pascal) language support feat: add Object Pascal language support (server + CLI) Mar 2, 2026
@siddsghosh
Copy link
Author

Added support for Object Pascal for full AST aware context and unit tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant