Class SyntaxCheckGrader
java.lang.Object
com.spertus.jacquard.common.Grader
com.spertus.jacquard.syntaxgrader.SyntaxGrader
com.spertus.jacquard.syntaxgrader.SyntaxCheckGrader
- Direct Known Subclasses:
FieldModifierGrader,ImportForbiddenGrader,ImportRequiredGrader,MethodModifierGrader
The base class for syntax-based graders that may involve multiple items of
the same type. Examples include:
-
MethodModifierGrader, which checks whether each of a list of methods has the correct modifiers, awarding up tomaxScorePerInstanceper method -
ImportRequiredGrader, which checks whether all required imports are present, awarding up tomaxScorePerInstanceper import -
ImportDisallowedGrader, which checks whether any disallowed imports are present, awarding or withholdingmaxScorePerInstance(all or nothing)
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe adapter that visits the nodes of the parse tree.protected final doubleThe maximum score per instance checked. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSyntaxCheckGrader(String name, double maxScorePerInstance, com.github.javaparser.ast.visitor.VoidVisitorAdapter<List<Result>> adapter) Constructs a syntax checker. -
Method Summary
Modifier and TypeMethodDescriptionvoidfinalizeResults(List<Result> results) Adds any results that cannot be computed until all visits are complete.grade(com.github.javaparser.ast.CompilationUnit cu) Grades the parsed compilation unit.voidPerforms any setup before a call tograde(CompilationUnit).protected ResultmakeFailingResult(String message) Creates a result indicating total failure.protected ResultmakeSuccessResult(String message) Creates a result indicating total success.Methods inherited from class com.spertus.jacquard.syntaxgrader.SyntaxGrader
getCallableSingleTargetMethods inherited from class com.spertus.jacquard.common.Grader
getCallableMultiTarget, grade, grade, gradeAll, makeExceptionResult, makeExceptionResultList, makeFailureResult, makeFailureResultList, makePartialCreditResult, makeSuccessResult, makeSuccessResultList
-
Field Details
-
maxScorePerInstance
protected final double maxScorePerInstanceThe maximum score per instance checked. -
adapter
The adapter that visits the nodes of the parse tree. If this is not passed to this class's constructor, it must be set in the child class's constructor.
-
-
Constructor Details
-
SyntaxCheckGrader
protected SyntaxCheckGrader(String name, double maxScorePerInstance, com.github.javaparser.ast.visitor.VoidVisitorAdapter<List<Result>> adapter) Constructs a syntax checker. If the adapter is null, the constructor in the concrete subclass must set it before returning. (Non-static adapters that are inner classes cannot be created until this constructor has completed.)- Parameters:
name- the name of the syntax checkermaxScorePerInstance- the maximum score per application of the checkadapter- the adapter ornull
-
-
Method Details
-
initialize
public void initialize()Performs any setup before a call tograde(CompilationUnit). -
finalizeResults
Adds any results that cannot be computed until all visits are complete.- Parameters:
results- the list of results, which may be mutated by this call
-
grade
Description copied from class:SyntaxGraderGrades the parsed compilation unit.- Specified by:
gradein classSyntaxGrader- Parameters:
cu- the parsed compilation unit- Returns:
- the results
-
makeFailingResult
Creates a result indicating total failure.- Parameters:
message- an accompanying message- Returns:
- the result
-
makeSuccessResult
Creates a result indicating total success.- Parameters:
message- an accompanying message- Returns:
- the result
-