143 lines
4.1 KiB
Markdown
143 lines
4.1 KiB
Markdown
|
|
# LSP Testing Status (Phase 3 Complete)
|
||
|
|
|
||
|
|
## Summary
|
||
|
|
✅ **Phase 3 (LSP Server Core Features) testing complete**
|
||
|
|
- All LSP tests passing: 78/78 ✓
|
||
|
|
- All tree-sitter grammar tests passing: 27/27 ✓
|
||
|
|
- Code coverage significantly improved
|
||
|
|
- Behavior tree support fully tested in both LSP and tree-sitter
|
||
|
|
|
||
|
|
## Test Coverage
|
||
|
|
|
||
|
|
### LSP Tests (78 total)
|
||
|
|
Location: `/Users/sienna/Development/storybook/storybook/src/lsp/`
|
||
|
|
|
||
|
|
#### Behavior Tests (8 tests) - `behavior_tests.rs`
|
||
|
|
- ✅ test_behavior_parsing
|
||
|
|
- ✅ test_behavior_symbols
|
||
|
|
- ✅ test_behavior_symbol_kinds
|
||
|
|
- ✅ test_behavior_in_document_symbols
|
||
|
|
- ✅ test_behavior_with_subtrees
|
||
|
|
- ✅ test_behavior_simple_action
|
||
|
|
- ✅ test_behavior_selectors_and_sequences
|
||
|
|
|
||
|
|
#### Diagnostics Tests (15 tests) - `diagnostics_tests.rs`
|
||
|
|
- ✅ Parse error detection and reporting
|
||
|
|
- ✅ Error position tracking
|
||
|
|
- ✅ Error severity levels
|
||
|
|
- ✅ Utility functions (byte_offset_to_position, create_diagnostic)
|
||
|
|
- ✅ Edge cases (empty input, whitespace, comments only)
|
||
|
|
|
||
|
|
#### Document Edge Tests (20 tests) - `document_edge_tests.rs`
|
||
|
|
- ✅ Word-at-offset with unicode, underscores, boundaries
|
||
|
|
- ✅ Document updates and symbol table management
|
||
|
|
- ✅ All declaration types: species, characters, templates, life_arcs, schedules, behaviors, institutions
|
||
|
|
- ✅ Symbol extraction for all entity types
|
||
|
|
|
||
|
|
#### Existing Tests (35 tests)
|
||
|
|
- Integration tests, formatting, hover, completion, definition, references, symbols
|
||
|
|
|
||
|
|
### Tree-sitter Grammar Tests (27 total)
|
||
|
|
Location: `/Users/sienna/Development/storybook/tree-sitter-storybook/test/corpus/`
|
||
|
|
|
||
|
|
#### Behavior Tests (7 tests) - `behaviors.txt`
|
||
|
|
- ✅ Simple Behavior (single action)
|
||
|
|
- ✅ Selector Behavior (? { ... })
|
||
|
|
- ✅ Sequence Behavior (> { ... })
|
||
|
|
- ✅ Nested Behavior (selectors + sequences)
|
||
|
|
- ✅ Repeat Behavior (* { ... })
|
||
|
|
- ✅ Behavior with Subtree (@path::notation)
|
||
|
|
- ✅ Complex Nested Behavior (all node types)
|
||
|
|
|
||
|
|
#### Declaration Tests (17 tests) - `declarations.txt`
|
||
|
|
- ✅ All declaration types (use, character, template, life_arc, schedule, behavior, etc.)
|
||
|
|
|
||
|
|
#### Basic Tests (3 tests) - `basic.txt`
|
||
|
|
- ✅ Simple character, use declaration, prose block
|
||
|
|
|
||
|
|
## Coverage Improvements
|
||
|
|
|
||
|
|
**Before testing push:**
|
||
|
|
- document.rs: 80.11%
|
||
|
|
- symbols.rs: 93.04%
|
||
|
|
- diagnostics.rs: 0%
|
||
|
|
- behavior support: untested
|
||
|
|
- Total LSP tests: 34
|
||
|
|
|
||
|
|
**After testing push:**
|
||
|
|
- document.rs: 97.79% (+17.68%)
|
||
|
|
- symbols.rs: 95.24% (+2.20%)
|
||
|
|
- diagnostics.rs: fully tested
|
||
|
|
- behavior support: comprehensive test coverage
|
||
|
|
- Total LSP tests: 78 (+44 new tests, +129% increase)
|
||
|
|
|
||
|
|
## Run Commands
|
||
|
|
|
||
|
|
### LSP Tests
|
||
|
|
```bash
|
||
|
|
cd /Users/sienna/Development/storybook/storybook
|
||
|
|
cargo test --lib lsp
|
||
|
|
```
|
||
|
|
|
||
|
|
### Tree-sitter Tests
|
||
|
|
```bash
|
||
|
|
cd /Users/sienna/Development/storybook/tree-sitter-storybook
|
||
|
|
npm run test
|
||
|
|
```
|
||
|
|
|
||
|
|
**Note:** If Bash tool fails, use Serena's `execute_shell_command` instead.
|
||
|
|
|
||
|
|
## Behavior Tree Support Verified
|
||
|
|
|
||
|
|
Both LSP and tree-sitter grammar now have comprehensive behavior tree support:
|
||
|
|
|
||
|
|
### Node Types Tested:
|
||
|
|
- **action_node**: Simple action identifiers (e.g., `walk_around`)
|
||
|
|
- **selector_node**: `? { ... }` - Try options in order until one succeeds
|
||
|
|
- **sequence_node**: `> { ... }` - Execute children in sequence
|
||
|
|
- **repeat_node**: `* { ... }` - Repeat child forever
|
||
|
|
- **subtree_node**: `@path::to::tree` - Reference external behavior tree
|
||
|
|
|
||
|
|
### Syntax Examples:
|
||
|
|
```storybook
|
||
|
|
behavior SimpleBehavior {
|
||
|
|
walk_around
|
||
|
|
}
|
||
|
|
|
||
|
|
behavior ComplexBehavior {
|
||
|
|
? {
|
||
|
|
> {
|
||
|
|
check_threat
|
||
|
|
flee_to_safety
|
||
|
|
}
|
||
|
|
> {
|
||
|
|
check_resources
|
||
|
|
gather_resources
|
||
|
|
}
|
||
|
|
* {
|
||
|
|
idle
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
behavior WithSubtree {
|
||
|
|
> {
|
||
|
|
@helpers::check_preconditions
|
||
|
|
main_action
|
||
|
|
}
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
## Next Steps (Phase 4)
|
||
|
|
- Navigation features (go-to-definition, find references)
|
||
|
|
- Cross-file symbol resolution
|
||
|
|
- Template includes and species references
|
||
|
|
|
||
|
|
## Files Modified
|
||
|
|
- Created: `storybook/src/lsp/behavior_tests.rs`
|
||
|
|
- Created: `storybook/src/lsp/diagnostics_tests.rs`
|
||
|
|
- Created: `storybook/src/lsp/document_edge_tests.rs`
|
||
|
|
- Created: `tree-sitter-storybook/test/corpus/behaviors.txt`
|
||
|
|
- Modified: `storybook/src/lsp/mod.rs` (added test modules)
|
||
|
|
- Modified: `storybook/src/lsp/server.rs` (fixed imports and mutability)
|