Interface LineIndentProvider

All Known Implementing Classes:
JavaLikeLangLineIndentProvider

public interface LineIndentProvider
An interface for fast indentation calculation as an alternative to formatter-based logic. Used in editor actions like Enter handling. Assumes that indent string is constructed using the editor document editor.getDocument() and the current offset without any document commits and PSI tree rebuilding which can be a time consuming operation. If there is no LineIndentProvider for the current editor and language context OR if a line indent provider can't calculate the indent (returns null), the document is committed and a formatter-based line indent calculation is performed.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Marker object to indicate that no further formatter-based indent adjustment must be made.
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable String
    getLineIndent(int offset)
    Calculates the indent that should be used for the line at specified offset in the specified document.
    boolean
    isSuitableFor(@Nullable Language language)
     
  • Field Details

    • DO_NOT_ADJUST

      static final String DO_NOT_ADJUST
      Marker object to indicate that no further formatter-based indent adjustment must be made.
  • Method Details

    • getLineIndent

      @Nullable @Nullable String getLineIndent(int offset)
      Calculates the indent that should be used for the line at specified offset in the specified document.
      Parameters:
      offset - The caret offset in the editor.
      Returns:
      The indent string (possibly consisting of tabs and/or white spaces), null if LineIndentProvider can't calculate the indent (in this case indent calculation is delegated to formatter if smart indent mode is used) or DO_NOT_ADJUST constant to leave the current caret position as is without any further formatter-based adjustment.
    • isSuitableFor

      boolean isSuitableFor(@Nullable @Nullable Language language)