Class SyntaxCountGrader

Direct Known Subclasses:
StringInterpolationCountGrader, SyntaxConditionCountGrader

public abstract class SyntaxCountGrader extends SyntaxGrader
The base class for counters to test whether the number of occurrences of a syntactic element is within the specified range.
  • Constructor Details

    • SyntaxCountGrader

      public SyntaxCountGrader(String name, String countedName, double maxScore, int minCount, int maxCount, com.github.javaparser.ast.visitor.VoidVisitorAdapter<MutableInteger> adapter)
      Creates a new counter to test whether the number of occurrences of an element is within the specified range.
      Parameters:
      name - the name of this processor (for the Result)
      countedName - the name of the element (for the Result)
      maxScore - the score if the condition holds
      minCount - the minimum number of occurrences
      maxCount - the maximum number of occurrences, or Integer.MAX_VALUE if there is no limit.
      adapter - an adapter for visiting nodes in parse tree
      Throws:
      ClientException - if minCount < 0, maxCount < minCount, or minCount is 0 when maxCount is Integer.MAX_VALUE
  • Method Details

    • grade

      protected 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
    • getResult

      protected Result getResult(MutableInteger mi)
      Creates a result with an appropriate score and message based on the number of occurrences of the syntactic element.
      Parameters:
      mi - the number of occurrences of the syntactic element.
      Returns:
      the result