feat(wordpress): integrate Oxygen and WooCommerce analyzers into WordPress pipeline#46
Open
feat(wordpress): integrate Oxygen and WooCommerce analyzers into WordPress pipeline#46
Conversation
added 2 commits
March 16, 2026 21:23
… 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
- 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)
There was a problem hiding this comment.
Pull request overview
Integrates existing Oxygen Builder and WooCommerce analyzers into the WordPress parsing pipeline to emit enriched framework-specific CodeChunks; additionally introduces Laravel Blade template parsing/chunking.
Changes:
- WordPress: call Oxygen/WooCommerce analyzers during
analyzeWordPress()and emitoxy_*/wc_*chunks inconvertToChunks(). - WooCommerce: break
wordpressimport cycle by introducing localWPHookInputand local AST helpers. - Laravel: add Blade template analyzer + adapter conversions + tests; update
.gitignore.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/parser/php/wordpress/woocommerce/analyzer_test.go | Updates WooCommerce hook classification test to use local WPHookInput. |
| pkg/parser/php/wordpress/woocommerce/analyzer.go | Removes wordpress dependency; adds WPHookInput + local AST helpers. |
| pkg/parser/php/wordpress/types.go | Extends WordPressInfo with OxygenInfo / WooCommerceInfo (as any) to avoid cycles. |
| pkg/parser/php/wordpress/analyzer_test.go | Adds WordPress integration tests for Oxygen/WooCommerce + nil-safety check. |
| pkg/parser/php/wordpress/analyzer.go | Wires Oxygen/WooCommerce analyzers into WP pipeline and chunk conversion. |
| pkg/parser/php/laravel/types.go | Adds BladeTemplate types to LaravelInfo. |
| pkg/parser/php/laravel/enricher.go | Runs Blade discovery + Blade analyzer and appends resulting chunks. |
| pkg/parser/php/laravel/blade_test.go | Adds unit tests for Blade directive extraction and view-name formatting. |
| pkg/parser/php/laravel/blade.go | Implements line-oriented Blade directive parser via regexes. |
| pkg/parser/php/laravel/adapter.go | Adds Blade file discovery and template→chunk conversion with relations. |
| .gitignore | Ignores docs/plans/*.md. |
You can also share your feedback on Copilot code review. Take the survey.
| } | ||
| } | ||
|
|
||
| logger.Instance.Debug("[LARAVEL] Enrich DONE: returning %d total chunks (before blade)", len(chunks)) |
Comment on lines
+128
to
+139
| // Analyze Blade Templates | ||
| bladeFiles := e.adapter.findBladeFiles(paths) | ||
| logger.Instance.Debug("[LARAVEL] Enrich: found %d blade files from paths=%v", len(bladeFiles), paths) | ||
| if len(bladeFiles) > 0 { | ||
| bladeAnalyzer := NewBladeAnalyzer() | ||
| bladeTemplates := bladeAnalyzer.Analyze(bladeFiles) | ||
| if len(bladeTemplates) > 0 { | ||
| bladeChunks := e.adapter.convertBladeToChunks(bladeTemplates) | ||
| logger.Instance.Debug("[LARAVEL] Enrich: %d blade templates → %d chunks", len(bladeTemplates), len(bladeChunks)) | ||
| chunks = append(chunks, bladeChunks...) | ||
| } | ||
| } |
| FilePath: wcHook.FilePath, | ||
| StartLine: wcHook.StartLine, | ||
| EndLine: wcHook.EndLine, | ||
| Signature: fmt.Sprintf("%s('%s', '%s')", wcHook.HookType, wcHook.HookName, wcHook.Callback), |
Comment on lines
+175
to
+179
| wcHooks := a.woocommerceAnalyzer.AnalyzeHooksFromWP(wcInputHooks) | ||
| if len(wcHooks) > 0 { | ||
| wcInfo := &woocommerce.WooCommerceInfo{Hooks: wcHooks} | ||
| info.WooCommerceInfo = wcInfo | ||
| } |
Comment on lines
+322
to
+345
| // extractExprValue extracts a string representation from an expression | ||
| func extractExprValue(expr ast.Vertex) string { | ||
| if expr == nil { | ||
| return "" | ||
| } | ||
| switch n := expr.(type) { | ||
| case *ast.ScalarString: | ||
| val := string(n.Value) | ||
| if len(val) >= 2 { | ||
| val = val[1 : len(val)-1] // Remove quotes | ||
| } | ||
| return val | ||
| case *ast.ScalarLnumber: | ||
| return string(n.Value) | ||
| case *ast.Name: | ||
| var parts []string | ||
| for _, part := range n.Parts { | ||
| if namePart, ok := part.(*ast.NamePart); ok { | ||
| parts = append(parts, string(namePart.Value)) | ||
| } | ||
| } | ||
| return strings.Join(parts, "\\") | ||
| case *ast.ExprVariable: | ||
| if nameNode, ok := n.Name.(*ast.Identifier); ok { |
| // Compiled regex patterns for Blade directives | ||
| var ( | ||
| reExtends = regexp.MustCompile(`@extends\(\s*['"](.+?)['"]\s*\)`) | ||
| reSection = regexp.MustCompile(`@section\(\s*['"](.+?)['"]\s*\)`) |
Comment on lines
+300
to
+316
| chunk := php.CodeChunk{ | ||
| Name: tpl.Name, | ||
| Type: "blade_template", | ||
| Language: "php", | ||
| FilePath: tpl.FilePath, | ||
| StartLine: 1, | ||
| Signature: sig, | ||
| Docstring: docstring, | ||
| Metadata: map[string]any{ | ||
| "framework": "laravel", | ||
| "blade": true, | ||
| "sections_count": len(tpl.Sections), | ||
| "includes_count": len(tpl.Includes), | ||
| }, | ||
| Relations: relations, | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Integrate the existing Oxygen Builder and WooCommerce analyzers into the main WordPress parsing pipeline, so that plugin-specific patterns are automatically detected and indexed as enriched
CodeChunkobjects.Previously,
wordpress/oxygen/analyzer.goandwordpress/woocommerce/analyzer.goexisted with passing tests, but were never imported from the mainwordpress/analyzer.go. This meant:OxyElclasses were parsed as generic PHP classes (nooxy_elementmetadata)woocommerce_before_cartwere detected as genericwp_hook(no area classification likecart,checkout,product)What this adds:
oxygenAnalyzer.AnalyzeFromPackages()inanalyzeWordPress():oxy_elementchunks for classes extendingOxyEl/OxyElShadow/OxygenElementoxy_templatechunks forct_templatepost type registrationsframework=wordpress,wp_type=oxygen_element, namespace, methods, slugwoocommerceAnalyzer.AnalyzeHooksFromWP():wc_hookchunks with area classification (cart,checkout,product,order,payment, etc.)wc_api_callchunks for WC API functions (wc_get_product,wc_get_order, etc.)wc_area,hook_type,callback,prioritywoocommercepackage previously importedwordpress(forWPHooktype andASTHelper), creating a cycle whenwordpressimportswoocommerce. Resolved by:WPHookInputstruct locally inwoocommercepackageextractHookFromFunctionCall,extractCallArgs, etc.) locallyWPHook → WPHookInputat call site inanalyzer.goTestAnalyzer_OxygenElementDetection— end-to-end OxyEl detection viaAnalyzePaths()TestAnalyzer_WooCommerceHookClassification— end-to-end WC area classificationTestConvertToChunks_OxygenAndWooCommerce— nil safety for new fieldsArchitecture decision:
Implemented as direct integration (Oxygen/WooCommerce analyzers called from
wordpress/analyzer.go), not as separate enrichers, because:Closes: Trello cards #114-#119
Type of change
Checklist:
go fmt ./...go test ./...and they passFiles Changed
pkg/parser/php/wordpress/types.goOxygenInfo anyandWooCommerceInfo anyfields toWordPressInfopkg/parser/php/wordpress/analyzer.gooxygen+woocommerce, added analyzers to struct, integrated calls inanalyzeWordPress()andconvertToChunks()pkg/parser/php/wordpress/analyzer_test.gopkg/parser/php/wordpress/woocommerce/analyzer.gowordpressimport, definedWPHookInput, reimplemented AST helpers locallypkg/parser/php/wordpress/woocommerce/analyzer_test.goTestAnalyzeHooksFromWPto useWPHookInputinstead ofwordpress.WPHook