Class TemplateDataElementType.RangeCollector

java.lang.Object
com.intellij.psi.templateLanguages.TemplateDataElementType.RangeCollector
Direct Known Subclasses:
RangeCollectorImpl
Enclosing class:
TemplateDataElementType

public abstract static class TemplateDataElementType.RangeCollector extends Object
This collector is used for storing ranges of outer elements and ranges of artificial elements, that should be stripped from the resulting tree At the time of creating source code for the data language we need to memorize positions with template language elements. For such positions we use addOuterRange(com.intellij.openapi.util.TextRange) Sometimes to build a correct tree we need to insert additional symbols into resulting source: e.g. put an identifier instead of the base language fragment: something={% $var %} => something=dummyidentifier that must be removed after building the tree. For such additional symbols addRangeToRemove(com.intellij.openapi.util.TextRange) must be used
API Note:
Please note that all start offsets for the ranges must be in terms of "original source code". So, outer ranges are ranges of outer elements in original source code. Ranges to remove don't correspond to any text range neither in original nor in modified text. But their start offset is the offset in original text, and length is the length of inserted dummy identifier.
Implementation Note:
Should be interface, but abstract class with empty method bodies for keeping binary compatibility with plugins.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addOuterRange(@NotNull com.intellij.openapi.util.TextRange newRange)
    Adds range corresponding to the outer element inside original source code.
    abstract void
    addOuterRange(@NotNull com.intellij.openapi.util.TextRange newRange, boolean isInsertion)
    Adds range corresponding to the outer element inside original source code.
    void
    addRangeToRemove(@NotNull com.intellij.openapi.util.TextRange rangeToRemove)
    Adds the fragment that must be removed from the tree on the stage inserting outer elements.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RangeCollector

      public RangeCollector()
  • Method Details

    • addOuterRange

      public void addOuterRange(@NotNull @NotNull com.intellij.openapi.util.TextRange newRange)
      Adds range corresponding to the outer element inside original source code. After building the data template tree these ranges will be used for inserting outer language elements. If it's known whether this template element adds some string to resulting text, consider using addOuterRange(TextRange, boolean).
    • addOuterRange

      public abstract void addOuterRange(@NotNull @NotNull com.intellij.openapi.util.TextRange newRange, boolean isInsertion)
      Adds range corresponding to the outer element inside original source code. After building the data template tree these ranges will be used for inserting outer language elements.
      Parameters:
      isInsertion - true if element is expected to insert some text into template data fragment. For example, PHP's <?= $myVar ?> are insertions, while <?php foo() ?> are not.
    • addRangeToRemove

      public void addRangeToRemove(@NotNull @NotNull com.intellij.openapi.util.TextRange rangeToRemove)
      Adds the fragment that must be removed from the tree on the stage inserting outer elements. This method should be called after adding "fake" symbols inside the data language text for building syntax correct tree