Package org.sonar.api.batch.sensor.cpd
Interface NewCpdTokens
-
- All Known Implementing Classes:
DefaultCpdTokens
public interface NewCpdTokens
This builder is used to define tokens used by CPD algorithm on files. Example:sensorContext.newCpdTokens().onFile(inputFile) .addToken(1, 10, 1, 15, "class") .addToken(1, 16, 1, 18, "IDENTIFIER") // Add more tokens .save;
- Since:
- 5.5
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description NewCpdTokens
addToken(int startLine, int startLineOffset, int endLine, int endLineOffset, java.lang.String image)
Shortcut to avoid callingInputFile.newRange(int, int, int, int)
NewCpdTokens
addToken(TextRange range, java.lang.String image)
Call this method to register a token in a range.NewCpdTokens
onFile(InputFile inputFile)
The tokenized file.void
save()
Call this method only once when your are done with defining tokens of the file.
-
-
-
Method Detail
-
onFile
NewCpdTokens onFile(InputFile inputFile)
The tokenized file.
-
addToken
NewCpdTokens addToken(TextRange range, java.lang.String image)
Call this method to register a token in a range. Tokens should be registered in order.- Parameters:
range
- Token position. UseInputFile.newRange(int, int, int, int)
to get a valid range.image
- Text content of the token. Can be replaced by a constant placeholder for some tokens (like litterals).
-
addToken
NewCpdTokens addToken(int startLine, int startLineOffset, int endLine, int endLineOffset, java.lang.String image)
Shortcut to avoid callingInputFile.newRange(int, int, int, int)
- Since:
- 5.6
-
save
void save()
Call this method only once when your are done with defining tokens of the file. It is not supported to save CPD tokens twice for the same file.
-
-