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 Detail

      • 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. Use InputFile.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).
      • 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.