mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-64837 diff: convert line separators
This commit is contained in:
@@ -40,6 +40,9 @@ public abstract class DiffContentFactory {
|
||||
@NotNull
|
||||
public abstract EmptyContent createEmpty();
|
||||
|
||||
@NotNull
|
||||
public abstract DocumentContent create(@NotNull String text);
|
||||
|
||||
@NotNull
|
||||
public abstract DocumentContent create(@NotNull String text, @Nullable FileType type);
|
||||
|
||||
@@ -58,8 +61,11 @@ public abstract class DiffContentFactory {
|
||||
@NotNull
|
||||
public abstract DiffContent createClipboardContent();
|
||||
|
||||
/**
|
||||
* @param referenceContent used to detect FileType and proper highlighting for clipboard content
|
||||
*/
|
||||
@NotNull
|
||||
public abstract DocumentContent createClipboardContent(@NotNull DocumentContent mainContent);
|
||||
public abstract DocumentContent createClipboardContent(@NotNull DocumentContent referenceContent);
|
||||
|
||||
@NotNull
|
||||
public abstract DiffContent createBinary(@Nullable Project project,
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.EditorFactory;
|
||||
import com.intellij.openapi.editor.impl.DocumentImpl;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.ide.CopyPasteManager;
|
||||
@@ -47,6 +46,12 @@ public class DiffContentFactoryImpl extends DiffContentFactory {
|
||||
return new EmptyContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public DocumentContent create(@NotNull String text) {
|
||||
return create(text, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public DocumentContent create(@NotNull String text, @Nullable FileType type) {
|
||||
@@ -97,14 +102,16 @@ public class DiffContentFactoryImpl extends DiffContentFactory {
|
||||
@NotNull
|
||||
public DiffContent createClipboardContent() {
|
||||
String text = CopyPasteManager.getInstance().getContents(DataFlavor.stringFlavor);
|
||||
return new DocumentContentImpl(new DocumentImpl(StringUtil.notNullize(text)));
|
||||
Document document = EditorFactory.getInstance().createDocument(StringUtil.convertLineSeparators(StringUtil.notNullize(text)));
|
||||
return new DocumentContentImpl(document); // TODO: show difference in line separators ?
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public DocumentContent createClipboardContent(@NotNull DocumentContent mainContent) {
|
||||
String text = CopyPasteManager.getInstance().getContents(DataFlavor.stringFlavor);
|
||||
return new DocumentContentWrapper(mainContent, StringUtil.notNullize(text));
|
||||
Document document = EditorFactory.getInstance().createDocument(StringUtil.convertLineSeparators(StringUtil.notNullize(text)));
|
||||
return new DocumentContentWrapper(document, mainContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -47,7 +47,7 @@ public class DiffRequestFactoryImpl extends DiffRequestFactory {
|
||||
@NotNull
|
||||
public ContentDiffRequest createClipboardVsValue(@NotNull String value) {
|
||||
DiffContent content1 = myContentFactory.createClipboardContent();
|
||||
DiffContent content2 = myContentFactory.create(value, null);
|
||||
DiffContent content2 = myContentFactory.create(value);
|
||||
|
||||
String title1 = DiffBundle.message("diff.content.clipboard.content.title");
|
||||
String title2 = DiffBundle.message("diff.content.selected.value");
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package com.intellij.diff.contents;
|
||||
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.EditorFactory;
|
||||
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -30,9 +29,9 @@ public class DocumentContentWrapper implements DocumentContent {
|
||||
@NotNull private final DocumentContent myBase;
|
||||
@NotNull private final Document myDocument;
|
||||
|
||||
public DocumentContentWrapper(@NotNull DocumentContent base, @NotNull String text) {
|
||||
public DocumentContentWrapper(@NotNull Document document, @NotNull DocumentContent base) {
|
||||
myDocument = document;
|
||||
myBase = base;
|
||||
myDocument = EditorFactory.getInstance().createDocument(text);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user