JSValidator class

A validator that uses the visitor pattern to validate JavaScript code

Constructors

JSValidator(String code, Program program, Context context)

Properties

code → String
final
context → Context
final
currentContext → Context
no setter
hashCode → int
The hash code for this object.
no setterinherited
program → Program
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

defaultNode(Node node) → bool
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
popContext() → void
pushContext(Context ctx) → void
toString() → String
A string representation of this object.
inherited
validate({Node? node}) → bool
Validates the JavaScript AST with context-aware rules Checks for syntax errors, undefined variables/objects, invalid property or method access, and provides typo suggestions. Throws JSException if validation fails; returns true if valid.
validateContextExistence(String name, Node node, Context programContext, {bool isObject = false}) → void
Checks whether the given name exists in the programContext. If not, throws an exception with details and possible recovery suggestions.
validateObjectPath(MemberExpression node) → void
Validates a chain of property accesses
validatePropertyOrMethodAccess(String propertyName, String objectName, dynamic obj, Node node) → void
Validates that a property or method exists on the given object. In case of a typo, it provides suggestions based on Levenshtein distance.
visit(Node? node) → bool?
Shorthand for node.visitBy(this).
inherited
visitArray(ArrayExpression node) → bool?
inherited
visitArrayPattern(ArrayPattern node) → bool?
inherited
visitArrowFunctionNode(ArrowFunctionNode node) → bool
visitAssignment(AssignmentExpression node) → bool
visitAwait(AwaitExpression node) → bool?
inherited
visitBinary(BinaryExpression node) → bool?
inherited
visitBlock(BlockStatement node) → bool?
inherited
visitBreak(BreakStatement node) → bool?
inherited
visitCall(CallExpression node) → bool
visitCatchClause(CatchClause node) → bool?
inherited
visitConditional(ConditionalExpression node) → bool?
inherited
visitContinue(ContinueStatement node) → bool?
inherited
visitDebugger(DebuggerStatement node) → bool?
inherited
visitDefaultParameter(DefaultParameter node) → bool?
inherited
visitDoWhile(DoWhileStatement node) → bool?
inherited
visitEmptyStatement(EmptyStatement node) → bool?
inherited
visitExpressionStatement(ExpressionStatement node) → bool?
inherited
visitFor(ForStatement node) → bool?
inherited
visitForIn(ForInStatement node) → bool?
inherited
visitForOf(ForOfStatement node) → bool?
inherited
visitFunctionDeclaration(FunctionDeclaration node) → bool
visitFunctionExpression(FunctionExpression node) → bool
visitFunctionNode(FunctionNode node) → bool?
inherited
visitIf(IfStatement node) → bool?
inherited
visitIndex(IndexExpression node) → bool?
inherited
visitLabeledStatement(LabeledStatement node) → bool?
inherited
visitLiteral(LiteralExpression node) → bool?
inherited
visitMember(MemberExpression node) → bool
visitName(Name node) → bool?
inherited
visitNameExpression(NameExpression node) → bool
visitObject(ObjectExpression node) → bool
visitObjectPattern(ObjectPattern node) → bool?
inherited
visitProgram(Program node) → bool?
inherited
visitPrograms(Programs node) → bool?
inherited
visitProperty(Property node) → bool?
inherited
visitRegexp(RegexpExpression node) → bool?
inherited
visitRestParameter(RestParameter node) → bool?
inherited
visitReturn(ReturnStatement node) → bool?
inherited
visitSequence(SequenceExpression node) → bool?
inherited
visitSpread(SpreadExpression node) → bool?
inherited
visitSwitch(SwitchStatement node) → bool?
inherited
visitSwitchCase(SwitchCase node) → bool?
inherited
visitTaggedTemplate(TaggedTemplateExpression node) → bool?
inherited
visitTemplateLiteral(TemplateLiteral node) → bool?
inherited
visitThis(ThisExpression node) → bool?
inherited
visitThrow(ThrowStatement node) → bool?
inherited
visitTry(TryStatement node) → bool?
inherited
visitUnary(UnaryExpression node) → bool?
inherited
visitUpdateExpression(UpdateExpression node) → bool?
inherited
visitVariableDeclaration(VariableDeclaration node) → bool
visitVariableDeclarator(VariableDeclarator node) → bool?
inherited
visitWhile(WhileStatement node) → bool?
inherited
visitWith(WithStatement node) → bool?
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited