This directory contains comprehensive JavaScript test files to demonstrate and test the enhanced JavaScript support in CodeGraphContext.
Demonstrates various function definition patterns:
- Regular function declarations
- Function expressions
- Arrow functions (with multiple parameters, single parameter, no parameters)
- Functions with default parameters
- Functions with rest parameters
- Functions with destructuring parameters
- Async functions
- Generator functions
- Higher-order functions
- IIFE (Immediately Invoked Function Expressions)
Demonstrates class definitions and inheritance:
- Basic class declarations
- Constructor methods
- Instance methods
- Static methods
- Getter and setter methods
- Class inheritance with
extends - Method overriding
- Private fields and methods (modern JavaScript)
- Class expressions
- Mixin patterns
Demonstrates object methods and prototype assignments:
- Object literal methods (shorthand and traditional syntax)
- Nested object methods
- Prototype method assignments
- Constructor functions with prototype methods
- Module pattern with private/public methods
- Factory functions that create objects with methods
- Methods that call other methods
- Callback and higher-order function patterns
The enhanced JavaScript parser should detect and properly index:
- Function Declarations:
function functionName(params) { ... } - Function Expressions:
const func = function(params) { ... } - Arrow Functions:
const func = (params) => { ... } - Single Parameter Arrow:
const func = param => { ... } - Method Definitions:
methodName(params) { ... }in classes and objects - Static Methods:
static methodName(params) { ... } - Prototype Methods:
Constructor.prototype.method = function(params) { ... } - Getter/Setter Methods:
get property() { ... }andset property(value) { ... }
- Index this JavaScript sample project using CodeGraphContext
- Verify that all function types are detected with correct:
- Function names
- Line numbers
- Parameter lists
- File paths
- JSDoc comments (where applicable)
After indexing, you should be able to run queries like:
// Find all JavaScript functions
MATCH (f:Function)
WHERE f.lang = 'javascript'
RETURN f.name, f.line_number, f.file_path, f.args
// Find all JavaScript classes
MATCH (c:Class)
WHERE c.lang = 'javascript'
RETURN c.name, c.line_number, c.file_path
// Find function call relationships
MATCH (caller:Function)-[r:CALLS]->(callee:Function)
WHERE caller.lang = 'javascript'
RETURN caller.name + " → " + callee.name as CallChain