JSValidator class

A validator that uses the visitor pattern to validate JavaScript code

Constructors

JSValidator.new(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
visitArrowFunctionNode(ArrowFunctionNode node) bool
visitAssignment(AssignmentExpression node) bool
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
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
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
visitProgram(Program node) bool?
inherited
visitPrograms(Programs node) bool?
inherited
visitProperty(Property node) bool?
inherited
visitRegexp(RegexpExpression node) bool?
inherited
visitReturn(ReturnStatement node) bool?
inherited
visitSequence(SequenceExpression node) bool?
inherited
visitSwitch(SwitchStatement node) bool?
inherited
visitSwitchCase(SwitchCase 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