Skip to content

feat(wordpress): integrate Oxygen and WooCommerce analyzers into WordPress pipeline#46

Merged
doITmagic merged 5 commits intodevfrom
feat/oxygen-woocommerce-integration
Mar 18, 2026
Merged

feat(wordpress): integrate Oxygen and WooCommerce analyzers into WordPress pipeline#46
doITmagic merged 5 commits intodevfrom
feat/oxygen-woocommerce-integration

Conversation

@doITmagic
Copy link
Owner

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 CodeChunk objects.

Previously, wordpress/oxygen/analyzer.go and wordpress/woocommerce/analyzer.go existed with passing tests, but were never imported from the main wordpress/analyzer.go. This meant:

  • Oxygen OxyEl classes were parsed as generic PHP classes (no oxy_element metadata)
  • WooCommerce hooks like woocommerce_before_cart were detected as generic wp_hook (no area classification like cart, checkout, product)

What this adds:

  • Oxygen integration — calls oxygenAnalyzer.AnalyzeFromPackages() in analyzeWordPress():
    • oxy_element chunks for classes extending OxyEl / OxyElShadow / OxygenElement
    • oxy_template chunks for ct_template post type registrations
    • Rich metadata: framework=wordpress, wp_type=oxygen_element, namespace, methods, slug
  • WooCommerce integration — calls woocommerceAnalyzer.AnalyzeHooksFromWP():
    • wc_hook chunks with area classification (cart, checkout, product, order, payment, etc.)
    • wc_api_call chunks for WC API functions (wc_get_product, wc_get_order, etc.)
    • Rich metadata: wc_area, hook_type, callback, priority
  • Import cycle resolutionwoocommerce package previously imported wordpress (for WPHook type and ASTHelper), creating a cycle when wordpress imports woocommerce. Resolved by:
    • Defining WPHookInput struct locally in woocommerce package
    • Reimplementing AST helpers (extractHookFromFunctionCall, extractCallArgs, etc.) locally
    • Converting WPHook → WPHookInput at call site in analyzer.go
  • 3 new integration tests:
    • TestAnalyzer_OxygenElementDetection — end-to-end OxyEl detection via AnalyzePaths()
    • TestAnalyzer_WooCommerceHookClassification — end-to-end WC area classification
    • TestConvertToChunks_OxygenAndWooCommerce — nil safety for new fields

Architecture decision:

Implemented as direct integration (Oxygen/WooCommerce analyzers called from wordpress/analyzer.go), not as separate enrichers, because:

  1. Both are conceptual extensions of WordPress — they don't make sense outside WP context
  2. They reuse the same packages/AST already parsed by the WordPress analyzer
  3. Avoids duplicating file walking and PHP parsing

Closes: Trello cards #114-#119

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist:

  • I have performed a self-review of my own code
  • I have formatted my code with go fmt ./...
  • I have run tests go test ./... and they pass
  • I have verified integration with Ollama/Qdrant (if applicable)
  • I have updated the documentation accordingly

Files Changed

File Change
pkg/parser/php/wordpress/types.go Added OxygenInfo any and WooCommerceInfo any fields to WordPressInfo
pkg/parser/php/wordpress/analyzer.go Imported oxygen + woocommerce, added analyzers to struct, integrated calls in analyzeWordPress() and convertToChunks()
pkg/parser/php/wordpress/analyzer_test.go +3 integration tests for Oxygen, WooCommerce, and nil safety
pkg/parser/php/wordpress/woocommerce/analyzer.go Broke import cycle: removed wordpress import, defined WPHookInput, reimplemented AST helpers locally
pkg/parser/php/wordpress/woocommerce/analyzer_test.go Updated TestAnalyzeHooksFromWP to use WPHookInput instead of wordpress.WPHook

razvan 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)
Copilot AI review requested due to automatic review settings March 16, 2026 20:12
@doITmagic doITmagic self-assigned this Mar 16, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 emit oxy_* / wc_* chunks in convertToChunks().
  • WooCommerce: break wordpress import cycle by introducing local WPHookInput and 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.

doITmagic pushed a commit that referenced this pull request Mar 17, 2026
- Fix misleading 'Enrich DONE' log emitted before Blade analysis (enricher.go)
- Fix wc_hook signature to use real WP functions (add_action/add_filter/etc.)
- Populate WooCommerce APICalls via woocommerceAnalyzer.Analyze() in AST walk
- Add missing AST cases to extractExprValue (ScalarDnumber, ExprConstFetch, ExprClassConstFetch)
- Fix Blade reSection regex to capture inline sections like @section('title', 'Dashboard')
- Set EndLine on blade_template chunks using TotalLines from BladeTemplate struct

Signed-off-by: doITmagic <doitmagic@users.noreply.github.com>
- Fix misleading 'Enrich DONE' log emitted before Blade analysis (enricher.go)
- Fix wc_hook signature to use real WP functions (add_action/add_filter/etc.)
- Populate WooCommerce APICalls via woocommerceAnalyzer.Analyze() in AST walk
- Add missing AST cases to extractExprValue (ScalarDnumber, ExprConstFetch, ExprClassConstFetch)
- Fix Blade reSection regex to capture inline sections like @section('title', 'Dashboard')
- Set EndLine on blade_template chunks using TotalLines from BladeTemplate struct

Signed-off-by: doITmagic <razvan@doitmagic.com>
@doITmagic doITmagic force-pushed the feat/oxygen-woocommerce-integration branch from 967107e to 4cbac50 Compare March 17, 2026 21:43
go.mod requires Go 1.24.4 but CI workflows were using Go 1.22,
causing 'no such file or directory' errors during test runs.

Signed-off-by: doITmagic <razvan@doitmagic.com>
Copilot AI review requested due to automatic review settings March 17, 2026 21:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Integrates plugin-specific analyzers (Oxygen Builder + WooCommerce) into the main WordPress analyzer so their patterns are indexed as enriched CodeChunks; additionally introduces Laravel Blade template analysis in the Laravel enricher.

Changes:

  • WordPress: wire oxygen + woocommerce analyzers into analyzeWordPress() and emit new chunk types (oxy_element, oxy_template, wc_hook, wc_api_call).
  • WooCommerce: break wordpress import cycle by introducing WPHookInput and local AST helper logic.
  • Laravel: add Blade template parsing + chunk conversion (new analyzer + tests) and run it from the Laravel enricher.

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pkg/parser/php/wordpress/analyzer.go Integrates Oxygen/WooCommerce analyzers; emits Oxygen/WooCommerce chunks; adds WC hook signature builder
pkg/parser/php/wordpress/types.go Adds OxygenInfo any and WooCommerceInfo any fields to WordPressInfo
pkg/parser/php/wordpress/analyzer_test.go Adds end-to-end integration tests for Oxygen/WooCommerce and nil-safety coverage
pkg/parser/php/wordpress/woocommerce/analyzer.go Removes wordpress dependency; adds WPHookInput + local AST helpers
pkg/parser/php/wordpress/woocommerce/analyzer_test.go Updates tests to use WPHookInput and string hook types
pkg/parser/php/laravel/types.go Adds BladeTemplates to LaravelInfo and defines Blade template structs
pkg/parser/php/laravel/enricher.go Runs Blade analysis during Laravel enrichment (adds Blade-generated chunks)
pkg/parser/php/laravel/adapter.go Adds Blade file discovery + conversion of Blade templates into chunks and relations
pkg/parser/php/laravel/blade.go New Blade analyzer (regex-based directive extraction)
pkg/parser/php/laravel/blade_test.go New unit tests for Blade analyzer behavior
.github/workflows/test.yml Updates CI Go version to 1.24
.github/workflows/release.yml Updates release workflow Go version to 1.24
.gitignore Ignores docs/plans/*.md

You can also share your feedback on Copilot code review. Take the survey.

- Add NameFullyQualified support to woocommerce extractFuncName
- Add action_check/filter_check cases to buildWCHookSignature
- Use dynamic BaseClass for Oxygen element signatures
- Increase bufio.Scanner buffer to 1MB for Blade templates
- Update CI Go version from 1.22 to 1.24 to match go.mod

Signed-off-by: doITmagic <razvan@doitmagic.com>
@doITmagic
Copy link
Owner Author

PR Review Resolution Summary

All 12 review comments from Copilot code review have been verified against the current branch state.

✅ All Code Issues Already Resolved (10/12)

# File Issue Resolution
1 enricher.go Misleading "Enrich DONE" log Fixed in subsequent commits (outdated)
3 analyzer.go wc_hook signature uses HookType as callable Fixed — buildWCHookSignature() maps all types to real WP functions
4 analyzer.go:189 WooCommerceInfo.APICalls always empty Fixed — woocommerceAnalyzer.Analyze() now called in file walk loop, APICalls collected
5 woocommerce/analyzer.go:363 extractExprValue missing ConstFetch/ClassConstFetch/ScalarDnumber Fixed — all three cases now present
6 blade.go reSection regex misses inline sections Fixed — regex now includes (?:,.*?)? for optional args
7 adapter.go:322 blade_template chunks don't set EndLine Fixed — EndLine set from tpl.TotalLines with fallback to 1
8 woocommerce/analyzer.go:300 extractFuncName misses *ast.NameFullyQualified Fixed — case added for fully-qualified names
9 analyzer.go:542 buildWCHookSignature invalid for action_check/filter_check Fixed — explicit has_action()/has_filter() cases added
10 analyzer.go Oxygen signature always uses OxyEl base class Fixed — uses elem.BaseClass with OxyEl fallback
11 blade.go:68 bufio.Scanner 64K limit silently drops files Fixed — scanner.Buffer() set to allow lines up to 1MB

📋 Process Comment Addressed (2/12)

# Issue Action
2, 12 PR title/description only mentions WordPress, but also includes Laravel Blade changes Proposed: Update PR title to feat(wordpress,laravel): integrate Oxygen/WooCommerce analyzers and add Blade template analysis and expand body to document both features

Proposed Title Update

feat(wordpress,laravel): integrate Oxygen/WooCommerce analyzers and add Blade template analysis

The PR body should be updated to include a Section 2: Laravel Blade Template Analysis alongside the existing WordPress documentation, covering:

  • BladeAnalyzer with regex-based directive extraction
  • Blade chunk conversion with proper EndLine and structural relations
  • Blade file discovery and enricher integration
  • Unit tests for Blade behavior

@doITmagic doITmagic merged commit 1fcaca2 into dev Mar 18, 2026
5 checks passed
@doITmagic doITmagic deleted the feat/oxygen-woocommerce-integration branch March 18, 2026 13:25
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.

2 participants