Commit 52571ac
authored
feat(laravel): add Blade Template (.blade.php) semantic indexing
## Summary
Add semantic indexing for Laravel Blade templates (.blade.php), extracting
structural directives as symbols with inheritance and dependency relations
in the Code Graph.
## What's included
- **BladeAnalyzer** — regex-based parser for 8 Blade directives:
@extends, @section, @yield, @include, @component, @each, @push/@stack, @props
- **findBladeFiles()** — recursive .blade.php file discovery (excludes vendor/node_modules)
- **convertBladeToChunks()** — converts templates to CodeChunk with:
- Type: blade_template
- Structural relations (RelInheritance for @extends, RelDependency for @include/@component)
- Rich metadata (framework, sections count, includes count, stacks, props)
- Auto-generated docstrings from directive summaries
- **Integration** into existing Laravel Enrich() pipeline
- **bladeViewName()** — file path → Laravel dot notation conversion
- **3 new types**: BladeTemplate, BladeSection, BladeInclude in types.go
- **9 comprehensive unit tests** covering all directives and edge cases
## Review fixes applied (Copilot PR review)
1. Regex patterns — changed (.+?) to ([^'"]+) to prevent multi-argument capture bugs
2. Log message — "Enrich: N chunks after routes, before blade analysis" (was misleading "DONE")
3. EndLine populated — TotalLines field + fallback to 1 for empty files
4. Scanner buffer — Allow lines up to 1MB for large Blade templates
## Architecture decision
Implemented as a Laravel enricher extension (not a separate parser) because:
1. .blade.php already passes PHP CanHandle() — no new parser registration needed
2. Blade is strictly a Laravel feature — fits naturally in pkg/parser/php/laravel/
3. Directives are plain text patterns — regex is sufficient (no AST needed)
4. Follows the established FrameworkEnricher pattern (Routes/Eloquent/Migrations)
## Files Changed
| File | Change |
|------|--------|
| pkg/parser/php/laravel/blade.go | NEW — BladeAnalyzer with 8 regex extractors |
| pkg/parser/php/laravel/blade_test.go | NEW — 9 unit tests |
| pkg/parser/php/laravel/types.go | Added BladeTemplate, BladeSection, BladeInclude types |
| pkg/parser/php/laravel/adapter.go | Added findBladeFiles() + convertBladeToChunks() |
| pkg/parser/php/laravel/enricher.go | Integrated Blade analysis into Enrich() pipeline |3 files changed
Lines changed: 25 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
| 300 | + | |
300 | 301 | | |
301 | 302 | | |
302 | 303 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
108 | 109 | | |
109 | 110 | | |
| 111 | + | |
110 | 112 | | |
111 | 113 | | |
112 | 114 | | |
113 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
114 | 122 | | |
115 | 123 | | |
116 | 124 | | |
| |||
218 | 226 | | |
219 | 227 | | |
220 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
221 | 235 | | |
222 | 236 | | |
223 | 237 | | |
224 | 238 | | |
225 | 239 | | |
226 | 240 | | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
227 | 244 | | |
228 | 245 | | |
229 | 246 | | |
| |||
0 commit comments