mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
notnull
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.vcs.FileStatusManager;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -43,11 +44,11 @@ public class NavigationItemFileStatus {
|
||||
return FileStatus.NOT_CHANGED;
|
||||
}
|
||||
|
||||
private static FileStatus getPsiElementFileStatus(PsiElement psiElement) {
|
||||
private static FileStatus getPsiElementFileStatus(@NotNull PsiElement psiElement) {
|
||||
if (!psiElement.isPhysical()) return FileStatus.NOT_CHANGED;
|
||||
PsiFile contFile = psiElement.getContainingFile();
|
||||
if (contFile == null) return FileStatus.NOT_CHANGED;
|
||||
VirtualFile vFile = contFile.getVirtualFile();
|
||||
return vFile != null ? FileStatusManager.getInstance(psiElement.getProject()).getStatus(vFile) : FileStatus.NOT_CHANGED;
|
||||
return vFile == null ? FileStatus.NOT_CHANGED : FileStatusManager.getInstance(psiElement.getProject()).getStatus(vFile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -18,6 +18,7 @@ package com.intellij.openapi.vcs;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
@@ -29,7 +30,7 @@ public abstract class FileStatusManager {
|
||||
return project.getComponent(FileStatusManager.class);
|
||||
}
|
||||
|
||||
public abstract FileStatus getStatus(VirtualFile virtualFile);
|
||||
public abstract FileStatus getStatus(@NotNull VirtualFile virtualFile);
|
||||
|
||||
public abstract void fileStatusesChanged();
|
||||
public abstract void fileStatusChanged(VirtualFile file);
|
||||
|
||||
@@ -45,15 +45,13 @@ public abstract class ColoredTreeCellRenderer extends SimpleColoredComponent imp
|
||||
|
||||
private boolean myOpaque = true;
|
||||
@Override
|
||||
public final Component getTreeCellRendererComponent(
|
||||
JTree tree,
|
||||
Object value,
|
||||
boolean selected,
|
||||
boolean expanded,
|
||||
boolean leaf,
|
||||
int row,
|
||||
boolean hasFocus
|
||||
){
|
||||
public final Component getTreeCellRendererComponent(JTree tree,
|
||||
Object value,
|
||||
boolean selected,
|
||||
boolean expanded,
|
||||
boolean leaf,
|
||||
int row,
|
||||
boolean hasFocus){
|
||||
myTree = tree;
|
||||
|
||||
clear();
|
||||
@@ -72,20 +70,18 @@ public abstract class ColoredTreeCellRenderer extends SimpleColoredComponent imp
|
||||
setBackground(hasFocus ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeUnfocusedSelectionBackground());
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (selected) {
|
||||
setPaintFocusBorder(true);
|
||||
if (isFocused()) {
|
||||
setBackground(UIUtil.getTreeSelectionBackground());
|
||||
}
|
||||
else {
|
||||
setBackground(null);
|
||||
}
|
||||
else if (selected) {
|
||||
setPaintFocusBorder(true);
|
||||
if (isFocused()) {
|
||||
setBackground(UIUtil.getTreeSelectionBackground());
|
||||
}
|
||||
else {
|
||||
setBackground(null);
|
||||
}
|
||||
}
|
||||
else {
|
||||
setBackground(null);
|
||||
}
|
||||
|
||||
if (value instanceof LoadingNode) {
|
||||
setForeground(JBColor.GRAY);
|
||||
@@ -176,13 +172,11 @@ public abstract class ColoredTreeCellRenderer extends SimpleColoredComponent imp
|
||||
* This method is invoked only for customization of component.
|
||||
* All component attributes are cleared when this method is being invoked.
|
||||
*/
|
||||
public abstract void customizeCellRenderer(
|
||||
JTree tree,
|
||||
Object value,
|
||||
boolean selected,
|
||||
boolean expanded,
|
||||
boolean leaf,
|
||||
int row,
|
||||
boolean hasFocus
|
||||
);
|
||||
public abstract void customizeCellRenderer(@NotNull JTree tree,
|
||||
Object value,
|
||||
boolean selected,
|
||||
boolean expanded,
|
||||
boolean leaf,
|
||||
int row,
|
||||
boolean hasFocus);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
|
||||
@@ -24,11 +25,12 @@ public class LoadingNode extends DefaultMutableTreeNode {
|
||||
this(getText());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getText() {
|
||||
return IdeBundle.message("treenode.loading");
|
||||
}
|
||||
|
||||
public LoadingNode(String text) {
|
||||
public LoadingNode(@NotNull String text) {
|
||||
super(text);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.ui;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -41,16 +42,16 @@ public interface PaintingParent {
|
||||
* @return a rectangle, if null -- the whole component will be repainted
|
||||
*/
|
||||
@Nullable
|
||||
Rectangle getChildRec(Component c);
|
||||
Rectangle getChildRec(@NotNull Component c);
|
||||
|
||||
class Wrapper extends JPanel implements PaintingParent {
|
||||
public Wrapper(Component component) {
|
||||
public Wrapper(@NotNull Component component) {
|
||||
super(new BorderLayout(0,0));
|
||||
add(component);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle getChildRec(Component c) {
|
||||
public Rectangle getChildRec(@NotNull Component c) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+26
-9
@@ -99,6 +99,7 @@ public class FileStatusManagerImpl extends FileStatusManager implements ProjectC
|
||||
@Override
|
||||
public void run() {
|
||||
DocumentAdapter documentListener = new DocumentAdapter() {
|
||||
@Override
|
||||
public void documentChanged(DocumentEvent event) {
|
||||
VirtualFile file = FileDocumentManager.getInstance().getFile(event.getDocument());
|
||||
if (file != null) {
|
||||
@@ -114,6 +115,7 @@ public class FileStatusManagerImpl extends FileStatusManager implements ProjectC
|
||||
}
|
||||
});
|
||||
startupManager.registerPostStartupActivity(new DumbAwareRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fileStatusesChanged();
|
||||
}
|
||||
@@ -139,47 +141,58 @@ public class FileStatusManagerImpl extends FileStatusManager implements ProjectC
|
||||
return getDefaultStatus(virtualFile);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static FileStatus getDefaultStatus(@NotNull final VirtualFile file) {
|
||||
return file.isValid() && file.is(VFileProperty.SPECIAL) ? FileStatus.IGNORED : FileStatus.NOT_CHANGED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectClosed() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectOpened() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
myCachedStatuses.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return "FileStatusManager";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFileStatusListener(@NotNull FileStatusListener listener) {
|
||||
myListeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFileStatusListener(final FileStatusListener listener, Disposable parentDisposable) {
|
||||
addFileStatusListener(listener);
|
||||
Disposer.register(parentDisposable, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
removeFileStatusListener(listener);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileStatusesChanged() {
|
||||
if (myProject.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
if (!ApplicationManager.getApplication().isDispatchThread()) {
|
||||
ApplicationManager.getApplication().invokeLater(new DumbAwareRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fileStatusesChanged();
|
||||
}
|
||||
@@ -195,26 +208,28 @@ public class FileStatusManagerImpl extends FileStatusManager implements ProjectC
|
||||
}
|
||||
}
|
||||
|
||||
private void cacheChangedFileStatus(final VirtualFile vf, final FileStatus fs) {
|
||||
myCachedStatuses.put(vf, fs);
|
||||
private void cacheChangedFileStatus(final VirtualFile virtualFile, final FileStatus fs) {
|
||||
myCachedStatuses.put(virtualFile, fs);
|
||||
if (FileStatus.NOT_CHANGED.equals(fs)) {
|
||||
final ThreeState parentingStatus = myFileStatusProvider.getNotChangedDirectoryParentingStatus(vf);
|
||||
final ThreeState parentingStatus = myFileStatusProvider.getNotChangedDirectoryParentingStatus(virtualFile);
|
||||
if (ThreeState.YES.equals(parentingStatus)) {
|
||||
myWhetherExactlyParentToChanged.put(vf, true);
|
||||
myWhetherExactlyParentToChanged.put(virtualFile, true);
|
||||
}
|
||||
else if (ThreeState.UNSURE.equals(parentingStatus)) {
|
||||
myWhetherExactlyParentToChanged.put(vf, false);
|
||||
myWhetherExactlyParentToChanged.put(virtualFile, false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
myWhetherExactlyParentToChanged.remove(vf);
|
||||
myWhetherExactlyParentToChanged.remove(virtualFile);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileStatusChanged(final VirtualFile file) {
|
||||
final Application application = ApplicationManager.getApplication();
|
||||
if (!application.isDispatchThread() && !application.isUnitTestMode()) {
|
||||
ApplicationManager.getApplication().invokeLater(new DumbAwareRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fileStatusChanged(file);
|
||||
}
|
||||
@@ -222,7 +237,7 @@ public class FileStatusManagerImpl extends FileStatusManager implements ProjectC
|
||||
return;
|
||||
}
|
||||
|
||||
if ((file == null) || (!file.isValid())) return;
|
||||
if (file == null || !file.isValid()) return;
|
||||
FileStatus cachedStatus = getCachedStatus(file);
|
||||
if (cachedStatus == FileStatusNull.INSTANCE) {
|
||||
return;
|
||||
@@ -240,7 +255,8 @@ public class FileStatusManagerImpl extends FileStatusManager implements ProjectC
|
||||
}
|
||||
}
|
||||
|
||||
public FileStatus getStatus(final VirtualFile file) {
|
||||
@Override
|
||||
public FileStatus getStatus(@NotNull final VirtualFile file) {
|
||||
if (file instanceof LightVirtualFile) {
|
||||
return FileStatus.NOT_CHANGED; // do not leak light files via cache
|
||||
}
|
||||
@@ -258,6 +274,7 @@ public class FileStatusManagerImpl extends FileStatusManager implements ProjectC
|
||||
return myCachedStatuses.get(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFileStatusListener(FileStatusListener listener) {
|
||||
myListeners.remove(listener);
|
||||
}
|
||||
@@ -271,7 +288,7 @@ public class FileStatusManagerImpl extends FileStatusManager implements ProjectC
|
||||
final Boolean exactMatch = myWhetherExactlyParentToChanged.get(vf);
|
||||
return exactMatch == null
|
||||
? notChangedColor
|
||||
: (exactMatch ? FileStatus.NOT_CHANGED_IMMEDIATE.getColor() : FileStatus.NOT_CHANGED_RECURSIVE.getColor());
|
||||
: exactMatch ? FileStatus.NOT_CHANGED_IMMEDIATE.getColor() : FileStatus.NOT_CHANGED_RECURSIVE.getColor();
|
||||
}
|
||||
|
||||
public void refreshFileStatusFromDocument(final VirtualFile file, final Document doc) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.vcs.FileStatus;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.ThreeState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -28,8 +29,9 @@ public interface FileStatusProvider {
|
||||
|
||||
ExtensionPointName<FileStatusProvider> EP_NAME = ExtensionPointName.create("com.intellij.vcs.fileStatusProvider");
|
||||
|
||||
FileStatus getFileStatus(final VirtualFile virtualFile);
|
||||
void refreshFileStatusFromDocument(final VirtualFile file, final Document doc);
|
||||
FileStatus getFileStatus(@NotNull VirtualFile virtualFile);
|
||||
void refreshFileStatusFromDocument(@NotNull VirtualFile virtualFile, @NotNull Document doc);
|
||||
|
||||
ThreeState getNotChangedDirectoryParentingStatus(VirtualFile vf);
|
||||
@NotNull
|
||||
ThreeState getNotChangedDirectoryParentingStatus(@NotNull VirtualFile virtualFile);
|
||||
}
|
||||
+17
-1
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.testFramework.vcs;
|
||||
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
@@ -204,8 +219,9 @@ public class MockChangeListManager extends ChangeListManagerEx {
|
||||
return changes;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ThreeState haveChangesUnder(VirtualFile vf) {
|
||||
public ThreeState haveChangesUnder(@NotNull VirtualFile vf) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -71,6 +71,7 @@ public interface UsageView extends Disposable {
|
||||
*/
|
||||
void addPerformOperationAction(@NotNull Runnable processRunnable, String commandName, String cannotMakeString, @NotNull String shortDescription, boolean checkReadOnlyStatus);
|
||||
|
||||
@NotNull
|
||||
UsageViewPresentation getPresentation();
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -105,6 +105,7 @@ public class FileUtil extends FileUtilRt {
|
||||
return !ThreeState.NO.equals(isAncestorThreeState(ancestor, file, strict));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ThreeState isAncestorThreeState(@NotNull String ancestor, @NotNull String file, boolean strict) {
|
||||
String ancestorPath = toCanonicalPath(ancestor);
|
||||
String filePath = toCanonicalPath(file);
|
||||
@@ -127,6 +128,7 @@ public class FileUtil extends FileUtilRt {
|
||||
/**
|
||||
* @return ThreeState.YES if same path or immediate parent
|
||||
*/
|
||||
@NotNull
|
||||
private static ThreeState startsWith(@NotNull String path, @NotNull String start, boolean strict, boolean caseSensitive,
|
||||
boolean checkImmediateParent) {
|
||||
final int length1 = path.length();
|
||||
@@ -138,12 +140,11 @@ public class FileUtil extends FileUtilRt {
|
||||
return strict ? ThreeState.NO : ThreeState.YES;
|
||||
}
|
||||
char last2 = start.charAt(length2 - 1);
|
||||
char next1;
|
||||
int slashOrSeparatorIdx = length2;
|
||||
if (last2 == '/' || last2 == File.separatorChar) {
|
||||
slashOrSeparatorIdx = length2 - 1;
|
||||
}
|
||||
next1 = path.charAt(slashOrSeparatorIdx);
|
||||
char next1 = path.charAt(slashOrSeparatorIdx);
|
||||
if (next1 == '/' || next1 == File.separatorChar) {
|
||||
if (!checkImmediateParent) return ThreeState.YES;
|
||||
|
||||
|
||||
@@ -19,11 +19,13 @@
|
||||
*/
|
||||
package com.intellij.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AdapterProcessor<T, S> implements Processor<T> {
|
||||
private final Processor<S> myAdaptee;
|
||||
private final Function<T, S> myConversion;
|
||||
|
||||
public AdapterProcessor(Processor<S> adaptee, Function<T, S> conversion) {
|
||||
public AdapterProcessor(@NotNull Processor<S> adaptee, @NotNull Function<T, S> conversion) {
|
||||
myAdaptee = adaptee;
|
||||
myConversion = conversion;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -157,5 +157,6 @@ public abstract class ChangeListManager implements ChangeListModification {
|
||||
|
||||
public abstract List<VirtualFile> getModifiedWithoutEditing();
|
||||
|
||||
public abstract ThreeState haveChangesUnder(VirtualFile vf);
|
||||
@NotNull
|
||||
public abstract ThreeState haveChangesUnder(@NotNull VirtualFile vf);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -1088,9 +1088,10 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
return getChangesIn(new FilePathImpl(dir));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ThreeState haveChangesUnder(final VirtualFile vf) {
|
||||
if (vf == null || ! vf.isValid() || ! vf.isDirectory()) return ThreeState.NO;
|
||||
public ThreeState haveChangesUnder(@NotNull final VirtualFile vf) {
|
||||
if (!vf.isValid() || !vf.isDirectory()) return ThreeState.NO;
|
||||
synchronized (myDataLock) {
|
||||
return myWorker.haveChangesUnder(vf);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -693,8 +693,9 @@ public class ChangeListWorker implements ChangeListsWriteOperations {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ThreeState haveChangesUnder(final VirtualFile vf) {
|
||||
final String absolutePath = new File(vf.getPath()).getAbsolutePath();
|
||||
@NotNull
|
||||
public ThreeState haveChangesUnder(@NotNull VirtualFile virtualFile) {
|
||||
final String absolutePath = new File(virtualFile.getPath()).getAbsolutePath();
|
||||
final SortedSet<String> tailSet = myIdx.getAffectedPaths().tailSet(absolutePath);
|
||||
for (String path : tailSet) {
|
||||
return FileUtil.isAncestorThreeState(absolutePath, path, false);
|
||||
|
||||
+8
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -24,6 +24,7 @@ import com.intellij.openapi.vcs.changes.ChangeListManagerImpl;
|
||||
import com.intellij.openapi.vcs.impl.FileStatusProvider;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.ThreeState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -48,8 +49,9 @@ public class ChangelistConflictFileStatusProvider implements FileStatusProvider
|
||||
myConflictTracker = changeListManager.getConflictTracker();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public FileStatus getFileStatus(VirtualFile virtualFile) {
|
||||
public FileStatus getFileStatus(@NotNull VirtualFile virtualFile) {
|
||||
ChangelistConflictTracker.Options options = myConflictTracker.getOptions();
|
||||
if (!options.TRACKING_ENABLED) {
|
||||
return null;
|
||||
@@ -69,12 +71,14 @@ public class ChangelistConflictFileStatusProvider implements FileStatusProvider
|
||||
return null;
|
||||
}
|
||||
|
||||
public void refreshFileStatusFromDocument(VirtualFile file, Document doc) {
|
||||
@Override
|
||||
public void refreshFileStatusFromDocument(@NotNull VirtualFile virtualFile, @NotNull Document doc) {
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ThreeState getNotChangedDirectoryParentingStatus(VirtualFile vf) {
|
||||
public ThreeState getNotChangedDirectoryParentingStatus(@NotNull VirtualFile virtualFile) {
|
||||
throw new UnsupportedOperationException("Shouldn't be called");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -29,6 +29,7 @@ import com.intellij.openapi.vcs.readOnlyHandler.ReadonlyStatusHandlerImpl;
|
||||
import com.intellij.openapi.vcs.rollback.RollbackEnvironment;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.ThreeState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -60,18 +61,22 @@ public class VcsFileStatusProvider implements FileStatusProvider, VcsBaseContent
|
||||
myFileStatusManager.setFileStatusProvider(this);
|
||||
|
||||
changeListManager.addChangeListListener(new ChangeListAdapter() {
|
||||
@Override
|
||||
public void changeListAdded(ChangeList list) {
|
||||
fileStatusesChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeListRemoved(ChangeList list) {
|
||||
fileStatusesChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeListChanged(ChangeList list) {
|
||||
fileStatusesChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeListUpdateDone() {
|
||||
if (myHaveEmptyContentRevisions) {
|
||||
myHaveEmptyContentRevisions = false;
|
||||
@@ -89,7 +94,9 @@ public class VcsFileStatusProvider implements FileStatusProvider, VcsBaseContent
|
||||
myFileStatusManager.fileStatusesChanged();
|
||||
}
|
||||
|
||||
public FileStatus getFileStatus(final VirtualFile virtualFile) {
|
||||
@Override
|
||||
@NotNull
|
||||
public FileStatus getFileStatus(@NotNull final VirtualFile virtualFile) {
|
||||
final AbstractVcs vcs = myVcsManager.getVcsFor(virtualFile);
|
||||
if (vcs == null) {
|
||||
return FileStatusManagerImpl.getDefaultStatus(virtualFile);
|
||||
@@ -110,33 +117,35 @@ public class VcsFileStatusProvider implements FileStatusProvider, VcsBaseContent
|
||||
return FileDocumentManager.getInstance().isFileModified(virtualFile);
|
||||
}
|
||||
|
||||
public void refreshFileStatusFromDocument(final VirtualFile file, final Document doc) {
|
||||
@Override
|
||||
public void refreshFileStatusFromDocument(@NotNull final VirtualFile virtualFile, @NotNull final Document doc) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("refreshFileStatusFromDocument: file.getModificationStamp()=" + file.getModificationStamp() + ", document.getModificationStamp()=" + doc.getModificationStamp());
|
||||
LOG.debug("refreshFileStatusFromDocument: file.getModificationStamp()=" + virtualFile.getModificationStamp() + ", document.getModificationStamp()=" + doc.getModificationStamp());
|
||||
}
|
||||
FileStatus cachedStatus = myFileStatusManager.getCachedStatus(file);
|
||||
if (cachedStatus == null || cachedStatus == FileStatus.NOT_CHANGED || !isDocumentModified(file)) {
|
||||
final AbstractVcs vcs = myVcsManager.getVcsFor(file);
|
||||
FileStatus cachedStatus = myFileStatusManager.getCachedStatus(virtualFile);
|
||||
if (cachedStatus == null || cachedStatus == FileStatus.NOT_CHANGED || !isDocumentModified(virtualFile)) {
|
||||
final AbstractVcs vcs = myVcsManager.getVcsFor(virtualFile);
|
||||
if (vcs == null) return;
|
||||
if (cachedStatus == FileStatus.MODIFIED && !isDocumentModified(file)) {
|
||||
if (cachedStatus == FileStatus.MODIFIED && !isDocumentModified(virtualFile)) {
|
||||
if (!((ReadonlyStatusHandlerImpl) ReadonlyStatusHandlerImpl.getInstance(myProject)).getState().SHOW_DIALOG) {
|
||||
RollbackEnvironment rollbackEnvironment = vcs.getRollbackEnvironment();
|
||||
if (rollbackEnvironment != null) {
|
||||
rollbackEnvironment.rollbackIfUnchanged(file);
|
||||
rollbackEnvironment.rollbackIfUnchanged(virtualFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
myFileStatusManager.fileStatusChanged(file);
|
||||
myFileStatusManager.fileStatusChanged(virtualFile);
|
||||
ChangeProvider cp = vcs.getChangeProvider();
|
||||
if (cp != null && cp.isModifiedDocumentTrackingRequired()) {
|
||||
myDirtyScopeManager.fileDirty(file);
|
||||
myDirtyScopeManager.fileDirty(virtualFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ThreeState getNotChangedDirectoryParentingStatus(VirtualFile vf) {
|
||||
return myConfiguration.SHOW_DIRTY_RECURSIVELY ? myChangeListManager.haveChangesUnder(vf) : ThreeState.NO;
|
||||
public ThreeState getNotChangedDirectoryParentingStatus(@NotNull VirtualFile virtualFile) {
|
||||
return myConfiguration.SHOW_DIRTY_RECURSIVELY ? myChangeListManager.haveChangesUnder(virtualFile) : ThreeState.NO;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -164,6 +173,7 @@ public class VcsFileStatusProvider implements FileStatusProvider, VcsBaseContent
|
||||
|
||||
if (isDocumentModified(file)) {
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<String>() {
|
||||
@Override
|
||||
public String compute() {
|
||||
return LoadTextUtil.loadText(file).toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user