mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
diff: cleanup: convert DiffContent/DiffRequest factories to services
This commit is contained in:
+2
-2
@@ -20,7 +20,7 @@ import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.diff.DiffDialogHints;
|
||||
import com.intellij.openapi.util.diff.DiffManager;
|
||||
import com.intellij.openapi.util.diff.impl.DiffRequestFactory;
|
||||
import com.intellij.openapi.util.diff.DiffRequestFactory;
|
||||
import com.intellij.openapi.util.diff.requests.DiffRequest;
|
||||
|
||||
/**
|
||||
@@ -28,7 +28,7 @@ import com.intellij.openapi.util.diff.requests.DiffRequest;
|
||||
*/
|
||||
public class CompareValueWithClipboardAction extends BaseValueAction {
|
||||
protected void processText(final Project project, final String text, DebuggerTreeNodeImpl node, DebuggerContextImpl debuggerContext) {
|
||||
DiffRequest request = DiffRequestFactory.createClipboardVsValue(text);
|
||||
DiffRequest request = DiffRequestFactory.getInstance().createClipboardVsValue(text);
|
||||
DiffManager.getInstance().showDiff(project, request, DiffDialogHints.DEFAULT);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.util.diff;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.diff.contents.DiffContent;
|
||||
import com.intellij.openapi.util.diff.contents.DocumentContent;
|
||||
import com.intellij.openapi.util.diff.contents.EmptyContent;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.LineSeparator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/*
|
||||
* Use ProgressManager.executeProcessUnderProgress() to pass modality state if needed
|
||||
*/
|
||||
public abstract class DiffContentFactory {
|
||||
@NotNull
|
||||
public static DiffContentFactory getInstance() {
|
||||
return ServiceManager.getService(DiffContentFactory.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract EmptyContent createEmpty();
|
||||
|
||||
@NotNull
|
||||
public abstract DocumentContent create(@NotNull String text, @Nullable FileType type);
|
||||
|
||||
@NotNull
|
||||
public abstract DocumentContent create(@Nullable Project project, @NotNull Document document);
|
||||
|
||||
@NotNull
|
||||
public abstract DocumentContent create(@Nullable Project project, @NotNull Document document, @Nullable VirtualFile file);
|
||||
|
||||
@NotNull
|
||||
public abstract DiffContent create(@Nullable Project project, @NotNull VirtualFile file);
|
||||
|
||||
@Nullable
|
||||
public abstract DocumentContent createDocument(@Nullable Project project, @NotNull VirtualFile file);
|
||||
|
||||
@NotNull
|
||||
public abstract DiffContent createClipboardContent();
|
||||
|
||||
@NotNull
|
||||
public abstract DocumentContent createClipboardContent(@NotNull DocumentContent mainContent);
|
||||
|
||||
@NotNull
|
||||
public abstract DiffContent createBinary(@Nullable Project project,
|
||||
@NotNull String name,
|
||||
@NotNull FileType type,
|
||||
@NotNull byte[] content) throws IOException;
|
||||
|
||||
@NotNull
|
||||
public abstract Pair<Document, LineSeparator> buildDocument(@NotNull String text);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.util.diff;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.diff.requests.ContentDiffRequest;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/*
|
||||
* Use ProgressManager.executeProcessUnderProgress() to pass modality state if needed
|
||||
*/
|
||||
public abstract class DiffRequestFactory {
|
||||
@NotNull
|
||||
public static DiffRequestFactory getInstance() {
|
||||
return ServiceManager.getService(DiffRequestFactory.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract ContentDiffRequest createFromFile(@Nullable Project project, @NotNull VirtualFile file1, @NotNull VirtualFile file2);
|
||||
|
||||
@NotNull
|
||||
public abstract String getVirtualFileContentTitle(@NotNull VirtualFile file);
|
||||
|
||||
@NotNull
|
||||
public abstract ContentDiffRequest createClipboardVsValue(@NotNull String value);
|
||||
}
|
||||
+30
-19
@@ -26,6 +26,7 @@ import com.intellij.openapi.ide.CopyPasteManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.diff.DiffContentFactory;
|
||||
import com.intellij.openapi.util.diff.contents.*;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -40,43 +41,49 @@ import java.awt.datatransfer.DataFlavor;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class DiffContentFactory {
|
||||
public static final Logger LOG = Logger.getInstance(DiffContentFactory.class);
|
||||
public class DiffContentFactoryImpl extends DiffContentFactory {
|
||||
public final Logger LOG = Logger.getInstance(DiffContentFactoryImpl.class);
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public static EmptyContent createEmpty() {
|
||||
public EmptyContent createEmpty() {
|
||||
return new EmptyContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public static DocumentContent create(@NotNull String text, @Nullable FileType type) {
|
||||
public DocumentContent create(@NotNull String text, @Nullable FileType type) {
|
||||
Pair<Document, LineSeparator> pair = buildDocument(text);
|
||||
pair.first.setReadOnly(true);
|
||||
return new DocumentContentImpl(pair.first, type, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public static DocumentContent create(@Nullable Project project, @NotNull Document document) {
|
||||
public DocumentContent create(@Nullable Project project, @NotNull Document document) {
|
||||
VirtualFile file = FileDocumentManager.getInstance().getFile(document);
|
||||
return create(project, document, file);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public static DocumentContent create(@Nullable Project project, @NotNull Document document, @Nullable VirtualFile file) {
|
||||
public DocumentContent create(@Nullable Project project, @NotNull Document document, @Nullable VirtualFile file) {
|
||||
if (file != null) return new FileDocumentContentImpl(project, document, file);
|
||||
return new DocumentContentImpl(document);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public static DiffContent create(@Nullable Project project, @NotNull VirtualFile file) {
|
||||
public DiffContent create(@Nullable Project project, @NotNull VirtualFile file) {
|
||||
if (file.isDirectory()) return new DirectoryContentImpl(project, file);
|
||||
DocumentContent content = createDocument(project, file);
|
||||
if (content != null) return content;
|
||||
return new BinaryFileContentImpl(project, file);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public static DocumentContent createDocument(@Nullable Project project, @NotNull final VirtualFile file) {
|
||||
public DocumentContent createDocument(@Nullable Project project, @NotNull final VirtualFile file) {
|
||||
// TODO: add notification, that file is decompiled ?
|
||||
if (file.isDirectory()) return null;
|
||||
Document document = ApplicationManager.getApplication().runReadAction(new Computable<Document>() {
|
||||
@@ -89,23 +96,26 @@ public class DiffContentFactory {
|
||||
return new FileDocumentContentImpl(project, document, file);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public static DiffContent createClipboardContent() {
|
||||
public DiffContent createClipboardContent() {
|
||||
String text = CopyPasteManager.getInstance().getContents(DataFlavor.stringFlavor);
|
||||
return new DocumentContentImpl(new DocumentImpl(StringUtil.notNullize(text)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public static DocumentContent createClipboardContent(@NotNull DocumentContent mainContent) {
|
||||
public DocumentContent createClipboardContent(@NotNull DocumentContent mainContent) {
|
||||
String text = CopyPasteManager.getInstance().getContents(DataFlavor.stringFlavor);
|
||||
return new DocumentContentWrapper(mainContent, StringUtil.notNullize(text));
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public static DiffContent createBinary(@Nullable Project project,
|
||||
@NotNull String name,
|
||||
@NotNull FileType type,
|
||||
@NotNull byte[] content) throws IOException {
|
||||
public DiffContent createBinary(@Nullable Project project,
|
||||
@NotNull String name,
|
||||
@NotNull FileType type,
|
||||
@NotNull byte[] content) throws IOException {
|
||||
boolean useTemporalFile = true; // TODO: workaround for Decompiler
|
||||
//boolean useTemporalFile = type instanceof ArchiveFileType; // workaround - our JarFileSystem can't process non-local files
|
||||
|
||||
@@ -126,10 +136,10 @@ public class DiffContentFactory {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static VirtualFile createTemporalFile(@Nullable Project project,
|
||||
@NotNull String prefix,
|
||||
@NotNull String suffix,
|
||||
@NotNull byte[] content) throws IOException {
|
||||
public VirtualFile createTemporalFile(@Nullable Project project,
|
||||
@NotNull String prefix,
|
||||
@NotNull String suffix,
|
||||
@NotNull byte[] content) throws IOException {
|
||||
File tempFile = FileUtil.createTempFile(prefix + "_", "_" + suffix, true);
|
||||
if (content.length != 0) {
|
||||
FileUtil.writeToFile(tempFile, content);
|
||||
@@ -141,8 +151,9 @@ public class DiffContentFactory {
|
||||
return file;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public static Pair<Document, LineSeparator> buildDocument(@NotNull String text) {
|
||||
public Pair<Document, LineSeparator> buildDocument(@NotNull String text) {
|
||||
Pair<String, LineSeparator> pair = convertLineSeparators(text);
|
||||
Document document = EditorFactory.getInstance().createDocument(pair.getFirst());
|
||||
return Pair.create(document, pair.getSecond());
|
||||
+15
-8
@@ -17,6 +17,8 @@ package com.intellij.openapi.util.diff.impl;
|
||||
|
||||
import com.intellij.openapi.diff.DiffBundle;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.diff.DiffContentFactory;
|
||||
import com.intellij.openapi.util.diff.DiffRequestFactory;
|
||||
import com.intellij.openapi.util.diff.contents.DiffContent;
|
||||
import com.intellij.openapi.util.diff.requests.ContentDiffRequest;
|
||||
import com.intellij.openapi.util.diff.requests.SimpleDiffRequest;
|
||||
@@ -25,11 +27,14 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class DiffRequestFactory {
|
||||
public class DiffRequestFactoryImpl extends DiffRequestFactory {
|
||||
private DiffContentFactory myContentFactory = DiffContentFactory.getInstance();
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public static ContentDiffRequest createFromFile(@Nullable Project project, @NotNull VirtualFile file1, @NotNull VirtualFile file2) {
|
||||
DiffContent content1 = DiffContentFactory.create(project, file1);
|
||||
DiffContent content2 = DiffContentFactory.create(project, file2);
|
||||
public ContentDiffRequest createFromFile(@Nullable Project project, @NotNull VirtualFile file1, @NotNull VirtualFile file2) {
|
||||
DiffContent content1 = myContentFactory.create(project, file1);
|
||||
DiffContent content2 = myContentFactory.create(project, file2);
|
||||
|
||||
String title1 = getVirtualFileContentTitle(file1);
|
||||
String title2 = getVirtualFileContentTitle(file2);
|
||||
@@ -40,8 +45,9 @@ public class DiffRequestFactory {
|
||||
return new SimpleDiffRequest(title, content1, content2, title1, title2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public static String getVirtualFileContentTitle(@NotNull VirtualFile file) {
|
||||
public String getVirtualFileContentTitle(@NotNull VirtualFile file) {
|
||||
String name = file.getName();
|
||||
VirtualFile parent = file.getParent();
|
||||
if (parent != null) {
|
||||
@@ -50,10 +56,11 @@ public class DiffRequestFactory {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public static ContentDiffRequest createClipboardVsValue(@NotNull String value) {
|
||||
DiffContent content1 = DiffContentFactory.createClipboardContent();
|
||||
DiffContent content2 = DiffContentFactory.create(value, null);
|
||||
public ContentDiffRequest createClipboardVsValue(@NotNull String value) {
|
||||
DiffContent content1 = myContentFactory.createClipboardContent();
|
||||
DiffContent content2 = myContentFactory.create(value, null);
|
||||
|
||||
String title1 = DiffBundle.message("diff.content.clipboard.content.title");
|
||||
String title2 = DiffBundle.message("diff.content.selected.value");
|
||||
+5
-5
@@ -25,8 +25,8 @@ import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.diff.contents.DocumentContent;
|
||||
import com.intellij.openapi.util.diff.impl.DiffContentFactory;
|
||||
import com.intellij.openapi.util.diff.impl.DiffRequestFactory;
|
||||
import com.intellij.openapi.util.diff.DiffContentFactory;
|
||||
import com.intellij.openapi.util.diff.DiffRequestFactory;
|
||||
import com.intellij.openapi.util.diff.requests.DiffRequest;
|
||||
import com.intellij.openapi.util.diff.requests.SimpleDiffRequest;
|
||||
import com.intellij.openapi.util.diff.util.DiffUserDataKeys;
|
||||
@@ -63,7 +63,7 @@ public class CompareClipboardWithSelectionAction extends BaseShowDiffAction {
|
||||
assert editor != null;
|
||||
|
||||
DocumentContent content2 = createContent(project, editor);
|
||||
DocumentContent content1 = DiffContentFactory.createClipboardContent(content2);
|
||||
DocumentContent content1 = DiffContentFactory.getInstance().createClipboardContent(content2);
|
||||
|
||||
String title1 = DiffBundle.message("diff.content.clipboard.content.title");
|
||||
String title2 = createContentTitle(editor);
|
||||
@@ -79,7 +79,7 @@ public class CompareClipboardWithSelectionAction extends BaseShowDiffAction {
|
||||
|
||||
@NotNull
|
||||
private static DocumentContent createContent(@NotNull Project project, @NotNull Editor editor) {
|
||||
DocumentContent content = DiffContentFactory.create(project, editor.getDocument());
|
||||
DocumentContent content = DiffContentFactory.getInstance().create(project, editor.getDocument());
|
||||
|
||||
SelectionModel selectionModel = editor.getSelectionModel();
|
||||
if (selectionModel.hasSelection()) {
|
||||
@@ -93,7 +93,7 @@ public class CompareClipboardWithSelectionAction extends BaseShowDiffAction {
|
||||
@NotNull
|
||||
private static String createContentTitle(@NotNull Editor editor) {
|
||||
VirtualFile file = FileDocumentManager.getInstance().getFile(editor.getDocument());
|
||||
String title = file != null ? DiffRequestFactory.getVirtualFileContentTitle(file) : "Editor";
|
||||
String title = file != null ? DiffRequestFactory.getInstance().getVirtualFileContentTitle(file) : "Editor";
|
||||
|
||||
if (editor.getSelectionModel().hasSelection()) {
|
||||
title = DiffBundle.message("diff.content.selection.from.file.content.title", title);
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.diff.contents.DiffContent;
|
||||
import com.intellij.openapi.util.diff.contents.DocumentContent;
|
||||
import com.intellij.openapi.util.diff.impl.DiffRequestFactory;
|
||||
import com.intellij.openapi.util.diff.DiffRequestFactory;
|
||||
import com.intellij.openapi.util.diff.requests.ContentDiffRequest;
|
||||
import com.intellij.openapi.util.diff.requests.DiffRequest;
|
||||
import com.intellij.openapi.util.diff.util.DiffUserDataKeys;
|
||||
@@ -88,7 +88,7 @@ public class CompareFileWithEditorAction extends BaseShowDiffAction {
|
||||
|
||||
assert selectedFile != null && currentFile != null;
|
||||
|
||||
ContentDiffRequest request = DiffRequestFactory.createFromFile(project, selectedFile, currentFile);
|
||||
ContentDiffRequest request = DiffRequestFactory.getInstance().createFromFile(project, selectedFile, currentFile);
|
||||
|
||||
DiffContent editorContent = request.getContents()[1];
|
||||
if (editorContent instanceof DocumentContent) {
|
||||
|
||||
+3
-3
@@ -22,7 +22,7 @@ import com.intellij.openapi.actionSystem.DataKey;
|
||||
import com.intellij.openapi.fileChooser.FileChooser;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.diff.impl.DiffRequestFactory;
|
||||
import com.intellij.openapi.util.diff.DiffRequestFactory;
|
||||
import com.intellij.openapi.util.diff.requests.DiffRequest;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -69,10 +69,10 @@ public class CompareFilesAction extends BaseShowDiffAction {
|
||||
VirtualFile[] result = FileChooser.chooseFiles(descriptor, project, data[0]);
|
||||
|
||||
if (result.length != 1 || result[0] == null) return null;
|
||||
return DiffRequestFactory.createFromFile(project, data[0], result[0]);
|
||||
return DiffRequestFactory.getInstance().createFromFile(project, data[0], result[0]);
|
||||
}
|
||||
else {
|
||||
return DiffRequestFactory.createFromFile(project, data[0], data[1]);
|
||||
return DiffRequestFactory.getInstance().createFromFile(project, data[0], data[1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.diff.DiffBundle;
|
||||
import com.intellij.openapi.util.diff.DiffDialogHints;
|
||||
import com.intellij.openapi.util.diff.DiffManagerEx;
|
||||
import com.intellij.openapi.util.diff.impl.DiffRequestFactory;
|
||||
import com.intellij.openapi.util.diff.DiffRequestFactory;
|
||||
import com.intellij.openapi.util.diff.requests.DiffRequest;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -57,7 +57,7 @@ public class DiffApplication extends ApplicationStarterBase {
|
||||
|
||||
file1.refresh(false, true);
|
||||
file2.refresh(false, true);
|
||||
DiffRequest request = DiffRequestFactory.createFromFile(null, file1, file2);
|
||||
DiffRequest request = DiffRequestFactory.getInstance().createFromFile(null, file1, file2);
|
||||
|
||||
DiffManagerEx.getInstance().showDiffBuiltin(null, request, DiffDialogHints.MODAL);
|
||||
}
|
||||
|
||||
+3
-3
@@ -46,10 +46,10 @@ import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.diff.DiffContentFactory;
|
||||
import com.intellij.openapi.util.diff.DiffManager;
|
||||
import com.intellij.openapi.util.diff.DiffRequestPanel;
|
||||
import com.intellij.openapi.util.diff.contents.DocumentContent;
|
||||
import com.intellij.openapi.util.diff.impl.DiffContentFactory;
|
||||
import com.intellij.openapi.util.diff.requests.DiffRequest;
|
||||
import com.intellij.openapi.util.diff.requests.SimpleDiffRequest;
|
||||
import com.intellij.openapi.util.diff.util.DiffUserDataKeys;
|
||||
@@ -673,8 +673,8 @@ public class FileDocumentManagerImpl extends FileDocumentManager implements Virt
|
||||
|
||||
FileType fileType = file.getFileType();
|
||||
String fsContent = LoadTextUtil.loadText(file).toString();
|
||||
DocumentContent content1 = DiffContentFactory.create(fsContent, fileType);
|
||||
DocumentContent content2 = DiffContentFactory.create(project, document, file);
|
||||
DocumentContent content1 = DiffContentFactory.getInstance().create(fsContent, fileType);
|
||||
DocumentContent content2 = DiffContentFactory.getInstance().create(project, document, file);
|
||||
String title = UIBundle.message("file.cache.conflict.for.file.dialog.title", file.getPresentableUrl());
|
||||
String title1 = UIBundle.message("file.cache.conflict.diff.content.file.system.content");
|
||||
String title2 = UIBundle.message("file.cache.conflict.diff.content.memory.content");
|
||||
|
||||
@@ -83,6 +83,10 @@
|
||||
serviceImplementation="com.intellij.openapi.diff.impl.external.DiffManagerImpl"/>
|
||||
<applicationService serviceInterface="com.intellij.openapi.util.diff.DiffManager"
|
||||
serviceImplementation="com.intellij.openapi.util.diff.DiffManagerImpl"/>
|
||||
<applicationService serviceInterface="com.intellij.openapi.util.diff.DiffContentFactory"
|
||||
serviceImplementation="com.intellij.openapi.util.diff.impl.DiffContentFactoryImpl"/>
|
||||
<applicationService serviceInterface="com.intellij.openapi.util.diff.DiffRequestFactory"
|
||||
serviceImplementation="com.intellij.openapi.util.diff.impl.DiffRequestFactoryImpl"/>
|
||||
<applicationService serviceInterface="com.intellij.openapi.util.diff.tools.util.base.TextDiffSettingsHolder"
|
||||
serviceImplementation="com.intellij.openapi.util.diff.tools.util.base.TextDiffSettingsHolder"/>
|
||||
<applicationService serviceInterface="com.intellij.openapi.util.diff.tools.external.ExternalDiffSettings"
|
||||
|
||||
+4
-4
@@ -7,7 +7,7 @@ import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.UserDataHolder;
|
||||
import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.openapi.util.diff.contents.DiffContent;
|
||||
import com.intellij.openapi.util.diff.impl.DiffContentFactory;
|
||||
import com.intellij.openapi.util.diff.DiffContentFactory;
|
||||
import com.intellij.openapi.util.diff.impl.DiffRequestProcessor;
|
||||
import com.intellij.openapi.util.diff.requests.DiffRequest;
|
||||
import com.intellij.openapi.util.diff.requests.ErrorDiffRequest;
|
||||
@@ -53,17 +53,17 @@ public class TestDiffRequestProcessor extends DiffRequestProcessor {
|
||||
String title1;
|
||||
String title2 = ExecutionBundle.message("diff.content.actual.title");
|
||||
DiffContent content1;
|
||||
DiffContent content2 = DiffContentFactory.create(hyperlink.getRight(), null);
|
||||
DiffContent content2 = DiffContentFactory.getInstance().create(hyperlink.getRight(), null);
|
||||
|
||||
String filePath = hyperlink.getFilePath();
|
||||
final VirtualFile vFile;
|
||||
if (filePath != null && (vFile = LocalFileSystem.getInstance().findFileByPath(filePath)) != null) {
|
||||
title1 = ExecutionBundle.message("diff.content.expected.title") + " (" + vFile.getPresentableUrl() + ")";
|
||||
content1 = DiffContentFactory.create(getProject(), vFile);
|
||||
content1 = DiffContentFactory.getInstance().create(getProject(), vFile);
|
||||
}
|
||||
else {
|
||||
title1 = ExecutionBundle.message("diff.content.expected.title");
|
||||
content1 = DiffContentFactory.create(hyperlink.getLeft(), null);
|
||||
content1 = DiffContentFactory.getInstance().create(hyperlink.getLeft(), null);
|
||||
}
|
||||
|
||||
return new SimpleDiffRequest(title, content1, content2, title1, title2);
|
||||
|
||||
@@ -28,7 +28,7 @@ import com.intellij.openapi.util.diff.DiffDialogHints;
|
||||
import com.intellij.openapi.util.diff.DiffManager;
|
||||
import com.intellij.openapi.util.diff.contents.DiffContent;
|
||||
import com.intellij.openapi.util.diff.contents.DocumentContent;
|
||||
import com.intellij.openapi.util.diff.impl.DiffContentFactory;
|
||||
import com.intellij.openapi.util.diff.DiffContentFactory;
|
||||
import com.intellij.openapi.util.diff.requests.DiffRequest;
|
||||
import com.intellij.openapi.util.diff.requests.SimpleDiffRequest;
|
||||
import com.intellij.openapi.util.diff.util.DiffUserDataKeys;
|
||||
@@ -74,7 +74,7 @@ public abstract class DiffActionExecutor {
|
||||
final byte[] content = ((BinaryContentRevision)fileRevision).getBinaryContent();
|
||||
if (content == null) return null;
|
||||
|
||||
return DiffContentFactory.createBinary(myProject, filePath.getName(), filePath.getFileType(), content);
|
||||
return DiffContentFactory.getInstance().createBinary(myProject, filePath.getName(), filePath.getFileType(), content);
|
||||
}
|
||||
|
||||
if (fileRevision != null) {
|
||||
@@ -104,7 +104,7 @@ public abstract class DiffActionExecutor {
|
||||
}
|
||||
DiffContent content1 = createRemote(revisionNumber);
|
||||
if (content1 == null) return;
|
||||
DiffContent content2 = DiffContentFactory.create(myProject, mySelectedFile);
|
||||
DiffContent content2 = DiffContentFactory.getInstance().create(myProject, mySelectedFile);
|
||||
|
||||
String title = mySelectedFile.getPresentableUrl();
|
||||
|
||||
@@ -234,7 +234,7 @@ public abstract class DiffActionExecutor {
|
||||
if (myFileStillExists) {
|
||||
return super.createRemote(revisionNumber);
|
||||
} else {
|
||||
return DiffContentFactory.createEmpty();
|
||||
return DiffContentFactory.getInstance().createEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -33,7 +33,7 @@ import com.intellij.openapi.util.UserDataHolder;
|
||||
import com.intellij.openapi.util.diff.chains.DiffRequestPresentable;
|
||||
import com.intellij.openapi.util.diff.chains.DiffRequestPresentableException;
|
||||
import com.intellij.openapi.util.diff.contents.DiffContent;
|
||||
import com.intellij.openapi.util.diff.impl.DiffContentFactory;
|
||||
import com.intellij.openapi.util.diff.DiffContentFactory;
|
||||
import com.intellij.openapi.util.diff.impl.DiffViewerWrapper;
|
||||
import com.intellij.openapi.util.diff.requests.DiffRequest;
|
||||
import com.intellij.openapi.util.diff.requests.ErrorDiffRequest;
|
||||
@@ -401,12 +401,12 @@ public class ChangeDiffRequestPresentable implements DiffRequestPresentable {
|
||||
try {
|
||||
indicator.checkCanceled();
|
||||
|
||||
if (revision == null) return DiffContentFactory.createEmpty();
|
||||
if (revision == null) return DiffContentFactory.getInstance().createEmpty();
|
||||
|
||||
if (revision instanceof CurrentContentRevision) {
|
||||
VirtualFile vFile = ((CurrentContentRevision)revision).getVirtualFile();
|
||||
if (vFile == null) throw new DiffRequestPresentableException("Can't get current revision content");
|
||||
return DiffContentFactory.create(project, vFile);
|
||||
return DiffContentFactory.getInstance().create(project, vFile);
|
||||
}
|
||||
|
||||
FilePath filePath = revision.getFile();
|
||||
@@ -419,7 +419,7 @@ public class ChangeDiffRequestPresentable implements DiffRequestPresentable {
|
||||
if (content == null) {
|
||||
throw new DiffRequestPresentableException("Can't get binary revision content");
|
||||
}
|
||||
return DiffContentFactory.createBinary(project, filePath.getName(), filePath.getFileType(), content);
|
||||
return DiffContentFactory.getInstance().createBinary(project, filePath.getName(), filePath.getFileType(), content);
|
||||
}
|
||||
|
||||
String revisionContent = revision.getContent();
|
||||
@@ -438,7 +438,7 @@ public class ChangeDiffRequestPresentable implements DiffRequestPresentable {
|
||||
|
||||
@NotNull
|
||||
public static DiffContent createTextContent(@NotNull byte[] bytes, @NotNull VirtualFile file) {
|
||||
return DiffContentFactory.create(CharsetToolkit.bytesToString(bytes, file.getCharset()), file.getFileType());
|
||||
return DiffContentFactory.getInstance().create(CharsetToolkit.bytesToString(bytes, file.getCharset()), file.getFileType());
|
||||
}
|
||||
|
||||
public static void checkContentRevision(@NotNull Project project,
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.diff.contents.DiffContent;
|
||||
import com.intellij.openapi.util.diff.contents.DocumentContentImpl;
|
||||
import com.intellij.openapi.util.diff.impl.DiffContentFactory;
|
||||
import com.intellij.openapi.util.diff.DiffContentFactory;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -64,7 +64,7 @@ public class FileAwareDocumentContent extends DocumentContentImpl {
|
||||
@Nullable FileType fileType,
|
||||
@Nullable VirtualFile file,
|
||||
@Nullable Charset charset) {
|
||||
Pair<Document, LineSeparator> pair = DiffContentFactory.buildDocument(content);
|
||||
Pair<Document, LineSeparator> pair = DiffContentFactory.getInstance().buildDocument(content);
|
||||
pair.first.setReadOnly(true);
|
||||
if (FileTypes.UNKNOWN.equals(fileType)) fileType = PlainTextFileType.INSTANCE;
|
||||
return new FileAwareDocumentContent(project, pair.first, fileType, file, pair.second, charset);
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ import com.intellij.openapi.util.diff.DiffManager;
|
||||
import com.intellij.openapi.util.diff.actions.DocumentFragmentContent;
|
||||
import com.intellij.openapi.util.diff.contents.DiffContent;
|
||||
import com.intellij.openapi.util.diff.contents.DocumentContent;
|
||||
import com.intellij.openapi.util.diff.impl.DiffContentFactory;
|
||||
import com.intellij.openapi.util.diff.DiffContentFactory;
|
||||
import com.intellij.openapi.util.diff.requests.DiffRequest;
|
||||
import com.intellij.openapi.util.diff.requests.SimpleDiffRequest;
|
||||
import com.intellij.openapi.vcs.VcsBundle;
|
||||
@@ -69,7 +69,7 @@ public class ShowLineStatusRangeDiffAction extends BaseLineStatusRangeAction {
|
||||
@NotNull
|
||||
private DiffContent createDiffContent(@NotNull Document document, @NotNull TextRange textRange, @Nullable VirtualFile file) {
|
||||
final Project project = myLineStatusTracker.getProject();
|
||||
DocumentContent content = DiffContentFactory.create(project, document, file);
|
||||
DocumentContent content = DiffContentFactory.getInstance().create(project, document, file);
|
||||
return new DocumentFragmentContent(project, content, textRange);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.diff.DiffDialogHints;
|
||||
import com.intellij.openapi.util.diff.DiffManager;
|
||||
import com.intellij.openapi.util.diff.contents.DiffContent;
|
||||
import com.intellij.openapi.util.diff.impl.DiffContentFactory;
|
||||
import com.intellij.openapi.util.diff.DiffContentFactory;
|
||||
import com.intellij.openapi.util.diff.requests.DiffRequest;
|
||||
import com.intellij.openapi.util.diff.requests.SimpleDiffRequest;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
@@ -81,8 +81,8 @@ public class VcsHistoryUtil {
|
||||
* @param filePath file which revisions are compared.
|
||||
* @param revision1 first revision - 'before', to the left.
|
||||
* @param revision2 second revision - 'after', to the right.
|
||||
* @throws com.intellij.openapi.vcs.VcsException
|
||||
* @throws java.io.IOException
|
||||
* @throws VcsException
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void showDiff(@NotNull final Project project, @NotNull FilePath filePath,
|
||||
@NotNull VcsFileRevision revision1, @NotNull VcsFileRevision revision2,
|
||||
@@ -134,13 +134,13 @@ public class VcsHistoryUtil {
|
||||
@NotNull FilePath filePath) throws IOException {
|
||||
if (isCurrent(revision)) {
|
||||
VirtualFile file = filePath.getVirtualFile();
|
||||
if (file != null) return DiffContentFactory.create(project, file);
|
||||
if (file != null) return DiffContentFactory.getInstance().create(project, file);
|
||||
}
|
||||
if (isEmpty(revision)) {
|
||||
return DiffContentFactory.createEmpty();
|
||||
return DiffContentFactory.getInstance().createEmpty();
|
||||
}
|
||||
if (filePath.getFileType().isBinary()) {
|
||||
return DiffContentFactory.createBinary(project, filePath.getName(), filePath.getFileType(), content);
|
||||
return DiffContentFactory.getInstance().createBinary(project, filePath.getName(), filePath.getFileType(), content);
|
||||
}
|
||||
String text = CharsetToolkit.bytesToString(content, filePath.getCharset());
|
||||
return FileAwareDocumentContent.create(project, text, filePath);
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ package com.intellij.xdebugger.impl.ui.tree.actions;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.diff.DiffDialogHints;
|
||||
import com.intellij.openapi.util.diff.DiffManager;
|
||||
import com.intellij.openapi.util.diff.impl.DiffRequestFactory;
|
||||
import com.intellij.openapi.util.diff.DiffRequestFactory;
|
||||
import com.intellij.openapi.util.diff.requests.DiffRequest;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree;
|
||||
@@ -33,7 +33,7 @@ public class XCompareWithClipboardAction extends XFetchValueActionBase {
|
||||
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
DiffRequest request = DiffRequestFactory.createClipboardVsValue(value);
|
||||
DiffRequest request = DiffRequestFactory.getInstance().createClipboardVsValue(value);
|
||||
DiffManager.getInstance().showDiff(project, request, DiffDialogHints.DEFAULT);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.diff.actions.DocumentFragmentContent;
|
||||
import com.intellij.openapi.util.diff.contents.DiffContent;
|
||||
import com.intellij.openapi.util.diff.contents.DocumentContent;
|
||||
import com.intellij.openapi.util.diff.impl.DiffContentFactory;
|
||||
import com.intellij.openapi.util.diff.DiffContentFactory;
|
||||
import com.intellij.openapi.util.diff.requests.DiffRequest;
|
||||
import com.intellij.openapi.util.diff.requests.SimpleDiffRequest;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
@@ -43,18 +43,18 @@ public class PsiDiffContentFactory {
|
||||
@Nullable
|
||||
private static DiffContent fromPsiElement(@NotNull PsiElement psiElement) {
|
||||
if (psiElement instanceof PsiFile) {
|
||||
return DiffContentFactory.create(psiElement.getProject(), ((PsiFile)psiElement).getVirtualFile());
|
||||
return DiffContentFactory.getInstance().create(psiElement.getProject(), ((PsiFile)psiElement).getVirtualFile());
|
||||
}
|
||||
else if (psiElement instanceof PsiDirectory) {
|
||||
return DiffContentFactory.create(psiElement.getProject(), ((PsiDirectory)psiElement).getVirtualFile());
|
||||
return DiffContentFactory.getInstance().create(psiElement.getProject(), ((PsiDirectory)psiElement).getVirtualFile());
|
||||
}
|
||||
PsiFile containingFile = psiElement.getContainingFile();
|
||||
if (containingFile == null) {
|
||||
String text = psiElement.getText();
|
||||
if (text == null) return null;
|
||||
return DiffContentFactory.create(text, psiElement.getLanguage().getAssociatedFileType());
|
||||
return DiffContentFactory.getInstance().create(text, psiElement.getLanguage().getAssociatedFileType());
|
||||
}
|
||||
DocumentContent wholeFileContent = DiffContentFactory.createDocument(psiElement.getProject(), containingFile.getVirtualFile());
|
||||
DocumentContent wholeFileContent = DiffContentFactory.getInstance().createDocument(psiElement.getProject(), containingFile.getVirtualFile());
|
||||
if (wholeFileContent == null) return null;
|
||||
return new DocumentFragmentContent(psiElement.getProject(), wholeFileContent, psiElement.getTextRange());
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.diff.DiffDialogHints;
|
||||
import com.intellij.openapi.util.diff.DiffManager;
|
||||
import com.intellij.openapi.util.diff.contents.DiffContent;
|
||||
import com.intellij.openapi.util.diff.impl.DiffContentFactory;
|
||||
import com.intellij.openapi.util.diff.DiffContentFactory;
|
||||
import com.intellij.openapi.util.diff.requests.DiffRequest;
|
||||
import com.intellij.openapi.util.diff.requests.SimpleDiffRequest;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
@@ -77,7 +77,7 @@ public class FileWithBranchComparer extends ElementWithBranchComparer {
|
||||
|
||||
String contentText = CharsetToolkit.bytesToString(content.get(), myVirtualFile.getCharset());
|
||||
DiffContent content1 = FileAwareDocumentContent.create(myProject, contentText, myVirtualFile);
|
||||
DiffContent content2 = DiffContentFactory.create(myProject, myVirtualFile);
|
||||
DiffContent content2 = DiffContentFactory.getInstance().create(myProject, myVirtualFile);
|
||||
|
||||
DiffRequest request = new SimpleDiffRequest(title, content1, content2, title1, title2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user