Class Helpers


  • public class Helpers
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      Helpers()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int countWhiteSpace​(java.lang.CharSequence chars, int start, int end)  
      static int countWhiteSpaceReversed​(java.lang.CharSequence chars, int start, int end)  
      static com.intellij.openapi.util.Couple<java.lang.Integer> duplicateLineOrSelectedBlockAtCaret​(com.intellij.openapi.editor.Editor editor, com.intellij.openapi.editor.Document document, @NotNull com.intellij.openapi.editor.Caret caret, boolean moveCaret)  
      static @Nullable com.intellij.openapi.util.Couple<java.lang.Integer> duplicateLinesRange​(com.intellij.openapi.editor.Editor editor, com.intellij.openapi.editor.Document document, @Nullable com.intellij.openapi.editor.Caret caret, int offset, com.intellij.openapi.editor.VisualPosition rangeStart, com.intellij.openapi.editor.VisualPosition rangeEnd, boolean moveCaret)  
      static boolean endsWithQuote​(java.lang.String text)  
      static @NotNull com.vladsch.plugin.util.edit.ItemTextRange<com.intellij.lang.Language> findLanguageRangeFromElement​(com.intellij.psi.PsiElement elt)  
      static @Nullable com.vladsch.flexmark.util.sequence.Range getCaretRange​(@NotNull com.intellij.openapi.editor.Caret caret, boolean backwards, boolean lineMode, boolean singleLine)  
      static @Nullable com.vladsch.plugin.util.edit.ItemTextRange<com.intellij.lang.Commenter> getCommenterRange​(@NotNull com.intellij.openapi.editor.Editor editor, @Nullable com.intellij.psi.PsiFile file, int startOffset, int endOffset)  
      static char getCorrespondingQuoteLike​(char openingChar)  
      static @NotNull java.lang.String getCorrespondingQuoteLike​(java.lang.String openingText)  
      static int getEndOfLineOffset​(@NotNull java.lang.CharSequence charSequence, int offset)  
      static @NotNull com.vladsch.plugin.util.edit.ItemTextRange<com.intellij.lang.Language> getLanguageRangeAtOffset​(@NotNull com.intellij.psi.PsiFile file, int offset)  
      static int getNextWordEndAtOffset​(java.lang.CharSequence charSequence, int offset, int wordType, boolean isCamel, boolean stopIfNonWord)  
      static int getNextWordStartAtOffset​(java.lang.CharSequence charSequence, int offset, int wordType, boolean isCamel, boolean stopIfNonWord)  
      static int getPreviousWordEndAtOffset​(java.lang.CharSequence charSequence, int offset, int wordType, boolean isCamel, boolean stopIfNonWord)  
      static int getPreviousWordStartAtOffset​(java.lang.CharSequence charSequence, int offset, int wordType, boolean isCamel, boolean stopIfNonWord)  
      static @Nullable com.intellij.openapi.util.Pair<java.lang.String,​java.lang.String> getRangeText​(com.intellij.openapi.editor.Document document, com.vladsch.flexmark.util.sequence.Range range1, com.vladsch.flexmark.util.sequence.Range range2)
      Replace the text of range1 (non-overlapping part with range 2) with text from range2 (non-overlapping part of range 2)
      static int getStartOfLineOffset​(@NotNull java.lang.CharSequence charSequence, int offset)  
      static com.vladsch.flexmark.util.sequence.BasedSequence getWordAtOffset​(com.vladsch.flexmark.util.sequence.BasedSequence charSequence, int offset, int wordType, boolean isCamel, boolean stopIfNonWord)  
      static java.lang.CharSequence getWordAtOffset​(java.lang.CharSequence charSequence, int offset, int wordType, boolean isCamel, boolean stopIfNonWord)  
      static java.lang.String getWordAtOffset​(java.lang.String charSequence, int offset, int wordType, boolean isCamel, boolean stopIfNonWord)  
      static com.vladsch.flexmark.util.sequence.BasedSequence getWordAtOffsets​(com.vladsch.flexmark.util.sequence.BasedSequence charSequence, int start, int end, int wordType, boolean isCamel, boolean stopIfNonWord)  
      static java.lang.CharSequence getWordAtOffsets​(java.lang.CharSequence charSequence, int start, int end, int wordType, boolean isCamel, boolean stopIfNonWord)  
      static java.lang.String getWordAtOffsets​(java.lang.String charSequence, int start, int end, int wordType, boolean isCamel, boolean stopIfNonWord)  
      static int getWordEndAtOffset​(java.lang.CharSequence charSequence, int offset, int wordType, boolean isCamel, boolean stopIfNonWord)  
      static com.intellij.openapi.util.TextRange getWordRangeAtOffsets​(java.lang.CharSequence charSequence, int start, int end, int wordType, boolean isCamel, boolean stopIfNonWord)  
      static int getWordStartAtOffset​(java.lang.CharSequence charSequence, int offset, int wordType, boolean isCamel, boolean stopIfNonWord)  
      static int getWordType​(int flags)  
      static boolean isHumpBoundIdentifier​(@NotNull java.lang.CharSequence editorText, int offset, boolean start)  
      static boolean isHumpBoundWord​(@NotNull java.lang.CharSequence editorText, int offset, boolean start)  
      static boolean isIdentifier​(@NotNull java.lang.CharSequence text, int offset)  
      static boolean isIdentifierEnd​(@NotNull com.intellij.openapi.editor.Editor editor, int offset, boolean isCamel)  
      static boolean isIdentifierEnd​(@NotNull java.lang.CharSequence text, int offset, boolean isCamel)  
      static boolean isIdentifierPart​(char c)  
      static boolean isIdentifierStart​(@NotNull com.intellij.openapi.editor.Editor editor, int offset, boolean isCamel)  
      static boolean isIdentifierStart​(@NotNull java.lang.CharSequence text, int offset, boolean isCamel)  
      static boolean isLowerCaseOrDigit​(char c)  
      static boolean isPasswordEditor​(@Nullable com.intellij.openapi.editor.Editor editor)  
      static boolean isQuote​(char c)  
      static boolean isSet​(int options, int flag)  
      static boolean isSnakeCaseBound​(@NotNull java.lang.CharSequence editorText, int offset, boolean start)  
      static boolean isWhitespaceEnd​(@NotNull java.lang.CharSequence text, int offset, boolean isCamel)  
      static boolean isWhitespaceMiddle​(@NotNull java.lang.CharSequence text, int offset)  
      static boolean isWhitespaceStart​(@NotNull java.lang.CharSequence text, int offset)  
      static boolean isWordEnd​(@NotNull com.intellij.openapi.editor.Editor editor, int offset, boolean isCamel)  
      static boolean isWordEnd​(@NotNull java.lang.CharSequence text, int offset, boolean isCamel)  
      static boolean isWordStart​(@NotNull com.intellij.openapi.editor.Editor editor, int offset, boolean isCamel)  
      static boolean isWordStart​(@NotNull java.lang.CharSequence text, int offset, boolean isCamel)  
      static boolean isWordType​(int wordType, @NotNull java.lang.CharSequence charSequence, int offset)  
      static boolean isWordTypeEnd​(int wordType, @NotNull com.intellij.openapi.editor.Editor editor, int offset, boolean isCamel)  
      static boolean isWordTypeEnd​(int wordType, @NotNull java.lang.CharSequence charSequence, int offset, boolean isCamel)  
      static boolean isWordTypeStart​(int wordType, @NotNull com.intellij.openapi.editor.Editor editor, int offset, boolean isCamel)  
      static boolean isWordTypeStart​(int wordType, @NotNull java.lang.CharSequence charSequence, int offset, boolean isCamel)  
      static java.util.Map<com.intellij.openapi.editor.Caret,​com.vladsch.flexmark.util.sequence.Range> limitCaretRange​(boolean backwards, java.util.Map<com.intellij.openapi.editor.Caret,​com.vladsch.flexmark.util.sequence.Range> rangeMap, boolean wantEmptyRanges)  
      static void moveCaretToNextWordStartOrEnd​(@NotNull com.intellij.openapi.editor.Editor editor, boolean isWithSelection, boolean camel, int flags)  
      static void moveCaretToPreviousWordStartOrEnd​(@NotNull com.intellij.openapi.editor.Editor editor, boolean isWithSelection, boolean camel, int flags)  
      static void restoreState​(@Nullable com.intellij.openapi.editor.Caret newCaret, com.intellij.openapi.editor.CaretState caretState, boolean alwaysSetSelection)  
      static void scrollToCaret​(com.intellij.openapi.editor.Editor editor)  
      static void scrollToSelection​(com.intellij.openapi.editor.Editor editor)  
      static com.intellij.openapi.actionSystem.DataContext simpleDataContext​(@Nullable com.intellij.openapi.project.Project project)  
      static com.intellij.openapi.actionSystem.DataContext simpleDataContext​(@Nullable com.intellij.openapi.project.Project project, @Nullable com.intellij.openapi.vfs.VirtualFile virtualFile)  
      static com.intellij.openapi.actionSystem.DataContext simpleDataContext​(@Nullable com.intellij.openapi.project.Project project, @Nullable com.intellij.openapi.vfs.VirtualFile virtualFile, @Nullable com.intellij.openapi.editor.Editor editor)  
      static java.awt.datatransfer.Transferable splitCaretTransferable​(java.lang.String... texts)  
      static boolean startsWithQuote​(java.lang.String text)  
      • Methods inherited from class java.lang.Object

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

      • Helpers

        public Helpers()
    • Method Detail

      • getWordType

        public static int getWordType​(int flags)
      • isSet

        public static boolean isSet​(int options,
                                    int flag)
      • moveCaretToNextWordStartOrEnd

        public static void moveCaretToNextWordStartOrEnd​(@NotNull
                                                         @NotNull com.intellij.openapi.editor.Editor editor,
                                                         boolean isWithSelection,
                                                         boolean camel,
                                                         int flags)
      • moveCaretToPreviousWordStartOrEnd

        public static void moveCaretToPreviousWordStartOrEnd​(@NotNull
                                                             @NotNull com.intellij.openapi.editor.Editor editor,
                                                             boolean isWithSelection,
                                                             boolean camel,
                                                             int flags)
      • isWordTypeStart

        public static boolean isWordTypeStart​(int wordType,
                                              @NotNull
                                              @NotNull com.intellij.openapi.editor.Editor editor,
                                              int offset,
                                              boolean isCamel)
      • isWordTypeEnd

        public static boolean isWordTypeEnd​(int wordType,
                                            @NotNull
                                            @NotNull com.intellij.openapi.editor.Editor editor,
                                            int offset,
                                            boolean isCamel)
      • isWordTypeStart

        public static boolean isWordTypeStart​(int wordType,
                                              @NotNull
                                              @NotNull java.lang.CharSequence charSequence,
                                              int offset,
                                              boolean isCamel)
      • isWordTypeEnd

        public static boolean isWordTypeEnd​(int wordType,
                                            @NotNull
                                            @NotNull java.lang.CharSequence charSequence,
                                            int offset,
                                            boolean isCamel)
      • isWordType

        public static boolean isWordType​(int wordType,
                                         @NotNull
                                         @NotNull java.lang.CharSequence charSequence,
                                         int offset)
      • isWordStart

        public static boolean isWordStart​(@NotNull
                                          @NotNull com.intellij.openapi.editor.Editor editor,
                                          int offset,
                                          boolean isCamel)
      • isWordEnd

        public static boolean isWordEnd​(@NotNull
                                        @NotNull com.intellij.openapi.editor.Editor editor,
                                        int offset,
                                        boolean isCamel)
      • isIdentifierStart

        public static boolean isIdentifierStart​(@NotNull
                                                @NotNull com.intellij.openapi.editor.Editor editor,
                                                int offset,
                                                boolean isCamel)
      • isIdentifierEnd

        public static boolean isIdentifierEnd​(@NotNull
                                              @NotNull com.intellij.openapi.editor.Editor editor,
                                              int offset,
                                              boolean isCamel)
      • isWhitespaceStart

        public static boolean isWhitespaceStart​(@NotNull
                                                @NotNull java.lang.CharSequence text,
                                                int offset)
      • isWhitespaceMiddle

        public static boolean isWhitespaceMiddle​(@NotNull
                                                 @NotNull java.lang.CharSequence text,
                                                 int offset)
      • isWhitespaceEnd

        public static boolean isWhitespaceEnd​(@NotNull
                                              @NotNull java.lang.CharSequence text,
                                              int offset,
                                              boolean isCamel)
      • isIdentifierPart

        public static boolean isIdentifierPart​(char c)
      • isIdentifier

        public static boolean isIdentifier​(@NotNull
                                           @NotNull java.lang.CharSequence text,
                                           int offset)
      • isWordStart

        public static boolean isWordStart​(@NotNull
                                          @NotNull java.lang.CharSequence text,
                                          int offset,
                                          boolean isCamel)
      • isWordEnd

        public static boolean isWordEnd​(@NotNull
                                        @NotNull java.lang.CharSequence text,
                                        int offset,
                                        boolean isCamel)
      • isIdentifierStart

        public static boolean isIdentifierStart​(@NotNull
                                                @NotNull java.lang.CharSequence text,
                                                int offset,
                                                boolean isCamel)
      • isIdentifierEnd

        public static boolean isIdentifierEnd​(@NotNull
                                              @NotNull java.lang.CharSequence text,
                                              int offset,
                                              boolean isCamel)
      • isHumpBoundWord

        public static boolean isHumpBoundWord​(@NotNull
                                              @NotNull java.lang.CharSequence editorText,
                                              int offset,
                                              boolean start)
      • isHumpBoundIdentifier

        public static boolean isHumpBoundIdentifier​(@NotNull
                                                    @NotNull java.lang.CharSequence editorText,
                                                    int offset,
                                                    boolean start)
      • isSnakeCaseBound

        public static boolean isSnakeCaseBound​(@NotNull
                                               @NotNull java.lang.CharSequence editorText,
                                               int offset,
                                               boolean start)
      • isLowerCaseOrDigit

        public static boolean isLowerCaseOrDigit​(char c)
      • countWhiteSpace

        public static int countWhiteSpace​(java.lang.CharSequence chars,
                                          int start,
                                          int end)
      • countWhiteSpaceReversed

        public static int countWhiteSpaceReversed​(java.lang.CharSequence chars,
                                                  int start,
                                                  int end)
      • scrollToCaret

        public static void scrollToCaret​(com.intellij.openapi.editor.Editor editor)
      • scrollToSelection

        public static void scrollToSelection​(com.intellij.openapi.editor.Editor editor)
      • restoreState

        public static void restoreState​(@Nullable
                                        @Nullable com.intellij.openapi.editor.Caret newCaret,
                                        com.intellij.openapi.editor.CaretState caretState,
                                        boolean alwaysSetSelection)
      • getCaretRange

        @Nullable
        public static @Nullable com.vladsch.flexmark.util.sequence.Range getCaretRange​(@NotNull
                                                                                       @NotNull com.intellij.openapi.editor.Caret caret,
                                                                                       boolean backwards,
                                                                                       boolean lineMode,
                                                                                       boolean singleLine)
      • limitCaretRange

        public static java.util.Map<com.intellij.openapi.editor.Caret,​com.vladsch.flexmark.util.sequence.Range> limitCaretRange​(boolean backwards,
                                                                                                                                      java.util.Map<com.intellij.openapi.editor.Caret,​com.vladsch.flexmark.util.sequence.Range> rangeMap,
                                                                                                                                      boolean wantEmptyRanges)
      • getNextWordStartAtOffset

        public static int getNextWordStartAtOffset​(java.lang.CharSequence charSequence,
                                                   int offset,
                                                   int wordType,
                                                   boolean isCamel,
                                                   boolean stopIfNonWord)
      • getPreviousWordStartAtOffset

        public static int getPreviousWordStartAtOffset​(java.lang.CharSequence charSequence,
                                                       int offset,
                                                       int wordType,
                                                       boolean isCamel,
                                                       boolean stopIfNonWord)
      • getPreviousWordEndAtOffset

        public static int getPreviousWordEndAtOffset​(java.lang.CharSequence charSequence,
                                                     int offset,
                                                     int wordType,
                                                     boolean isCamel,
                                                     boolean stopIfNonWord)
      • getNextWordEndAtOffset

        public static int getNextWordEndAtOffset​(java.lang.CharSequence charSequence,
                                                 int offset,
                                                 int wordType,
                                                 boolean isCamel,
                                                 boolean stopIfNonWord)
      • getWordStartAtOffset

        public static int getWordStartAtOffset​(java.lang.CharSequence charSequence,
                                               int offset,
                                               int wordType,
                                               boolean isCamel,
                                               boolean stopIfNonWord)
      • getWordEndAtOffset

        public static int getWordEndAtOffset​(java.lang.CharSequence charSequence,
                                             int offset,
                                             int wordType,
                                             boolean isCamel,
                                             boolean stopIfNonWord)
      • getWordRangeAtOffsets

        public static com.intellij.openapi.util.TextRange getWordRangeAtOffsets​(java.lang.CharSequence charSequence,
                                                                                int start,
                                                                                int end,
                                                                                int wordType,
                                                                                boolean isCamel,
                                                                                boolean stopIfNonWord)
      • getWordAtOffsets

        public static java.lang.String getWordAtOffsets​(java.lang.String charSequence,
                                                        int start,
                                                        int end,
                                                        int wordType,
                                                        boolean isCamel,
                                                        boolean stopIfNonWord)
      • getWordAtOffsets

        public static java.lang.CharSequence getWordAtOffsets​(java.lang.CharSequence charSequence,
                                                              int start,
                                                              int end,
                                                              int wordType,
                                                              boolean isCamel,
                                                              boolean stopIfNonWord)
      • getWordAtOffsets

        public static com.vladsch.flexmark.util.sequence.BasedSequence getWordAtOffsets​(com.vladsch.flexmark.util.sequence.BasedSequence charSequence,
                                                                                        int start,
                                                                                        int end,
                                                                                        int wordType,
                                                                                        boolean isCamel,
                                                                                        boolean stopIfNonWord)
      • getWordAtOffset

        public static java.lang.String getWordAtOffset​(java.lang.String charSequence,
                                                       int offset,
                                                       int wordType,
                                                       boolean isCamel,
                                                       boolean stopIfNonWord)
      • getWordAtOffset

        public static java.lang.CharSequence getWordAtOffset​(java.lang.CharSequence charSequence,
                                                             int offset,
                                                             int wordType,
                                                             boolean isCamel,
                                                             boolean stopIfNonWord)
      • getWordAtOffset

        public static com.vladsch.flexmark.util.sequence.BasedSequence getWordAtOffset​(com.vladsch.flexmark.util.sequence.BasedSequence charSequence,
                                                                                       int offset,
                                                                                       int wordType,
                                                                                       boolean isCamel,
                                                                                       boolean stopIfNonWord)
      • isPasswordEditor

        public static boolean isPasswordEditor​(@Nullable
                                               @Nullable com.intellij.openapi.editor.Editor editor)
      • getStartOfLineOffset

        public static int getStartOfLineOffset​(@NotNull
                                               @NotNull java.lang.CharSequence charSequence,
                                               int offset)
      • getEndOfLineOffset

        public static int getEndOfLineOffset​(@NotNull
                                             @NotNull java.lang.CharSequence charSequence,
                                             int offset)
      • findLanguageRangeFromElement

        @NotNull
        public static @NotNull com.vladsch.plugin.util.edit.ItemTextRange<com.intellij.lang.Language> findLanguageRangeFromElement​(com.intellij.psi.PsiElement elt)
      • getLanguageRangeAtOffset

        @NotNull
        public static @NotNull com.vladsch.plugin.util.edit.ItemTextRange<com.intellij.lang.Language> getLanguageRangeAtOffset​(@NotNull
                                                                                                                               @NotNull com.intellij.psi.PsiFile file,
                                                                                                                               int offset)
      • getCommenterRange

        @Nullable
        public static @Nullable com.vladsch.plugin.util.edit.ItemTextRange<com.intellij.lang.Commenter> getCommenterRange​(@NotNull
                                                                                                                          @NotNull com.intellij.openapi.editor.Editor editor,
                                                                                                                          @Nullable
                                                                                                                          @Nullable com.intellij.psi.PsiFile file,
                                                                                                                          int startOffset,
                                                                                                                          int endOffset)
      • splitCaretTransferable

        public static java.awt.datatransfer.Transferable splitCaretTransferable​(java.lang.String... texts)
      • duplicateLineOrSelectedBlockAtCaret

        public static com.intellij.openapi.util.Couple<java.lang.Integer> duplicateLineOrSelectedBlockAtCaret​(com.intellij.openapi.editor.Editor editor,
                                                                                                              com.intellij.openapi.editor.Document document,
                                                                                                              @NotNull
                                                                                                              @NotNull com.intellij.openapi.editor.Caret caret,
                                                                                                              boolean moveCaret)
      • duplicateLinesRange

        @Nullable
        public static @Nullable com.intellij.openapi.util.Couple<java.lang.Integer> duplicateLinesRange​(com.intellij.openapi.editor.Editor editor,
                                                                                                        com.intellij.openapi.editor.Document document,
                                                                                                        @Nullable
                                                                                                        @Nullable com.intellij.openapi.editor.Caret caret,
                                                                                                        int offset,
                                                                                                        com.intellij.openapi.editor.VisualPosition rangeStart,
                                                                                                        com.intellij.openapi.editor.VisualPosition rangeEnd,
                                                                                                        boolean moveCaret)
      • getCorrespondingQuoteLike

        @NotNull
        public static @NotNull java.lang.String getCorrespondingQuoteLike​(java.lang.String openingText)
      • getCorrespondingQuoteLike

        public static char getCorrespondingQuoteLike​(char openingChar)
      • isQuote

        public static boolean isQuote​(char c)
      • startsWithQuote

        public static boolean startsWithQuote​(java.lang.String text)
      • endsWithQuote

        public static boolean endsWithQuote​(java.lang.String text)
      • getRangeText

        @Nullable
        public static @Nullable com.intellij.openapi.util.Pair<java.lang.String,​java.lang.String> getRangeText​(com.intellij.openapi.editor.Document document,
                                                                                                                     com.vladsch.flexmark.util.sequence.Range range1,
                                                                                                                     com.vladsch.flexmark.util.sequence.Range range2)
        Replace the text of range1 (non-overlapping part with range 2) with text from range2 (non-overlapping part of range 2)
        Parameters:
        document - document for the ranges
        range1 - range to replace
        range2 - range to replace with
        Returns:
        Pair first is range1 (non-overlapping) text and second is range2 non-overlapping text
      • simpleDataContext

        public static com.intellij.openapi.actionSystem.DataContext simpleDataContext​(@Nullable
                                                                                      @Nullable com.intellij.openapi.project.Project project)
      • simpleDataContext

        public static com.intellij.openapi.actionSystem.DataContext simpleDataContext​(@Nullable
                                                                                      @Nullable com.intellij.openapi.project.Project project,
                                                                                      @Nullable
                                                                                      @Nullable com.intellij.openapi.vfs.VirtualFile virtualFile)
      • simpleDataContext

        public static com.intellij.openapi.actionSystem.DataContext simpleDataContext​(@Nullable
                                                                                      @Nullable com.intellij.openapi.project.Project project,
                                                                                      @Nullable
                                                                                      @Nullable com.intellij.openapi.vfs.VirtualFile virtualFile,
                                                                                      @Nullable
                                                                                      @Nullable com.intellij.openapi.editor.Editor editor)