Search in sources :

Example 16 with FileStatus

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;
}
Also used : FileStatus(com.intellij.openapi.vcs.FileStatus) NonPhysicalFileSystem(com.intellij.openapi.vfs.NonPhysicalFileSystem)

Example 17 with FileStatus

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);
    }
}
Also used : FileStatus(com.intellij.openapi.vcs.FileStatus) FileStatusListener(com.intellij.openapi.vcs.FileStatusListener) Application(com.intellij.openapi.application.Application) DumbAwareRunnable(com.intellij.openapi.project.DumbAwareRunnable)

Example 18 with FileStatus

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;
}
Also used : FileStatus(com.intellij.openapi.vcs.FileStatus) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) FileStatusManager(com.intellij.openapi.vcs.FileStatusManager)

Example 19 with FileStatus

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);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileStatus(com.intellij.openapi.vcs.FileStatus) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) FileStatusManager(com.intellij.openapi.vcs.FileStatusManager) NotNull(org.jetbrains.annotations.NotNull)

Example 20 with FileStatus

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);
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) FileStatus(com.intellij.openapi.vcs.FileStatus) GitRevisionNumber(git4idea.GitRevisionNumber) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) GitContentRevision(git4idea.GitContentRevision) Change(com.intellij.openapi.vcs.changes.Change) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

FileStatus (com.intellij.openapi.vcs.FileStatus)29 VirtualFile (com.intellij.openapi.vfs.VirtualFile)9 Change (com.intellij.openapi.vcs.changes.Change)7 NotNull (org.jetbrains.annotations.NotNull)6 FilePath (com.intellij.openapi.vcs.FilePath)5 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)5 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)4 FileStatusManager (com.intellij.openapi.vcs.FileStatusManager)3 ArrayList (java.util.ArrayList)3 PsiElement (com.intellij.psi.PsiElement)2 GitContentRevision (git4idea.GitContentRevision)2 RefElement (com.intellij.codeInspection.reference.RefElement)1 RefEntity (com.intellij.codeInspection.reference.RefEntity)1 NavigationItemFileStatus (com.intellij.navigation.NavigationItemFileStatus)1 Application (com.intellij.openapi.application.Application)1 FilePatch (com.intellij.openapi.diff.impl.patch.FilePatch)1 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)1 DumbAwareRunnable (com.intellij.openapi.project.DumbAwareRunnable)1 Project (com.intellij.openapi.project.Project)1 InvalidDataException (com.intellij.openapi.util.InvalidDataException)1