Skip to content

Conversation

@zen010101
Copy link
Contributor

Summary

  • Implemented extraction of Property symbols (SymbolKind.Property = 7)
  • Implemented extraction of Field symbols (SymbolKind.Field = 8)
  • Both flat (SymbolInformation) and hierarchical (DocumentSymbol) modes supported
  • Added comprehensive FPCUnit test suite
  • Added integration test framework for future LSP protocol testing

Changes

  • PasLS.Symbols.pas: Extended TSymbolExtractor.Extract to handle Property and Field declarations
  • Tests.DocumentSymbol.pas: New unit test suite testing both flat and hierarchical modes
  • LSP.TestClient.pas: Socket-based LSP client for integration testing
  • Tests.Integration.pas: Integration test framework (infrastructure complete, tests need environment setup)
  • testlsp.lpr/.lpi: Updated test project to include new test units

Test Coverage

  • ✅ Unit tests pass for both flat and hierarchical modes
  • ✅ Verifies extraction of Class, Property, Field, and Method symbols
  • ✅ Tests correct SymbolKind values and JSON structure
  • ⚠️ Integration tests created but require paslssock setup (separate from feature)

Testing

Run tests:

lazbuild src/tests/testlsp.lpi
src/tests/testlsp.exe

Results:

  • TTestDocumentSymbol.TestSymbolExtractionHierarchical: ✅ PASS
  • TTestDocumentSymbol.TestSymbolExtractionFlat: ✅ PASS

Implement dual-mode DocumentSymbol provider supporting both LSP 2.x
flat mode (SymbolInformation) and LSP 3.x hierarchical mode
(DocumentSymbol with children).

Changes:
- Add TSymbolMode enum and TSymbolBuilder class for dual-mode building
- Detect client hierarchicalDocumentSymbolSupport capability during init
- Build hierarchical structure with parent-child relationships
- Return DocumentSymbol (with range/children) or SymbolInformation
  (with location/containerName) based on client capability

Benefits:
- Better IDE integration (Outline view shows proper nesting in VS Code)
- Enables hierarchical navigation and symbol search (Class/Method paths)
- Backward compatible with clients not supporting hierarchical mode
- Compliant with LSP 3.10+ specification

Tested with VS Code and Serena MCP, both working correctly in
hierarchical mode with proper symbol nesting.
@zen010101 zen010101 force-pushed the feat/property-field-symbols branch from 2850f9b to ef2bb5b Compare December 25, 2025 19:09
- Implemented extraction of Property symbols (SymbolKind.Property = 7)
- Implemented extraction of Field symbols (SymbolKind.Field = 8)
- Both flat and hierarchical modes are supported
- Added FPCUnit test suite (Tests.DocumentSymbol) with comprehensive coverage
- Tests verify correct extraction of Class, Property, Field, and Method symbols

The implementation properly handles both SymbolInformation (flat) and
DocumentSymbol (hierarchical) response formats based on client capabilities.
@zen010101 zen010101 force-pushed the feat/property-field-symbols branch from ef2bb5b to 1f9d7fe Compare December 25, 2025 19:19
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