(self)
| 578 | |
| 579 | class JavaScriptParser(LanguageParser): # This is the old regex-based parser |
| 580 | def __init__(self): |
| 581 | # Regex for functions, classes, and basic imports/exports. |
| 582 | # WARNING: Regex-based parsing for JS/TS is very limited and error-prone. |
| 583 | # A proper AST parser (e.g., esprima, acorn, or tree-sitter) is highly recommended for robust analysis. |
| 584 | |
| 585 | # function funcName(...) or const funcName = (...) => { ... } or let funcName = function(...) |
| 586 | self.function_pattern = re.compile( |
| 587 | r"^\s*(?:async\s+)?function\s+([a-zA-Z0-9_]+)\s*\(|" # function foo() |
| 588 | r"^\s*(?:const|let|var)\s+([a-zA-Z0-9_]+)\s*=\s*(?:async\s*)?\(?[^)]*\)?\s*=>|" # const foo = () => |
| 589 | r"^\s*(?:const|let|var)\s+([a-zA-Z0-9_]+)\s*=\s*function\s*\(", # const foo = function() |
| 590 | re.MULTILINE, |
| 591 | ) |
| 592 | |
| 593 | self.class_pattern = re.compile( |
| 594 | r"^\s*class\s+([a-zA-Z0-9_]+)(?:\s+extends\s+([a-zA-Z0-9_]+))?", |
| 595 | re.MULTILINE, |
| 596 | ) |
| 597 | |
| 598 | # import defaultExport from 'module'; import { namedExport } from 'module'; import * as name from 'module'; |
| 599 | self.import_pattern = re.compile( |
| 600 | r"import\s+(?:(.+?)\s+from\s+)?['\"]([^'\"]+)['\"]", re.MULTILINE |
| 601 | ) |
| 602 | pass |
| 603 | |
| 604 | def parse( |
| 605 | self, files_data: List[Dict[str, Any]], all_files_content: Dict[str, str] |
nothing calls this directly
no outgoing calls
no test coverage detected