use of com.intellij.openapi.vcs.FileStatus in project intellij-community by JetBrains.
the class FileStatusManagerImpl method getStatus.
@Override
public FileStatus getStatus(@NotNull final VirtualFile file) {
if (file.getFileSystem() instanceof NonPhysicalFileSystem) {
// do not leak light files via cache
return FileStatus.SUPPRESSED;
}
FileStatus status = getCachedStatus(file);
if (status == null || status == FileStatusNull.INSTANCE) {
status = calcStatus(file);
cacheChangedFileStatus(file, status);
}
return status;
}
use of com.intellij.openapi.vcs.FileStatus in project intellij-community by JetBrains.
the class FileStatusManagerImpl method fileStatusChanged.
@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);
}
});
return;
}
if (file == null || !file.isValid())
return;
FileStatus cachedStatus = getCachedStatus(file);
if (cachedStatus == FileStatusNull.INSTANCE) {
return;
}
if (cachedStatus == null) {
cacheChangedFileStatus(file, FileStatusNull.INSTANCE);
return;
}
FileStatus newStatus = calcStatus(file);
if (cachedStatus == newStatus)
return;
cacheChangedFileStatus(file, newStatus);
for (FileStatusListener listener : myListeners) {
listener.fileStatusChanged(file);
}
}
use of com.intellij.openapi.vcs.FileStatus in project intellij-community by JetBrains.
the class LineStatusTrackerManager method shouldBeInstalled.
private boolean shouldBeInstalled(@Nullable final VirtualFile virtualFile) {
if (isDisabled())
return false;
if (virtualFile == null || virtualFile instanceof LightVirtualFile)
return false;
final FileStatusManager statusManager = FileStatusManager.getInstance(myProject);
if (statusManager == null)
return false;
if (!myStatusProvider.isSupported(virtualFile)) {
log("shouldBeInstalled failed: no support found", virtualFile);
return false;
}
final FileStatus status = statusManager.getStatus(virtualFile);
if (status == FileStatus.NOT_CHANGED || status == FileStatus.ADDED || status == FileStatus.UNKNOWN || status == FileStatus.IGNORED) {
log("shouldBeInstalled skipped: status=" + status, virtualFile);
return false;
}
return true;
}
use of com.intellij.openapi.vcs.FileStatus in project intellij-community by JetBrains.
the class FileOrDirectoryTreeNode method getAttributes.
@NotNull
@Override
public SimpleTextAttributes getAttributes() {
if (!getFilePointer().isValid()) {
return myInvalidAttributes;
}
VirtualFile file = getFilePointer().getFile();
FileStatusManager fileStatusManager = FileStatusManager.getInstance(myProject);
FileStatus status = fileStatusManager.getStatus(file);
SimpleTextAttributes attributes = getAttributesFor(status);
return myFilterAttributes == null ? attributes : SimpleTextAttributes.merge(myFilterAttributes, attributes);
}
use of com.intellij.openapi.vcs.FileStatus in project intellij-community by JetBrains.
the class GitChangesParser method parseChange.
private static Change parseChange(final Project project, final VirtualFile vcsRoot, final List<GitRevisionNumber> parentRevisions, final GitLogStatusInfo statusInfo, final VcsRevisionNumber thisRevision) throws VcsException {
final ContentRevision before;
final ContentRevision after;
FileStatus status = null;
final String path = statusInfo.getFirstPath();
@Nullable GitRevisionNumber firstParent = parentRevisions.isEmpty() ? null : parentRevisions.get(0);
switch(statusInfo.getType()) {
case ADDED:
before = null;
status = FileStatus.ADDED;
after = GitContentRevision.createRevision(vcsRoot, path, thisRevision, project, false, false, true);
break;
case UNRESOLVED:
status = FileStatus.MERGED_WITH_CONFLICTS;
case MODIFIED:
if (status == null) {
status = FileStatus.MODIFIED;
}
final FilePath filePath = GitContentRevision.createPath(vcsRoot, path, false, true, true);
before = GitContentRevision.createRevision(vcsRoot, path, firstParent, project, false, false, true);
after = GitContentRevision.createRevision(filePath, thisRevision, project, null);
break;
case DELETED:
status = FileStatus.DELETED;
final FilePath filePathDeleted = GitContentRevision.createPath(vcsRoot, path, true, true, true);
before = GitContentRevision.createRevision(filePathDeleted, firstParent, project, null);
after = null;
break;
case COPIED:
case RENAMED:
status = FileStatus.MODIFIED;
String secondPath = statusInfo.getSecondPath();
final FilePath filePathAfterRename = GitContentRevision.createPath(vcsRoot, secondPath == null ? path : secondPath, false, false, true);
before = GitContentRevision.createRevision(vcsRoot, path, firstParent, project, true, true, true);
after = GitContentRevision.createRevision(filePathAfterRename, thisRevision, project, null);
break;
case TYPE_CHANGED:
status = FileStatus.MODIFIED;
final FilePath filePath2 = GitContentRevision.createPath(vcsRoot, path, false, true, true);
before = GitContentRevision.createRevision(vcsRoot, path, firstParent, project, false, false, true);
after = GitContentRevision.createRevision(filePath2, thisRevision, project, null);
break;
default:
throw new AssertionError("Unknown file status: " + statusInfo);
}
return new Change(before, after, status);
}
Aggregations