@@ -62,6 +62,8 @@ func LoadLanguageConfig() (*LanguagesConfig, error) {
6262 return nil , fmt .Errorf ("failed to parse YAML languages configuration file: %w" , err )
6363 }
6464
65+ // Ensure license-sim entry for PHP files
66+ ensureLicenseSimEntry (& config )
6567 return & config , nil
6668 }
6769
@@ -83,9 +85,38 @@ func LoadLanguageConfig() (*LanguagesConfig, error) {
8385 return nil , fmt .Errorf ("failed to parse JSON languages configuration file: %w" , err )
8486 }
8587
88+ // Ensure license-sim entry for PHP files
89+ ensureLicenseSimEntry (& config )
8690 return & config , nil
8791}
8892
93+ // ensureLicenseSimEntry adds or updates the license-sim entry to only support .php files
94+ func ensureLicenseSimEntry (config * LanguagesConfig ) {
95+ found := false
96+ for i , tool := range config .Tools {
97+ if tool .Name == "license-sim" {
98+ // Overwrite to only support .php files
99+ config .Tools [i ].Extensions = []string {".php" }
100+ config .Tools [i ].Languages = []string {"PHP" }
101+ found = true
102+ break
103+ }
104+ }
105+ if ! found {
106+ config .Tools = append (config .Tools , struct {
107+ Name string `yaml:"name" json:"name"`
108+ Languages []string `yaml:"languages" json:"languages"`
109+ Extensions []string `yaml:"extensions" json:"extensions"`
110+ Files []string `yaml:"files" json:"files"`
111+ }{
112+ Name : "license-sim" ,
113+ Languages : []string {"PHP" },
114+ Extensions : []string {".php" },
115+ Files : nil ,
116+ })
117+ }
118+ }
119+
89120// GetFileExtension extracts the file extension from a path
90121func GetFileExtension (filePath string ) string {
91122 return strings .ToLower (filepath .Ext (filePath ))
@@ -113,14 +144,14 @@ func IsToolSupportedForFile(toolName string, filePath string, langConfig *Langua
113144 if tool .Name == toolName {
114145 // If tool has no extensions defined, assume it supports all files
115146 if len (tool .Extensions ) == 0 {
116- fmt .Printf ("[DEBUG ] Tool %s has no extensions defined, supports all files. File: %s\n " , toolName , filePath )
147+ fmt .Printf ("[DEBUG1 ] Tool %s has no extensions defined, supports all files. File: %s\n " , toolName , filePath )
117148 return true
118149 }
119150
120- fmt .Printf ("[DEBUG] Checking if tool %s supports file %s (ext: %s). Tool extensions: %v\n " , toolName , filePath , fileExt , tool .Extensions )
151+ // fmt.Printf("[DEBUG] Checking if tool %s supports file %s (ext: %s). Tool extensions: %v\n", toolName, filePath, fileExt, tool.Extensions)
121152 for _ , ext := range tool .Extensions {
122153 if strings .EqualFold (ext , fileExt ) {
123- fmt .Printf ("[DEBUG ] Tool %s supports file %s (matched ext: %s)\n " , toolName , filePath , fileExt )
154+ // fmt.Printf("[DEBUG2 ] Tool %s supports file %s (matched ext: %s)\n", toolName, filePath, fileExt)
124155 return true
125156 }
126157 }
@@ -138,7 +169,7 @@ func IsToolSupportedForFile(toolName string, filePath string, langConfig *Langua
138169 }
139170
140171 // If tool not found in config, assume it's supported
141- fmt .Printf ("[DEBUG ] Tool %s not found in language config, assuming it supports file %s\n " , toolName , filePath )
172+ // fmt.Printf("[DEBUG3 ] Tool %s not found in language config, assuming it supports file %s\n", toolName, filePath)
142173 return true
143174}
144175
0 commit comments