Package com.vladsch.plugin.util.edit
Class Helpers
- java.lang.Object
-
- com.vladsch.plugin.util.edit.Helpers
-
public class Helpers extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classHelpers.ByLineTypestatic classHelpers.EachLineCarets
-
Field Summary
Fields Modifier and Type Field Description static intBOUNDARY_FLAGSstatic intEND_OF_FOLDING_REGIONstatic intEND_OF_LEADING_BLANKSstatic intEND_OF_LINEstatic intEND_OF_WORDstatic intIDE_WORDstatic intMIA_IDENTIFIERstatic intMIA_WORDstatic intMULTI_CARET_SINGLE_LINEstatic java.lang.StringQUOTE_LIKEstatic java.lang.StringQUOTESstatic intSINGLE_LINEstatic intSPACE_DELIMITEDstatic intSTART_OF_FOLDING_REGIONstatic intSTART_OF_LINEstatic intSTART_OF_TRAILING_BLANKSstatic intSTART_OF_WORDstatic intWORD_IDEstatic intWORD_IDENTIFIERstatic intWORD_MIAstatic intWORD_SPACE_DELIMITED
-
Constructor Summary
Constructors Constructor Description Helpers()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcountWhiteSpace(java.lang.CharSequence chars, int start, int end)static intcountWhiteSpaceReversed(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 booleanendsWithQuote(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.RangegetCaretRange(@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 chargetCorrespondingQuoteLike(char openingChar)static @NotNull java.lang.StringgetCorrespondingQuoteLike(java.lang.String openingText)static intgetEndOfLineOffset(@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 intgetNextWordEndAtOffset(java.lang.CharSequence charSequence, int offset, int wordType, boolean isCamel, boolean stopIfNonWord)static intgetNextWordStartAtOffset(java.lang.CharSequence charSequence, int offset, int wordType, boolean isCamel, boolean stopIfNonWord)static intgetPreviousWordEndAtOffset(java.lang.CharSequence charSequence, int offset, int wordType, boolean isCamel, boolean stopIfNonWord)static intgetPreviousWordStartAtOffset(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 intgetStartOfLineOffset(@NotNull java.lang.CharSequence charSequence, int offset)static com.vladsch.flexmark.util.sequence.BasedSequencegetWordAtOffset(com.vladsch.flexmark.util.sequence.BasedSequence charSequence, int offset, int wordType, boolean isCamel, boolean stopIfNonWord)static java.lang.CharSequencegetWordAtOffset(java.lang.CharSequence charSequence, int offset, int wordType, boolean isCamel, boolean stopIfNonWord)static java.lang.StringgetWordAtOffset(java.lang.String charSequence, int offset, int wordType, boolean isCamel, boolean stopIfNonWord)static com.vladsch.flexmark.util.sequence.BasedSequencegetWordAtOffsets(com.vladsch.flexmark.util.sequence.BasedSequence charSequence, int start, int end, int wordType, boolean isCamel, boolean stopIfNonWord)static java.lang.CharSequencegetWordAtOffsets(java.lang.CharSequence charSequence, int start, int end, int wordType, boolean isCamel, boolean stopIfNonWord)static java.lang.StringgetWordAtOffsets(java.lang.String charSequence, int start, int end, int wordType, boolean isCamel, boolean stopIfNonWord)static intgetWordEndAtOffset(java.lang.CharSequence charSequence, int offset, int wordType, boolean isCamel, boolean stopIfNonWord)static com.intellij.openapi.util.TextRangegetWordRangeAtOffsets(java.lang.CharSequence charSequence, int start, int end, int wordType, boolean isCamel, boolean stopIfNonWord)static intgetWordStartAtOffset(java.lang.CharSequence charSequence, int offset, int wordType, boolean isCamel, boolean stopIfNonWord)static intgetWordType(int flags)static booleanisHumpBoundIdentifier(@NotNull java.lang.CharSequence editorText, int offset, boolean start)static booleanisHumpBoundWord(@NotNull java.lang.CharSequence editorText, int offset, boolean start)static booleanisIdentifier(@NotNull java.lang.CharSequence text, int offset)static booleanisIdentifierEnd(@NotNull com.intellij.openapi.editor.Editor editor, int offset, boolean isCamel)static booleanisIdentifierEnd(@NotNull java.lang.CharSequence text, int offset, boolean isCamel)static booleanisIdentifierPart(char c)static booleanisIdentifierStart(@NotNull com.intellij.openapi.editor.Editor editor, int offset, boolean isCamel)static booleanisIdentifierStart(@NotNull java.lang.CharSequence text, int offset, boolean isCamel)static booleanisLowerCaseOrDigit(char c)static booleanisPasswordEditor(@Nullable com.intellij.openapi.editor.Editor editor)static booleanisQuote(char c)static booleanisSet(int options, int flag)static booleanisSnakeCaseBound(@NotNull java.lang.CharSequence editorText, int offset, boolean start)static booleanisWhitespaceEnd(@NotNull java.lang.CharSequence text, int offset, boolean isCamel)static booleanisWhitespaceMiddle(@NotNull java.lang.CharSequence text, int offset)static booleanisWhitespaceStart(@NotNull java.lang.CharSequence text, int offset)static booleanisWordEnd(@NotNull com.intellij.openapi.editor.Editor editor, int offset, boolean isCamel)static booleanisWordEnd(@NotNull java.lang.CharSequence text, int offset, boolean isCamel)static booleanisWordStart(@NotNull com.intellij.openapi.editor.Editor editor, int offset, boolean isCamel)static booleanisWordStart(@NotNull java.lang.CharSequence text, int offset, boolean isCamel)static booleanisWordType(int wordType, @NotNull java.lang.CharSequence charSequence, int offset)static booleanisWordTypeEnd(int wordType, @NotNull com.intellij.openapi.editor.Editor editor, int offset, boolean isCamel)static booleanisWordTypeEnd(int wordType, @NotNull java.lang.CharSequence charSequence, int offset, boolean isCamel)static booleanisWordTypeStart(int wordType, @NotNull com.intellij.openapi.editor.Editor editor, int offset, boolean isCamel)static booleanisWordTypeStart(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 voidmoveCaretToNextWordStartOrEnd(@NotNull com.intellij.openapi.editor.Editor editor, boolean isWithSelection, boolean camel, int flags)static voidmoveCaretToPreviousWordStartOrEnd(@NotNull com.intellij.openapi.editor.Editor editor, boolean isWithSelection, boolean camel, int flags)static voidrestoreState(@Nullable com.intellij.openapi.editor.Caret newCaret, com.intellij.openapi.editor.CaretState caretState, boolean alwaysSetSelection)static voidscrollToCaret(com.intellij.openapi.editor.Editor editor)static voidscrollToSelection(com.intellij.openapi.editor.Editor editor)static com.intellij.openapi.actionSystem.DataContextsimpleDataContext(@Nullable com.intellij.openapi.project.Project project)static com.intellij.openapi.actionSystem.DataContextsimpleDataContext(@Nullable com.intellij.openapi.project.Project project, @Nullable com.intellij.openapi.vfs.VirtualFile virtualFile)static com.intellij.openapi.actionSystem.DataContextsimpleDataContext(@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.TransferablesplitCaretTransferable(java.lang.String... texts)static booleanstartsWithQuote(java.lang.String text)
-
-
-
Field Detail
-
START_OF_WORD
public static final int START_OF_WORD
- See Also:
- Constant Field Values
-
END_OF_WORD
public static final int END_OF_WORD
- See Also:
- Constant Field Values
-
START_OF_TRAILING_BLANKS
public static final int START_OF_TRAILING_BLANKS
- See Also:
- Constant Field Values
-
END_OF_LEADING_BLANKS
public static final int END_OF_LEADING_BLANKS
- See Also:
- Constant Field Values
-
START_OF_LINE
public static final int START_OF_LINE
- See Also:
- Constant Field Values
-
END_OF_LINE
public static final int END_OF_LINE
- See Also:
- Constant Field Values
-
MIA_IDENTIFIER
public static final int MIA_IDENTIFIER
- See Also:
- Constant Field Values
-
START_OF_FOLDING_REGION
public static final int START_OF_FOLDING_REGION
- See Also:
- Constant Field Values
-
END_OF_FOLDING_REGION
public static final int END_OF_FOLDING_REGION
- See Also:
- Constant Field Values
-
SINGLE_LINE
public static final int SINGLE_LINE
- See Also:
- Constant Field Values
-
MULTI_CARET_SINGLE_LINE
public static final int MULTI_CARET_SINGLE_LINE
- See Also:
- Constant Field Values
-
IDE_WORD
public static final int IDE_WORD
- See Also:
- Constant Field Values
-
SPACE_DELIMITED
public static final int SPACE_DELIMITED
- See Also:
- Constant Field Values
-
MIA_WORD
public static final int MIA_WORD
- See Also:
- Constant Field Values
-
WORD_SPACE_DELIMITED
public static final int WORD_SPACE_DELIMITED
- See Also:
- Constant Field Values
-
WORD_IDE
public static final int WORD_IDE
- See Also:
- Constant Field Values
-
WORD_MIA
public static final int WORD_MIA
- See Also:
- Constant Field Values
-
WORD_IDENTIFIER
public static final int WORD_IDENTIFIER
- See Also:
- Constant Field Values
-
BOUNDARY_FLAGS
public static int BOUNDARY_FLAGS
-
QUOTES
public static final java.lang.String QUOTES
- See Also:
- Constant Field Values
-
QUOTE_LIKE
public static final java.lang.String QUOTE_LIKE
- See Also:
- Constant Field Values
-
-
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 rangesrange1- range to replacerange2- 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)
-
-