Package net.sourceforge.pmd.cpd
Interface TokenFactory
- All Superinterfaces:
AutoCloseable
Proxy to record tokens from within
CpdLexer.tokenize(TextDocument, TokenFactory).-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()This adds the EOF token, it must be called whenCpdLexer.tokenize(TextDocument, TokenFactory)is done.makeLexException(int line, int column, String message, @Nullable Throwable cause) @Nullable TokenEntryReturns 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 Details
-
recordToken
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
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
-
setImage
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
-