Class RuleBasedPartitionScanner

All Implemented Interfaces:
ICharacterScanner, IPartitionTokenScanner, ITokenScanner

public class RuleBasedPartitionScanner extends BufferedRuleBasedScanner implements IPartitionTokenScanner
Scanner that exclusively uses predicate rules.

If a partial range is set (see setPartialRange(IDocument, int, int, String, int) with content type that is not null then this scanner will first try the rules that match the given content type.

Originally since 2.0, but moved to org.eclipse.text in 3.14
Since:
3.14
  • Field Details

    • fContentType

      protected String fContentType
      The content type of the partition in which to resume scanning.
    • fPartitionOffset

      protected int fPartitionOffset
      The offset of the partition inside which to resume.
  • Constructor Details

    • RuleBasedPartitionScanner

      public RuleBasedPartitionScanner()
  • Method Details

    • setRules

      public void setRules(IRule... rules)
      Disallow setting the rules since this scanner exclusively uses predicate rules.
      Overrides:
      setRules in class RuleBasedScanner
      Parameters:
      rules - the sequence of rules controlling this scanner
    • setPredicateRules

      public void setPredicateRules(IPredicateRule[] rules)
    • setRange

      public void setRange(IDocument document, int offset, int length)
      Description copied from interface: ITokenScanner
      Configures the scanner by providing access to the document range that should be scanned.
      Specified by:
      setRange in interface ITokenScanner
      Overrides:
      setRange in class BufferedRuleBasedScanner
      Parameters:
      document - the document to scan
      offset - the offset of the document range to scan
      length - the length of the document range to scan
    • setPartialRange

      public void setPartialRange(IDocument document, int offset, int length, String contentType, int partitionOffset)
      Configures the scanner by providing access to the document range that should be scanned. The range may not only contain complete partitions but starts at the beginning of a line in the middle of a partition of the given content type. This requires that a partition delimiter can not contain a line delimiter.

      If the given content type is not null then this scanner will first try the rules that match the given content type.

      Specified by:
      setPartialRange in interface IPartitionTokenScanner
      Parameters:
      document - the document to scan
      offset - the offset of the document range to scan
      length - the length of the document range to scan
      contentType - the content type at the given offset
      partitionOffset - the offset at which the partition of the given offset starts
    • nextToken

      public IToken nextToken()
      Description copied from interface: ITokenScanner
      Returns the next token in the document.
      Specified by:
      nextToken in interface ITokenScanner
      Overrides:
      nextToken in class RuleBasedScanner
      Returns:
      the next token in the document