public class DiffUtil
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
DiffUtil.CenteredPanel |
static class |
DiffUtil.Lazy |
static class |
DiffUtil.UpdatedLineRange |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DIFF_CONFIG |
static Key<java.lang.Boolean> |
TEMP_FILE_KEY |
static int |
TITLE_GAP |
Constructor and Description |
---|
DiffUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
addActionBlock(DefaultActionGroup group,
AnAction... actions) |
static void |
addActionBlock(DefaultActionGroup group,
java.util.List<? extends AnAction> actions) |
static void |
addNotification(javax.swing.JComponent component,
UserDataHolder holder) |
static java.lang.String |
applyModification(java.lang.CharSequence text,
LineOffsets lineOffsets,
java.lang.CharSequence otherText,
LineOffsets otherLineOffsets,
java.util.List<? extends Range> ranges) |
static void |
applyModification(Document document1,
int line1,
int line2,
Document document2,
int oLine1,
int oLine2) |
static void |
applyModification(Document document,
int line1,
int line2,
java.util.List<? extends java.lang.CharSequence> newLines) |
static int |
bound(int value,
int lowerBound,
int upperBound) |
static boolean |
canMakeWritable(Document document) |
static boolean |
canNavigateToFile(Project project,
VirtualFile file) |
static void |
closeWindow(java.awt.Window window,
boolean modalOnly,
boolean recursive) |
static boolean |
compareStreams(ThrowableComputable<? extends java.io.InputStream,? extends java.io.IOException> stream1,
ThrowableComputable<? extends java.io.InputStream,? extends java.io.IOException> stream2) |
static MergeInnerDifferences |
compareThreesideInner(java.util.List<? extends java.lang.CharSequence> chunks,
ComparisonPolicy comparisonPolicy,
ProgressIndicator indicator) |
static boolean |
compareWordMergeContents(MergeWordFragment fragment,
java.util.List<? extends java.lang.CharSequence> texts,
ComparisonPolicy policy,
ThreeSide side1,
ThreeSide side2) |
static void |
configureEditor(EditorEx editor,
DocumentContent content,
Project project) |
static int |
countLinesShift(DocumentEvent e) |
static EditorEx |
createEditor(Document document,
Project project,
boolean isViewer) |
static EditorEx |
createEditor(Document document,
Project project,
boolean isViewer,
boolean enableFolding) |
static EditorHighlighter |
createEditorHighlighter(Project project,
DocumentContent content) |
static EditorHighlighter |
createEmptyEditorHighlighter() |
static javax.swing.JPanel |
createMessagePanel(javax.swing.JComponent label) |
static javax.swing.JPanel |
createMessagePanel(java.lang.String message) |
static TwosideTextDiffProvider.NoIgnore |
createNoIgnoreTextDiffProvider(Project project,
ContentDiffRequest request,
TextDiffSettings settings,
java.lang.Runnable rediff,
Disposable disposable) |
static java.lang.String |
createNotificationText(java.lang.String text,
java.lang.String appendix) |
static java.util.List<javax.swing.JComponent> |
createSimpleTitles(ContentDiffRequest request) |
static javax.swing.JComponent |
createStackedComponents(java.util.List<? extends javax.swing.JComponent> components,
int gap) |
static java.util.List<javax.swing.JComponent> |
createSyncHeightComponents(java.util.List<javax.swing.JComponent> components) |
static TwosideTextDiffProvider |
createTextDiffProvider(Project project,
ContentDiffRequest request,
TextDiffSettings settings,
java.lang.Runnable rediff,
Disposable disposable) |
static java.util.List<javax.swing.JComponent> |
createTextTitles(ContentDiffRequest request,
java.util.List<? extends Editor> editors) |
static javax.swing.JComponent |
createTitle(java.lang.String title) |
static javax.swing.JComponent |
createTitle(java.lang.String title,
DiffEditorTitleCustomizer titleCustomizer) |
static javax.swing.JComponent |
createTitle(java.lang.String title,
LineSeparator separator,
java.nio.charset.Charset charset,
java.lang.Boolean bom,
boolean readOnly,
DiffEditorTitleCustomizer titleCustomizer) |
static java.lang.String |
createTooltipText(java.lang.String text,
java.lang.String appendix) |
static <T> UserDataHolderBase |
createUserDataHolder(Key<T> key,
T value) |
static void |
disableBlitting(EditorEx editor) |
static boolean |
executeWriteCommand(Document document,
Project project,
java.lang.String commandName,
java.lang.Runnable task) |
static boolean |
executeWriteCommand(Project project,
Document document,
java.lang.String commandName,
java.lang.String commandGroupId,
UndoConfirmationPolicy confirmationPolicy,
boolean underBulkUpdate,
java.lang.Runnable task) |
static <T extends DiffTool> |
filterSuppressedTools(java.util.List<T> tools) |
static DiffTool |
findToolSubstitutor(DiffTool tool,
DiffContext context,
DiffRequest request) |
static LineRange |
getAffectedLineRange(DocumentEvent e) |
static javax.swing.Icon |
getArrowDownIcon(Side sourceSide) |
static javax.swing.Icon |
getArrowIcon(Side sourceSide) |
static LogicalPosition |
getCaretPosition(Editor editor) |
static TIntFunction |
getContentLineConvertor(DocumentContent content) |
static java.util.List<javax.swing.JComponent> |
getCustomNotifications(DiffContent content) |
static java.util.List<javax.swing.JComponent> |
getCustomNotifications(UserDataHolder context,
UserDataHolder request) |
static java.lang.Object |
getData(DataProvider provider,
DataProvider fallbackProvider,
java.lang.String dataId) |
static java.awt.Dimension |
getDefaultDiffPanelSize() |
static java.awt.Dimension |
getDefaultDiffWindowSize() |
static DiffSettings |
getDiffSettings(DiffContext context) |
static TextDiffType |
getDiffType(boolean hasDeleted,
boolean hasInserted) |
static TextDiffType |
getDiffType(DiffFragment fragment) |
static java.io.InputStream |
getFileInputStream(VirtualFile file) |
static int |
getLineCount(Document document)
Document.getLineCount() returns 0 for empty text.
|
static TextDiffType |
getLineDiffType(LineFragment fragment) |
static MergeConflictType |
getLineMergeType(MergeLineFragment fragment,
java.util.List<? extends java.lang.CharSequence> sequences,
java.util.List<? extends LineOffsets> lineOffsets,
ComparisonPolicy policy) |
static java.util.List<java.lang.String> |
getLines(java.lang.CharSequence text,
LineOffsets lineOffsets) |
static java.util.List<java.lang.String> |
getLines(java.lang.CharSequence text,
LineOffsets lineOffsets,
int startLine,
int endLine) |
static java.util.List<java.lang.String> |
getLines(Document document) |
static java.util.List<java.lang.String> |
getLines(Document document,
int startLine,
int endLine) |
static java.lang.CharSequence |
getLinesContent(java.lang.CharSequence sequence,
LineOffsets lineOffsets,
int line1,
int line2) |
static java.lang.CharSequence |
getLinesContent(java.lang.CharSequence sequence,
LineOffsets lineOffsets,
int line1,
int line2,
boolean includeNewline) |
static java.lang.CharSequence |
getLinesContent(Document document,
int line1,
int line2) |
static java.lang.CharSequence |
getLinesContent(Document document,
int line1,
int line2,
boolean includeNewLine) |
static TextRange |
getLinesRange(Document document,
int line1,
int line2)
Return affected range, without non-internal newlines
we consider '\n' not as a part of line, but a separator between lines
ex: if last line is not empty, the last symbol will not be '\n'
|
static TextRange |
getLinesRange(Document document,
int line1,
int line2,
boolean includeNewline) |
static TextRange |
getLinesRange(LineOffsets lineOffsets,
int line1,
int line2,
boolean includeNewline) |
static MergeConflictType |
getLineThreeWayDiffType(MergeLineFragment fragment,
java.util.List<? extends java.lang.CharSequence> sequences,
java.util.List<? extends LineOffsets> lineOffsets,
ComparisonPolicy policy) |
static MergeConflictType |
getMergeType(Condition<? super ThreeSide> emptiness,
<any> equality,
<any> trueEquality,
BooleanGetter conflictResolver) |
static int |
getOffset(Document document,
int line,
int column) |
static java.awt.Point |
getScrollingPosition(Editor editor) |
static java.util.BitSet |
getSelectedLines(Editor editor) |
static java.lang.String |
getSettingsConfigurablePath() |
static <T> int [] |
getSortedIndexes(java.util.List<? extends T> values,
java.util.Comparator<? super T> comparator) |
static java.lang.String |
getStatusText(int totalCount,
int excludedCount,
ThreeState isContentsEqual) |
static <T> T |
getUserData(UserDataHolder first,
UserDataHolder second,
Key<T> key) |
static WindowWrapper.Mode |
getWindowMode(DiffDialogHints hints) |
static MergeConflictType |
getWordMergeType(MergeWordFragment fragment,
java.util.List<? extends java.lang.CharSequence> texts,
ComparisonPolicy policy) |
static EditorHighlighter |
initEditorHighlighter(Project project,
DocumentContent content,
java.lang.CharSequence text) |
static EditorHighlighter |
initEmptyEditorHighlighter(java.lang.CharSequence text) |
static void |
installLineConvertor(EditorEx editor,
DocumentContent content) |
static void |
installLineConvertor(EditorEx editor,
DocumentContent content,
FoldingModelSupport foldingSupport,
int editorIndex) |
static void |
installLineConvertor(EditorEx editor,
FoldingModelSupport foldingSupport) |
static int [] |
invertIndexes(int [] indexes) |
static boolean |
isDiffEditor(Editor editor) |
static boolean |
isEditable(Editor editor) |
static boolean |
isFocusedComponent(java.awt.Component component) |
static boolean |
isFocusedComponent(Project project,
java.awt.Component component) |
static boolean |
isFocusedComponentInWindow(java.awt.Component component) |
static boolean |
isFromShortcut(AnActionEvent e) |
static boolean |
isMirrored(Editor editor) |
static boolean |
isSelectedByLine(java.util.BitSet selected,
int line1,
int line2) |
static boolean |
isSelectedByLine(int line,
int line1,
int line2) |
static boolean |
isSomeRangeSelected(Editor editor,
Condition<? super java.util.BitSet> condition) |
static boolean |
isUserDataFlagSet(Key<java.lang.Boolean> key,
UserDataHolder... holders) |
static boolean |
makeWritable(Project project,
Document document) |
static boolean |
makeWritable(Project project,
VirtualFile file) |
static void |
markDirtyAndRefresh(boolean async,
boolean recursive,
boolean reloadChildren,
VirtualFile... files)
Difference with
VfsUtil.markDirtyAndRefresh(boolean, boolean, boolean, com.intellij.openapi.vfs.VirtualFile...) is that refresh from VfsUtil will be performed with ModalityState.NON_MODAL. |
static TIntFunction |
mergeLineConverters(TIntFunction convertor1,
TIntFunction convertor2) |
static void |
moveCaret(Editor editor,
int line) |
static void |
moveCaretToLineRangeIfNeeded(Editor editor,
int startLine,
int endLine) |
static <T> void |
putDataKey(UserDataHolder holder,
DataKey<T> key,
T value) |
static void |
putNonundoableOperation(Project project,
Document document) |
static void |
registerAction(AnAction action,
javax.swing.JComponent component) |
static void |
requestFocus(Project project,
java.awt.Component component) |
static void |
requestFocusInWindow(java.awt.Component component) |
static void |
runPreservingFocus(FocusableContext context,
java.lang.Runnable task) |
static void |
scrollEditor(Editor editor,
int line,
boolean animated) |
static void |
scrollEditor(Editor editor,
int line,
int column,
boolean animated) |
static void |
scrollToCaret(Editor editor,
boolean animated) |
static void |
scrollToPoint(Editor editor,
java.awt.Point point,
boolean animated) |
static void |
setEditorCodeStyle(Project project,
EditorEx editor,
DocumentContent content) |
static void |
setEditorHighlighter(Project project,
EditorEx editor,
DocumentContent content) |
static void |
setFoldingModelSupport(EditorEx editor) |
static void |
showSuccessPopup(java.lang.String message,
RelativePoint point,
Disposable disposable,
java.lang.Runnable hyperlinkHandler) |
static <K,V> java.util.TreeMap<K,V> |
trimDefaultValues(java.util.TreeMap<K,V> map,
Convertor<? super K,V> defaultValue) |
static DiffUtil.UpdatedLineRange |
updateRangeOnModification(int start,
int end,
int changeStart,
int changeEnd,
int shift) |
static DiffUtil.UpdatedLineRange |
updateRangeOnModification(int start,
int end,
int changeStart,
int changeEnd,
int shift,
boolean greedy) |
public static final Key<java.lang.Boolean> TEMP_FILE_KEY
public static final java.lang.String DIFF_CONFIG
public static final int TITLE_GAP
public static boolean isDiffEditor(Editor editor)
public static EditorHighlighter initEditorHighlighter(Project project, DocumentContent content, java.lang.CharSequence text)
public static EditorHighlighter initEmptyEditorHighlighter(java.lang.CharSequence text)
public static EditorHighlighter createEditorHighlighter(Project project, DocumentContent content)
public static EditorHighlighter createEmptyEditorHighlighter()
public static void setEditorHighlighter(Project project, EditorEx editor, DocumentContent content)
public static void setEditorCodeStyle(Project project, EditorEx editor, DocumentContent content)
public static void setFoldingModelSupport(EditorEx editor)
public static EditorEx createEditor(Document document, Project project, boolean isViewer)
public static EditorEx createEditor(Document document, Project project, boolean isViewer, boolean enableFolding)
public static void configureEditor(EditorEx editor, DocumentContent content, Project project)
public static boolean isMirrored(Editor editor)
public static boolean canNavigateToFile(Project project, VirtualFile file)
public static void installLineConvertor(EditorEx editor, FoldingModelSupport foldingSupport)
public static void installLineConvertor(EditorEx editor, DocumentContent content)
public static void installLineConvertor(EditorEx editor, DocumentContent content, FoldingModelSupport foldingSupport, int editorIndex)
public static TIntFunction getContentLineConvertor(DocumentContent content)
public static TIntFunction mergeLineConverters(TIntFunction convertor1, TIntFunction convertor2)
public static void disableBlitting(EditorEx editor)
public static void moveCaret(Editor editor, int line)
public static void scrollEditor(Editor editor, int line, boolean animated)
public static void scrollEditor(Editor editor, int line, int column, boolean animated)
public static void scrollToPoint(Editor editor, java.awt.Point point, boolean animated)
public static void scrollToCaret(Editor editor, boolean animated)
public static java.awt.Point getScrollingPosition(Editor editor)
public static LogicalPosition getCaretPosition(Editor editor)
public static void moveCaretToLineRangeIfNeeded(Editor editor, int startLine, int endLine)
public static javax.swing.Icon getArrowIcon(Side sourceSide)
public static javax.swing.Icon getArrowDownIcon(Side sourceSide)
public static boolean isFromShortcut(AnActionEvent e)
public static void registerAction(AnAction action, javax.swing.JComponent component)
public static javax.swing.JPanel createMessagePanel(java.lang.String message)
public static javax.swing.JPanel createMessagePanel(javax.swing.JComponent label)
public static void addActionBlock(DefaultActionGroup group, AnAction... actions)
public static void addActionBlock(DefaultActionGroup group, java.util.List<? extends AnAction> actions)
public static java.lang.String getSettingsConfigurablePath()
public static java.lang.String createTooltipText(java.lang.String text, java.lang.String appendix)
public static java.lang.String createNotificationText(java.lang.String text, java.lang.String appendix)
public static void showSuccessPopup(java.lang.String message, RelativePoint point, Disposable disposable, java.lang.Runnable hyperlinkHandler)
public static java.util.List<javax.swing.JComponent> createSimpleTitles(ContentDiffRequest request)
public static java.util.List<javax.swing.JComponent> createTextTitles(ContentDiffRequest request, java.util.List<? extends Editor> editors)
public static javax.swing.JComponent createTitle(java.lang.String title)
public static javax.swing.JComponent createTitle(java.lang.String title, DiffEditorTitleCustomizer titleCustomizer)
public static javax.swing.JComponent createTitle(java.lang.String title, LineSeparator separator, java.nio.charset.Charset charset, java.lang.Boolean bom, boolean readOnly, DiffEditorTitleCustomizer titleCustomizer)
public static java.util.List<javax.swing.JComponent> createSyncHeightComponents(java.util.List<javax.swing.JComponent> components)
public static javax.swing.JComponent createStackedComponents(java.util.List<? extends javax.swing.JComponent> components, int gap)
public static java.lang.String getStatusText(int totalCount, int excludedCount, ThreeState isContentsEqual)
public static boolean isFocusedComponent(java.awt.Component component)
public static boolean isFocusedComponent(Project project, java.awt.Component component)
public static void requestFocus(Project project, java.awt.Component component)
public static boolean isFocusedComponentInWindow(java.awt.Component component)
public static void requestFocusInWindow(java.awt.Component component)
public static void runPreservingFocus(FocusableContext context, java.lang.Runnable task)
public static TwosideTextDiffProvider createTextDiffProvider(Project project, ContentDiffRequest request, TextDiffSettings settings, java.lang.Runnable rediff, Disposable disposable)
public static TwosideTextDiffProvider.NoIgnore createNoIgnoreTextDiffProvider(Project project, ContentDiffRequest request, TextDiffSettings settings, java.lang.Runnable rediff, Disposable disposable)
public static MergeInnerDifferences compareThreesideInner(java.util.List<? extends java.lang.CharSequence> chunks, ComparisonPolicy comparisonPolicy, ProgressIndicator indicator)
public static <T> int [] getSortedIndexes(java.util.List<? extends T> values, java.util.Comparator<? super T> comparator)
public static int [] invertIndexes(int [] indexes)
public static boolean compareStreams(ThrowableComputable<? extends java.io.InputStream,? extends java.io.IOException> stream1, ThrowableComputable<? extends java.io.InputStream,? extends java.io.IOException> stream2) throws java.io.IOException
java.io.IOException
public static java.io.InputStream getFileInputStream(VirtualFile file) throws java.io.IOException
java.io.IOException
public static boolean isSomeRangeSelected(Editor editor, Condition<? super java.util.BitSet> condition)
public static java.util.BitSet getSelectedLines(Editor editor)
public static boolean isSelectedByLine(int line, int line1, int line2)
public static boolean isSelectedByLine(java.util.BitSet selected, int line1, int line2)
public static void applyModification(Document document, int line1, int line2, java.util.List<? extends java.lang.CharSequence> newLines)
public static void applyModification(Document document1, int line1, int line2, Document document2, int oLine1, int oLine2)
public static java.lang.String applyModification(java.lang.CharSequence text, LineOffsets lineOffsets, java.lang.CharSequence otherText, LineOffsets otherLineOffsets, java.util.List<? extends Range> ranges)
public static java.lang.CharSequence getLinesContent(Document document, int line1, int line2)
public static java.lang.CharSequence getLinesContent(Document document, int line1, int line2, boolean includeNewLine)
public static java.lang.CharSequence getLinesContent(java.lang.CharSequence sequence, LineOffsets lineOffsets, int line1, int line2)
public static java.lang.CharSequence getLinesContent(java.lang.CharSequence sequence, LineOffsets lineOffsets, int line1, int line2, boolean includeNewline)
public static TextRange getLinesRange(Document document, int line1, int line2)
public static TextRange getLinesRange(Document document, int line1, int line2, boolean includeNewline)
public static TextRange getLinesRange(LineOffsets lineOffsets, int line1, int line2, boolean includeNewline)
public static int getOffset(Document document, int line, int column)
public static int getLineCount(Document document)
This breaks an assumption "getLineCount() == StringUtil.countNewLines(text) + 1" and adds unnecessary corner case into line ranges logic.
public static java.util.List<java.lang.String> getLines(Document document)
public static java.util.List<java.lang.String> getLines(java.lang.CharSequence text, LineOffsets lineOffsets)
public static java.util.List<java.lang.String> getLines(Document document, int startLine, int endLine)
public static java.util.List<java.lang.String> getLines(java.lang.CharSequence text, LineOffsets lineOffsets, int startLine, int endLine)
public static int bound(int value, int lowerBound, int upperBound)
public static LineRange getAffectedLineRange(DocumentEvent e)
public static int countLinesShift(DocumentEvent e)
public static DiffUtil.UpdatedLineRange updateRangeOnModification(int start, int end, int changeStart, int changeEnd, int shift)
public static DiffUtil.UpdatedLineRange updateRangeOnModification(int start, int end, int changeStart, int changeEnd, int shift, boolean greedy)
public static TextDiffType getLineDiffType(LineFragment fragment)
public static TextDiffType getDiffType(DiffFragment fragment)
public static TextDiffType getDiffType(boolean hasDeleted, boolean hasInserted)
public static MergeConflictType getMergeType(Condition<? super ThreeSide> emptiness, <any> equality, <any> trueEquality, BooleanGetter conflictResolver)
public static MergeConflictType getLineThreeWayDiffType(MergeLineFragment fragment, java.util.List<? extends java.lang.CharSequence> sequences, java.util.List<? extends LineOffsets> lineOffsets, ComparisonPolicy policy)
public static MergeConflictType getLineMergeType(MergeLineFragment fragment, java.util.List<? extends java.lang.CharSequence> sequences, java.util.List<? extends LineOffsets> lineOffsets, ComparisonPolicy policy)
public static MergeConflictType getWordMergeType(MergeWordFragment fragment, java.util.List<? extends java.lang.CharSequence> texts, ComparisonPolicy policy)
public static boolean compareWordMergeContents(MergeWordFragment fragment, java.util.List<? extends java.lang.CharSequence> texts, ComparisonPolicy policy, ThreeSide side1, ThreeSide side2)
public static boolean executeWriteCommand(Project project, Document document, java.lang.String commandName, java.lang.String commandGroupId, UndoConfirmationPolicy confirmationPolicy, boolean underBulkUpdate, java.lang.Runnable task)
public static boolean executeWriteCommand(Document document, Project project, java.lang.String commandName, java.lang.Runnable task)
public static boolean isEditable(Editor editor)
public static boolean canMakeWritable(Document document)
public static boolean makeWritable(Project project, VirtualFile file)
public static void putNonundoableOperation(Project project, Document document)
public static void markDirtyAndRefresh(boolean async, boolean recursive, boolean reloadChildren, VirtualFile... files)
VfsUtil.markDirtyAndRefresh(boolean, boolean, boolean, com.intellij.openapi.vfs.VirtualFile...)
is that refresh from VfsUtil will be performed with ModalityState.NON_MODAL.public static java.awt.Dimension getDefaultDiffPanelSize()
public static java.awt.Dimension getDefaultDiffWindowSize()
public static WindowWrapper.Mode getWindowMode(DiffDialogHints hints)
public static void closeWindow(java.awt.Window window, boolean modalOnly, boolean recursive)
public static <T> UserDataHolderBase createUserDataHolder(Key<T> key, T value)
public static boolean isUserDataFlagSet(Key<java.lang.Boolean> key, UserDataHolder... holders)
public static <T> T getUserData(UserDataHolder first, UserDataHolder second, Key<T> key)
public static void addNotification(javax.swing.JComponent component, UserDataHolder holder)
public static java.util.List<javax.swing.JComponent> getCustomNotifications(UserDataHolder context, UserDataHolder request)
public static java.util.List<javax.swing.JComponent> getCustomNotifications(DiffContent content)
public static java.lang.Object getData(DataProvider provider, DataProvider fallbackProvider, java.lang.String dataId)
public static <T> void putDataKey(UserDataHolder holder, DataKey<T> key, T value)
public static DiffSettings getDiffSettings(DiffContext context)
public static <K,V> java.util.TreeMap<K,V> trimDefaultValues(java.util.TreeMap<K,V> map, Convertor<? super K,V> defaultValue)
public static <T extends DiffTool> java.util.List<T> filterSuppressedTools(java.util.List<T> tools)
public static DiffTool findToolSubstitutor(DiffTool tool, DiffContext context, DiffRequest request)