feat(laravel): add Blade Template (.blade.php) semantic indexing#45
feat(laravel): add Blade Template (.blade.php) semantic indexing#45
Conversation
… BladeTemplate, BladeSection, BladeInclude types in types.go- Implement BladeAnalyzer with 8 regex extractors for Blade directives (@extends, @section, @yield, @include, @component, @each, @push/@stack, @props)- Add findBladeFiles() for recursive .blade.php discovery- Add convertBladeToChunks() with inheritance/dependency relations- Integrate BladeAnalyzer into Laravel Enrich() pipeline- Add 9 comprehensive unit tests (all passing)Closes: Trello cards #104-#111
There was a problem hiding this comment.
Pull request overview
Adds Laravel Blade (.blade.php) semantic indexing to make Blade templates and directives discoverable in semantic search/code graph, integrated into the existing PHP→Laravel enricher pipeline.
Changes:
- Introduces a regex-based
BladeAnalyzerto extract key Blade directives and template metadata. - Discovers
.blade.phpfiles and converts parsed templates intophp.CodeChunkentries with relations/metadata. - Integrates Blade analysis into the Laravel
Enrich()pipeline and adds unit tests + new Laravel types.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/parser/php/laravel/blade.go | New Blade directive analyzer + view-name/path helpers |
| pkg/parser/php/laravel/blade_test.go | Unit tests for directive extraction and view-name conversion |
| pkg/parser/php/laravel/types.go | Adds Blade-related types and BladeTemplates to LaravelInfo |
| pkg/parser/php/laravel/adapter.go | Adds Blade file discovery + conversion to CodeChunk with relations/metadata |
| pkg/parser/php/laravel/enricher.go | Runs Blade analysis during Laravel enrichment and appends Blade chunks |
You can also share your feedback on Copilot code review. Take the survey.
| chunk := php.CodeChunk{ | ||
| Name: tpl.Name, | ||
| Type: "blade_template", | ||
| Language: "php", | ||
| FilePath: tpl.FilePath, | ||
| StartLine: 1, | ||
| Signature: sig, | ||
| Docstring: docstring, |
- Add OxygenInfo and WooCommerceInfo fields to WordPressInfo struct - Add oxygen.Analyzer and woocommerce.Analyzer to WordPress Analyzer - Call Oxygen analyzer in analyzeWordPress() for OxyEl element detection - Call WooCommerce analyzer for hook classification by area (cart, checkout, product, etc.) - Convert Oxygen elements/templates and WC hooks/API calls to CodeChunks - Break import cycle: woocommerce package no longer imports wordpress - Define WPHookInput in woocommerce as local mirror of WPHook - Reimplement AST helpers locally in woocommerce package - Add integration tests: - TestAnalyzer_OxygenElementDetection (end-to-end OxyEl detection) - TestAnalyzer_WooCommerceHookClassification (end-to-end WC area classification) - TestConvertToChunks_OxygenAndWooCommerce (nil safety)
Review Comments AddressedAll 3 Copilot review comments have been fixed: 1. ✅ Regex patterns — capture only first quoted argument (
|
- Fix regex patterns: changed (.+?) to ([^'"]+) to capture only the first quoted argument in multi-arg directives like @section('title', 'Dashboard') - Add EndLine to blade CodeChunks via new BladeTemplate.TotalLines field - Fix misleading 'Enrich DONE' log that appeared before blade analysis - Strengthen tests with value assertions (section names, view names, TotalLines)
Description
Add semantic indexing for Laravel Blade templates (
.blade.php), extracting structural directives as symbols with inheritance and dependency relations in the Code Graph.Previously,
.blade.phpfiles were accepted by the PHP parser (CanHandle()returnstruefor anything ending in.php), but only PHP constructs (classes, functions) were extracted. All Blade-specific directives (@extends,@section,@yield,@include,@component, etc.) were completely ignored, making Blade templates invisible to semantic search.What this adds:
@extends→ inheritance relations@section/@yield→ section symbols@include/@component/@each→ dependency relations@push/@stack→ stack tracking@props→ component property extractionfindBladeFiles()— recursive.blade.phpfile discovery with vendor/node_modules exclusionconvertBladeToChunks()— converts templates toCodeChunkwith:blade_templateRelInheritancefor@extends,RelDependencyfor@include/@component)Enrich()pipeline — follows the sameFrameworkEnricherpattern as Routes/Eloquent/MigrationsbladeViewName()— converts file paths to Laravel dot notation (e.g.,resources/views/layouts/app.blade.php→layouts.app)BladeTemplate,BladeSection,BladeIncludeintypes.goArchitecture decision:
Implemented as a Laravel enricher extension (not a separate parser), because:
.blade.phpalready passes PHPCanHandle()— no new parser registration neededpkg/parser/php/laravel/FrameworkEnricherpattern used by Routes/Eloquent/MigrationsCloses: Trello cards #104-#111
Type of change
Checklist:
go fmt ./...go test ./...and they passFiles Changed
pkg/parser/php/laravel/blade.gopkg/parser/php/laravel/blade_test.gopkg/parser/php/laravel/types.goBladeTemplate,BladeSection,BladeIncludetypes +BladeTemplatesfield inLaravelInfopkg/parser/php/laravel/adapter.gofindBladeFiles()+convertBladeToChunks()pkg/parser/php/laravel/enricher.goEnrich()pipeline