feat: Add enum member extraction support across all language extractors
Extends AST parsing to identify and extract individual enum members/cases for better code analysis. Adds enumMemberTypes configuration to each language extractor with language-specific node types (e.g., 'enum_variant' for Rust, 'enum_case' for PHP, 'enum_entry' for Swift/Kotlin). Implements flexible member name resolution supporting both field-based and identifier-based extraction patterns.
This commit is contained in:
@@ -9,6 +9,7 @@ export const cExtractor: LanguageExtractor = {
|
||||
interfaceTypes: [],
|
||||
structTypes: ['struct_specifier'],
|
||||
enumTypes: ['enum_specifier'],
|
||||
enumMemberTypes: ['enumerator'],
|
||||
typeAliasTypes: ['type_definition'], // typedef
|
||||
importTypes: ['preproc_include'],
|
||||
callTypes: ['call_expression'],
|
||||
@@ -41,6 +42,7 @@ export const cppExtractor: LanguageExtractor = {
|
||||
interfaceTypes: [],
|
||||
structTypes: ['struct_specifier'],
|
||||
enumTypes: ['enum_specifier'],
|
||||
enumMemberTypes: ['enumerator'],
|
||||
typeAliasTypes: ['type_definition', 'alias_declaration'], // typedef and using
|
||||
importTypes: ['preproc_include'],
|
||||
callTypes: ['call_expression'],
|
||||
|
||||
@@ -9,6 +9,7 @@ export const csharpExtractor: LanguageExtractor = {
|
||||
interfaceTypes: ['interface_declaration'],
|
||||
structTypes: ['struct_declaration'],
|
||||
enumTypes: ['enum_declaration'],
|
||||
enumMemberTypes: ['enum_member_declaration'],
|
||||
typeAliasTypes: [],
|
||||
importTypes: ['using_directive'],
|
||||
callTypes: ['invocation_expression'],
|
||||
|
||||
@@ -9,6 +9,7 @@ export const dartExtractor: LanguageExtractor = {
|
||||
interfaceTypes: [],
|
||||
structTypes: [],
|
||||
enumTypes: ['enum_declaration'],
|
||||
enumMemberTypes: ['enum_constant'],
|
||||
typeAliasTypes: ['type_alias'],
|
||||
importTypes: ['import_or_export'],
|
||||
callTypes: [], // Dart calls use identifier+selector, handled via function body traversal
|
||||
|
||||
@@ -9,6 +9,7 @@ export const javaExtractor: LanguageExtractor = {
|
||||
interfaceTypes: ['interface_declaration'],
|
||||
structTypes: [],
|
||||
enumTypes: ['enum_declaration'],
|
||||
enumMemberTypes: ['enum_constant'],
|
||||
typeAliasTypes: [],
|
||||
importTypes: ['import_declaration'],
|
||||
callTypes: ['method_invocation'],
|
||||
|
||||
@@ -9,6 +9,7 @@ export const kotlinExtractor: LanguageExtractor = {
|
||||
interfaceTypes: ['class_declaration'], // Interfaces use class_declaration with 'interface' modifier
|
||||
structTypes: [], // Kotlin uses data classes
|
||||
enumTypes: ['class_declaration'], // Enums use class_declaration with 'enum' modifier
|
||||
enumMemberTypes: ['enum_entry'],
|
||||
typeAliasTypes: ['type_alias'],
|
||||
importTypes: ['import_header'],
|
||||
callTypes: ['call_expression'],
|
||||
|
||||
@@ -9,6 +9,7 @@ export const phpExtractor: LanguageExtractor = {
|
||||
interfaceTypes: ['interface_declaration'],
|
||||
structTypes: [],
|
||||
enumTypes: ['enum_declaration'],
|
||||
enumMemberTypes: ['enum_case'],
|
||||
typeAliasTypes: [],
|
||||
importTypes: ['namespace_use_declaration'],
|
||||
callTypes: ['function_call_expression', 'member_call_expression', 'scoped_call_expression'],
|
||||
|
||||
@@ -9,6 +9,7 @@ export const rustExtractor: LanguageExtractor = {
|
||||
interfaceTypes: ['trait_item'],
|
||||
structTypes: ['struct_item'],
|
||||
enumTypes: ['enum_item'],
|
||||
enumMemberTypes: ['enum_variant'],
|
||||
typeAliasTypes: ['type_item'], // Rust type aliases
|
||||
importTypes: ['use_declaration'],
|
||||
callTypes: ['call_expression'],
|
||||
|
||||
@@ -9,6 +9,7 @@ export const swiftExtractor: LanguageExtractor = {
|
||||
interfaceTypes: ['protocol_declaration'],
|
||||
structTypes: ['struct_declaration'],
|
||||
enumTypes: ['enum_declaration'],
|
||||
enumMemberTypes: ['enum_entry'],
|
||||
typeAliasTypes: ['typealias_declaration'],
|
||||
importTypes: ['import_declaration'],
|
||||
callTypes: ['call_expression'],
|
||||
|
||||
@@ -8,6 +8,7 @@ export const typescriptExtractor: LanguageExtractor = {
|
||||
interfaceTypes: ['interface_declaration'],
|
||||
structTypes: [],
|
||||
enumTypes: ['enum_declaration'],
|
||||
enumMemberTypes: ['property_identifier', 'enum_assignment'],
|
||||
typeAliasTypes: ['type_alias_declaration'],
|
||||
importTypes: ['import_statement'],
|
||||
callTypes: ['call_expression'],
|
||||
|
||||
Reference in New Issue
Block a user