Class SyntaxCheckGrader

Direct Known Subclasses:
FieldModifierGrader, ImportForbiddenGrader, ImportRequiredGrader, MethodModifierGrader

public abstract class SyntaxCheckGrader extends SyntaxGrader
The base class for syntax-based graders that may involve multiple items of the same type. Examples include:
  • Field Details

    • maxScorePerInstance

      protected final double maxScorePerInstance
      The maximum score per instance checked.
    • adapter

      protected com.github.javaparser.ast.visitor.VoidVisitorAdapter<List<Result>> 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 checker
      maxScorePerInstance - the maximum score per application of the check
      adapter - the adapter or null
  • Method Details

    • initialize

      public void initialize()
      Performs any setup before a call to grade(CompilationUnit).
    • finalizeResults

      public void finalizeResults(List<Result> results)
      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

      public List<Result> grade(com.github.javaparser.ast.CompilationUnit cu)
      Description copied from class: SyntaxGrader
      Grades the parsed compilation unit.
      Specified by:
      grade in class SyntaxGrader
      Parameters:
      cu - the parsed compilation unit
      Returns:
      the results
    • makeFailingResult

      protected Result makeFailingResult(String message)
      Creates a result indicating total failure.
      Parameters:
      message - an accompanying message
      Returns:
      the result
    • makeSuccessResult

      protected Result makeSuccessResult(String message)
      Creates a result indicating total success.
      Parameters:
      message - an accompanying message
      Returns:
      the result