Interface PairedBraceMatcher


public interface PairedBraceMatcher
Defines the brace matching support required for a custom language. For paired brace matching to work, the language must also provide a com.intellij.openapi.fileTypes.SyntaxHighlighter and return the correct lexer from getHighlightingLexer().
See Also:
  • LanguageBraceMatching
  • BracePair
  • com.intellij.codeInsight.highlighting.BraceMatcherTerminationAspect
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    getCodeConstructStart(PsiFile file, int openingBraceOffset)
    Returns the start offset of the code construct which owns the opening structural brace at the specified offset.
    BracePair @NotNull []
    Returns the array of definitions for brace pairs that need to be matched when editing code in the language.
    boolean
    isPairedBracesAllowedBeforeType(@NotNull IElementType lbraceType, @Nullable IElementType contextType)
    Returns true if paired rbrace should be inserted after lbrace of given type when lbrace is encountered before contextType token.
  • Method Details

    • getPairs

      BracePair @NotNull [] getPairs()
      Returns the array of definitions for brace pairs that need to be matched when editing code in the language.
      Returns:
      the array of brace pair definitions.
    • isPairedBracesAllowedBeforeType

      boolean isPairedBracesAllowedBeforeType(@NotNull @NotNull IElementType lbraceType, @Nullable @Nullable IElementType contextType)
      Returns true if paired rbrace should be inserted after lbrace of given type when lbrace is encountered before contextType token. It is safe to always return true, then paired brace will be inserted anyway.
      Parameters:
      lbraceType - lbrace for which information is queried
      contextType - token type that follows lbrace
      Returns:
      true / false as described
    • getCodeConstructStart

      int getCodeConstructStart(PsiFile file, int openingBraceOffset)
      Returns the start offset of the code construct which owns the opening structural brace at the specified offset. For example, if the opening brace belongs to an 'if' statement, returns the start offset of the 'if' statement.
      Parameters:
      file - the file in which brace matching is performed.
      openingBraceOffset - the offset of an opening structural brace.
      Returns:
      the offset of corresponding code construct, or the same offset if not defined.