Package codeanalysis

Class DiagnosticBox

java.lang.Object
codeanalysis.DiagnosticBox
All Implemented Interfaces:
Iterator<Diagnostic>

public class DiagnosticBox extends Object implements Iterator<Diagnostic>
The DiagnosticBox class represents a collection of diagnostics produced during code analysis. It allows iterating over the diagnostics and provides methods for adding new diagnostics.
Version:
1.0
Author:
Siyabend Urun
See Also:
  • Constructor Details

    • DiagnosticBox

      public DiagnosticBox()
  • Method Details

    • hasNext

      public boolean hasNext()
      Checks if there are more diagnostics to iterate over.
      Specified by:
      hasNext in interface Iterator<Diagnostic>
      Returns:
      true if there are more diagnostics, false otherwise.
    • next

      public Diagnostic next()
      Retrieves the next diagnostic in the collection.
      Specified by:
      next in interface Iterator<Diagnostic>
      Returns:
      The next diagnostic.
      Throws:
      NoSuchElementException - if there are no more diagnostics to retrieve.
    • addAll

      public DiagnosticBox addAll(DiagnosticBox diagnostics)
      Adds all diagnostics from another DiagnosticBox to this DiagnosticBox.
      Parameters:
      diagnostics - The DiagnosticBox containing additional diagnostics to be added.
      Returns:
      This DiagnosticBox instance.
    • reportInvalidNumber

      public void reportInvalidNumber(TextSpan span, String text, Class<Integer> type)
      Reports an error for an invalid number with the specified TextSpan, number text, and expected type.
      Parameters:
      span - The TextSpan representing the location of the invalid number.
      text - The invalid number text.
      type - The expected type of the number.
    • reportBadCharacter

      public void reportBadCharacter(int position, char c)
      Reports an error for a bad character input at the specified position.
      Parameters:
      position - The position of the bad character in the input.
      c - The bad character.
    • reportUnexpectedToken

      public void reportUnexpectedToken(TextSpan span, SyntaxType actualType, SyntaxType expectedType)
      Reports an error for an unexpected token with the specified TextSpan, actual type, and expected type.
      Parameters:
      span - The TextSpan representing the location of the unexpected token.
      actualType - The actual syntax type of the token.
      expectedType - The expected syntax type of the token.
    • reportUndefinedUnaryOperator

      public void reportUndefinedUnaryOperator(TextSpan span, String data, Class<?> operandType)
      Reports an error for an undefined unary operator with the specified TextSpan, operator data, and operand type.
      Parameters:
      span - The TextSpan representing the location of the undefined unary operator.
      data - The data of the undefined unary operator.
      operandType - The type of the operand.
    • reportUndefinedBinaryOperator

      public void reportUndefinedBinaryOperator(TextSpan span, String data, Class<?> leftType, Class<?> rightType)
      Reports an error for an undefined binary operator with the specified TextSpan, operator data, left type, and right type.
      Parameters:
      span - The TextSpan representing the location of the undefined binary operator.
      data - The data of the undefined binary operator.
      leftType - The type of the left operand.
      rightType - The type of the right operand.
    • reportUndefinedName

      public void reportUndefinedName(TextSpan span, String name)
      Reports an undefined name diagnostic with the specified span and name.
      Parameters:
      span - The text span where the undefined name occurs.
      name - The undefined name.