diff: make DiffContent implement UserDataHolder

This commit is contained in:
Aleksey Pivovarov
2015-12-23 15:05:12 +03:00
parent fb639a0e6c
commit f2af97c09f
8 changed files with 44 additions and 40 deletions
@@ -18,6 +18,7 @@ package com.intellij.diff.contents;
import com.intellij.diff.requests.DiffRequest;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.util.UserDataHolder;
import org.jetbrains.annotations.CalledInAwt;
import org.jetbrains.annotations.Nullable;
@@ -26,7 +27,7 @@ import org.jetbrains.annotations.Nullable;
*
* @see DiffRequest
*/
public interface DiffContent {
public interface DiffContent extends UserDataHolder {
@Nullable
FileType getContentType();
@@ -0,0 +1,34 @@
/*
* 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.diff.contents;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.util.UserDataHolderBase;
import org.jetbrains.annotations.CalledInAwt;
import org.jetbrains.annotations.Nullable;
public abstract class DiffContentBase extends UserDataHolderBase implements DiffContent {
@Nullable
@Override
public OpenFileDescriptor getOpenFileDescriptor() {
return null;
}
@Override
@CalledInAwt
public void onAssigned(boolean isAssigned) {
}
}
@@ -15,7 +15,6 @@
*/
package com.intellij.diff.contents;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.fileTypes.FileType;
import org.jetbrains.annotations.Nullable;
@@ -24,20 +23,10 @@ import org.jetbrains.annotations.Nullable;
* <p/>
* ex: 'Before' state for new file
*/
public class EmptyContent implements DiffContent {
public class EmptyContent extends DiffContentBase {
@Nullable
@Override
public FileType getContentType() {
return null;
}
@Nullable
@Override
public OpenFileDescriptor getOpenFileDescriptor() {
return null;
}
@Override
public void onAssigned(boolean isAssigned) {
}
}
@@ -15,6 +15,7 @@
*/
package com.intellij.diff.actions;
import com.intellij.diff.contents.DiffContentBase;
import com.intellij.diff.contents.DocumentContent;
import com.intellij.openapi.command.undo.UndoManager;
import com.intellij.openapi.editor.Document;
@@ -35,7 +36,7 @@ import java.nio.charset.Charset;
/**
* Represents sub text of other content. Original content should provide not null document.
*/
public class DocumentFragmentContent implements DocumentContent {
public class DocumentFragmentContent extends DiffContentBase implements DocumentContent {
// TODO: reuse DocumentWindow ?
@NotNull private final DocumentContent myOriginal;
@@ -22,7 +22,7 @@ import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class DirectoryContentImpl implements DiffContent, DirectoryContent {
public class DirectoryContentImpl extends DiffContentBase implements DirectoryContent {
@NotNull private final VirtualFile myFile;
@Nullable private final Project myProject;
@@ -50,8 +50,4 @@ public class DirectoryContentImpl implements DiffContent, DirectoryContent {
public FileType getContentType() {
return null;
}
@Override
public void onAssigned(boolean isAssigned) {
}
}
@@ -28,7 +28,7 @@ import java.nio.charset.Charset;
/**
* Allows to compare some text associated with document.
*/
public class DocumentContentImpl implements DiffContent, DocumentContent {
public class DocumentContentImpl extends DiffContentBase implements DocumentContent {
@NotNull private final Document myDocument;
@Nullable private final FileType myType;
@@ -94,8 +94,4 @@ public class DocumentContentImpl implements DiffContent, DocumentContent {
public Charset getCharset() {
return myCharset;
}
@Override
public void onAssigned(boolean isAssigned) {
}
}
@@ -25,7 +25,7 @@ import org.jetbrains.annotations.Nullable;
/**
* Allows to compare files
*/
public class FileContentImpl implements FileContent {
public class FileContentImpl extends DiffContentBase implements FileContent {
@NotNull private final VirtualFile myFile;
@Nullable private final Project myProject;
@NotNull private final FileType myType;
@@ -60,8 +60,4 @@ public class FileContentImpl implements FileContent {
public String getFilePath() {
return myFile.getPath();
}
@Override
public void onAssigned(boolean isAssigned) {
}
}
@@ -1,6 +1,7 @@
package org.jetbrains.idea.svn.difftool.properties;
import com.intellij.diff.contents.DiffContent;
import com.intellij.diff.contents.DiffContentBase;
import com.intellij.diff.contents.EmptyContent;
import com.intellij.diff.requests.ContentDiffRequest;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
@@ -65,7 +66,7 @@ public class SvnPropertiesDiffRequest extends ContentDiffRequest {
return myContents;
}
public static class PropertyContent implements DiffContent {
public static class PropertyContent extends DiffContentBase {
@NotNull private final List<PropertyData> myProperties;
public PropertyContent(@NotNull List<PropertyData> properties) {
@@ -82,15 +83,5 @@ public class SvnPropertiesDiffRequest extends ContentDiffRequest {
public FileType getContentType() {
return null;
}
@Nullable
@Override
public OpenFileDescriptor getOpenFileDescriptor() {
return null;
}
@Override
public void onAssigned(boolean isAssigned) {
}
}
}