类 JavaLikeLangLineIndentProvider

java.lang.Object
com.intellij.psi.impl.source.codeStyle.lineIndent.JavaLikeLangLineIndentProvider
所有已实现的接口:
LineIndentProvider

public abstract class JavaLikeLangLineIndentProvider extends Object implements LineIndentProvider
  • 构造器详细资料

    • JavaLikeLangLineIndentProvider

      public JavaLikeLangLineIndentProvider(@NotNull @NotNull CharSequence charSequence, @NotNull @NotNull ITokenSequence tokenSequence, @NotNull @NotNull IndentOptions indentOptions)
  • 方法详细资料

    • getLineIndent

      @Nullable public @Nullable String getLineIndent(int offset)
      从接口复制的说明: LineIndentProvider
      Calculates the indent that should be used for the line at specified offset in the specified document.
      指定者:
      getLineIndent 在接口中 LineIndentProvider
      参数:
      offset - The caret offset in the editor.
      返回:
      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 LineIndentProvider.DO_NOT_ADJUST constant to leave the current caret position as is without any further formatter-based adjustment.
    • getIndent

      @Nullable protected @Nullable IndentCalculator getIndent(int offset)
    • isInArray

      protected boolean isInArray(int offset)
      Checks that the current offset is inside array. By default it is assumed to be after opening array bracket but can be overridden for more complicated logic, for example, the following case in Java: []{<caret>}.
      参数:
      offset - The current offset in the editor.
      返回:
      true if the position is inside array.
    • dropIndentAfterReturnLike

      protected boolean dropIndentAfterReturnLike(@NotNull @NotNull SemanticEditorPosition statementBeforeSemicolon)
      Checking the document context in position for return-like token (i.e. return, break, continue), after that we need to reduce the indent (for example after break; in switch statement).
      参数:
      statementBeforeSemicolon - position in the document context
      返回:
      true, if need to reduce the indent
    • isColonAfterLabelOrCase

      protected boolean isColonAfterLabelOrCase(@NotNull @NotNull SemanticEditorPosition position)
    • isInsideForLikeConstruction

      protected boolean isInsideForLikeConstruction(SemanticEditorPosition position)
    • getBlockStatementStartOffset

      protected int getBlockStatementStartOffset(@NotNull @NotNull SemanticEditorPosition position)
      Returns the start offset of the statement or new-line-'{' that owns the code block in position.

      Custom implementation for language can overwrite the default behavior for multi-lines statements like

      
          template<class T>
          class A {};
       
      or check indentation after new-line-'{' vs the brace style.
      参数:
      position - the position in the code block
    • getDeepBlockStatementStartOffset

      protected int getDeepBlockStatementStartOffset(@NotNull @NotNull SemanticEditorPosition position)
      Returns the start offset of the statement that owns the code block in position
      参数:
      position - the position in the code block
    • isStartOfStatementWithOptionalBlock

      protected boolean isStartOfStatementWithOptionalBlock(@NotNull @NotNull SemanticEditorPosition position)
      Returns true if the position starts a statement that can have a code block and the statement is the first in the code line. In C-like languages it is one of if, else, for, while, do, try.
      参数:
      position -
    • isIndentProvider

      protected boolean isIndentProvider(@NotNull @NotNull SemanticEditorPosition statementStartPosition, boolean ignoreLabels)
      Checking the document context in position as indent-provider.
      参数:
      statementStartPosition - position is the document
      ignoreLabels - true, if labels cannot be used as indent-providers in the context.
      返回:
      true, if statement is indent-provider (by default)
    • getPosition

      public SemanticEditorPosition getPosition(int offset)
      Returns abstract semantic position in editor for indent calculation.
      参数:
      offset - the offset in the editor
    • getIteratorAtPosition

      @NotNull protected @NotNull LexemeIterator getIteratorAtPosition(int offset)
    • mapType

      @Nullable protected abstract SemanticEditorPosition.SyntaxElement mapType(@NotNull @NotNull IElementType tokenType)
    • getIndentInBlock

      @Nullable protected @Nullable Indent getIndentInBlock(@NotNull @NotNull SemanticEditorPosition blockStartPosition)
    • getDefaultIndentFromType

      @Contract("null -> null") protected static Indent getDefaultIndentFromType(@Nullable @Nullable Indent.Type type)
    • isSuitableFor

      @Contract("null -> false") public final boolean isSuitableFor(@Nullable @Nullable Language language)
      指定者:
      isSuitableFor 在接口中 LineIndentProvider
    • isSuitableForLanguage

      public abstract boolean isSuitableForLanguage(@NotNull @NotNull Language language)
    • getIndentTypeInBrackets

      protected Indent.Type getIndentTypeInBrackets()
    • getIndentInBrackets

      protected Indent getIndentInBrackets()