@@ -10,6 +10,19 @@ import (
1010 pkgParser "github.com/doITmagic/rag-code-mcp/pkg/parser"
1111)
1212
13+ // FrameworkEnricher defines an interface for adding framework-specific parsing (e.g., Laravel, WordPress).
14+ type FrameworkEnricher interface {
15+ IsApplicable (ca * CodeAnalyzer , paths []string ) bool
16+ Enrich (ca * CodeAnalyzer , packages []* PackageInfo , paths []string , chunks []CodeChunk ) []CodeChunk
17+ }
18+
19+ var enrichers []FrameworkEnricher
20+
21+ // RegisterEnricher adds a framework-specific enricher to the PHP parser.
22+ func RegisterEnricher (e FrameworkEnricher ) {
23+ enrichers = append (enrichers , e )
24+ }
25+
1326func init () {
1427 pkgParser .Register (NewAnalyzer ())
1528}
@@ -38,11 +51,22 @@ func (a *Analyzer) CanHandle(filePath string) bool {
3851
3952// Analyze extracts symbols from a file or directory.
4053func (a * Analyzer ) Analyze (ctx context.Context , path string ) (* pkgParser.Result , error ) {
41- chunks , err := a .codeAnalyzer .AnalyzePaths ([]string {path })
54+ paths := []string {path }
55+ chunks , err := a .codeAnalyzer .AnalyzePaths (paths )
4256 if err != nil {
4357 return nil , err
4458 }
4559
60+ // Fetch packages analyzed by the core PHP parser
61+ packages := a .codeAnalyzer .GetPackages ()
62+
63+ // Run all registered framework enrichers
64+ for _ , enricher := range enrichers {
65+ if enricher .IsApplicable (a .codeAnalyzer , paths ) {
66+ chunks = enricher .Enrich (a .codeAnalyzer , packages , paths , chunks )
67+ }
68+ }
69+
4670 // If no symbols found and the file is in a routes/ directory,
4771 // try extracting Route::* calls as symbols (Laravel convention).
4872 if len (chunks ) == 0 && isRouteFile (path ) {
0 commit comments