Package net.sourceforge.pmd.cpd
Interface TokenFactory
-
- All Superinterfaces:
AutoCloseable
public interface TokenFactory extends AutoCloseable
Proxy to record tokens from withinTokenizer.tokenize(TextDocument, TokenFactory)
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
close()
This adds the EOF token, it must be called whenTokenizer.tokenize(TextDocument, TokenFactory)
is done.TokenMgrError
makeLexException(int line, int column, String message, @Nullable Throwable cause)
@Nullable TokenEntry
peekLastToken()
Returns the last token that has been recorded in this file.void
recordToken(@NonNull String image, int startLine, int startCol, int endLine, int endCol)
Record a token given its coordinates.default void
recordToken(@NonNull String image, @NonNull FileLocation location)
Record a token given its coordinates.void
setImage(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
TokenMgrError 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 whenTokenizer.tokenize(TextDocument, TokenFactory)
is done.- Specified by:
close
in interfaceAutoCloseable
-
-