Package net.sourceforge.pmd.cpd
Interface TokenFactory
-
- All Superinterfaces:
AutoCloseable
public interface TokenFactory extends AutoCloseable
Proxy to record tokens from withinCpdLexer.tokenize(TextDocument, TokenFactory).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidclose()This adds the EOF token, it must be called whenCpdLexer.tokenize(TextDocument, TokenFactory)is done.LexExceptionmakeLexException(int line, int column, String message, @Nullable Throwable cause)@Nullable TokenEntrypeekLastToken()Returns the last token that has been recorded in this file.voidrecordToken(@NonNull String image, int startLine, int startCol, int endLine, int endCol)Record a token given its coordinates.default voidrecordToken(@NonNull String image, @NonNull FileLocation location)Record a token given its coordinates.voidsetImage(TokenEntry entry, @NonNull String newImage)Sets the image of an existing token entry.
-
-
-
Method Detail
-
recordToken
void recordToken(@NonNull String image, int startLine, int startCol, int endLine, int endCol)
Record a token given its coordinates. Coordinates must match the requirements ofFileLocation, ie, be 1-based and ordered properly.- Parameters:
image- Image of the token. This will be taken into account to determine the hash value of the token.startLine- Start line of the tokenstartCol- Start column of the tokenendLine- End line of the tokenendCol- End column of the token
-
recordToken
default void recordToken(@NonNull String image, @NonNull FileLocation location)
Record a token given its coordinates. Coordinates must match the requirements ofFileLocation, ie, be 1-based and ordered properly.- Parameters:
image- Image of the token. This will be taken into account to determine the hash value of the token.location- Location of the token.
-
makeLexException
LexException makeLexException(int line, int column, String message, @Nullable Throwable cause)
-
setImage
void setImage(TokenEntry entry, @NonNull String newImage)
Sets the image of an existing token entry.
-
peekLastToken
@Nullable TokenEntry peekLastToken()
Returns the last token that has been recorded in this file.
-
close
void close()
This adds the EOF token, it must be called whenCpdLexer.tokenize(TextDocument, TokenFactory)is done.- Specified by:
closein interfaceAutoCloseable
-
-