Package codeanalysis
Class DiagnosticBox
java.lang.Object
codeanalysis.DiagnosticBox
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddAll(DiagnosticBox diagnostics) Adds all diagnostics from another DiagnosticBox to this DiagnosticBox.booleanhasNext()Checks if there are more diagnostics to iterate over.next()Retrieves the next diagnostic in the collection.voidreportBadCharacter(int position, char c) Reports an error for a bad character input at the specified position.voidreportInvalidNumber(TextSpan span, String text, Class<Integer> type) Reports an error for an invalid number with the specified TextSpan, number text, and expected type.voidreportUndefinedBinaryOperator(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.voidreportUndefinedName(TextSpan span, String name) Reports an undefined name diagnostic with the specified span and name.voidreportUndefinedUnaryOperator(TextSpan span, String data, Class<?> operandType) Reports an error for an undefined unary operator with the specified TextSpan, operator data, and operand type.voidreportUnexpectedToken(TextSpan span, SyntaxType actualType, SyntaxType expectedType) Reports an error for an unexpected token with the specified TextSpan, actual type, and expected type.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Constructor Details
-
DiagnosticBox
public DiagnosticBox()
-
-
Method Details
-
hasNext
public boolean hasNext()Checks if there are more diagnostics to iterate over.- Specified by:
hasNextin interfaceIterator<Diagnostic>- Returns:
trueif there are more diagnostics,falseotherwise.
-
next
Retrieves the next diagnostic in the collection.- Specified by:
nextin interfaceIterator<Diagnostic>- Returns:
- The next diagnostic.
- Throws:
NoSuchElementException- if there are no more diagnostics to retrieve.
-
addAll
Adds all diagnostics from another DiagnosticBox to this DiagnosticBox.- Parameters:
diagnostics- The DiagnosticBox containing additional diagnostics to be added.- Returns:
- This DiagnosticBox instance.
-
reportInvalidNumber
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
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
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
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.
-