From e31663bf12839f21c654cf164b38aa313669359f Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 29 May 2013 12:24:06 +0400 Subject: [PATCH] VCS keeps asking me to associate unknown file type --- .../src/com/intellij/openapi/vcs/FilePathImpl.java | 13 +++++++++---- .../actions/ConflictedDiffRequestPresentable.java | 5 +++-- .../changes/patch/MergedDiffRequestPresentable.java | 5 +++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/FilePathImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/FilePathImpl.java index abd2a3b05069..282fd29bd5b9 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/FilePathImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/FilePathImpl.java @@ -131,7 +131,7 @@ public class FilePathImpl implements FilePath { return myFile.equals(((FilePath)o).getIOFile()); } } - + private static boolean isSpecialName(final String name) { return ".".equals(name) || "..".equals(name); } @@ -214,6 +214,9 @@ public class FilePathImpl implements FilePath { if (myVirtualFile != null && !myVirtualFile.isValid()) { myVirtualFile = null; } + if (myVirtualFile == null) { + refresh(); + } detectFileType(); return myVirtualFile; } @@ -251,10 +254,11 @@ public class FilePathImpl implements FilePath { @Override @Nullable public Document getDocument() { - if (myVirtualFile == null || myVirtualFile.getFileType().isBinary()) { + VirtualFile virtualFile = getVirtualFile(); + if (virtualFile == null || virtualFile.getFileType().isBinary()) { return null; } - return FileDocumentManager.getInstance().getDocument(myVirtualFile); + return FileDocumentManager.getInstance().getDocument(virtualFile); } @Override @@ -290,7 +294,8 @@ public class FilePathImpl implements FilePath { @Override public FileType getFileType() { - return myVirtualFile != null ? myVirtualFile.getFileType() : FileTypeManager.getInstance().getFileTypeByFileName(myFile.getName()); + VirtualFile virtualFile = getVirtualFile(); + return virtualFile != null ? virtualFile.getFileType() : FileTypeManager.getInstance().getFileTypeByFileName(myFile.getName()); } public static FilePathImpl create(VirtualFile file) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/ConflictedDiffRequestPresentable.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/ConflictedDiffRequestPresentable.java index 0d27b1f5bc89..02586bba5e78 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/ConflictedDiffRequestPresentable.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/ConflictedDiffRequestPresentable.java @@ -75,8 +75,9 @@ public class ConflictedDiffRequestPresentable implements DiffRequestPresentable return new MyResult(request, DiffPresentationReturnValue.useRequest); } else { - if (myFile.getFileType().isBinary()) { - final boolean nowItIsText = ChangeDiffRequestPresentable.checkAssociate(myProject, new FilePathImpl(myFile), context); + FilePathImpl filePath = new FilePathImpl(myFile); + if (filePath.getFileType().isBinary()) { + final boolean nowItIsText = ChangeDiffRequestPresentable.checkAssociate(myProject, filePath, context); if (! nowItIsText) { return createErrorResult(); } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/MergedDiffRequestPresentable.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/MergedDiffRequestPresentable.java index e1bcb06f9fda..05b4e95b8672 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/MergedDiffRequestPresentable.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/MergedDiffRequestPresentable.java @@ -44,8 +44,9 @@ public class MergedDiffRequestPresentable implements DiffRequestPresentable { } public MyResult step(DiffChainContext context) { - if (myFile.getFileType().isBinary()) { - final boolean nowItIsText = ChangeDiffRequestPresentable.checkAssociate(myProject, new FilePathImpl(myFile), context); + FilePathImpl filePath = new FilePathImpl(myFile); + if (filePath.getFileType().isBinary()) { + final boolean nowItIsText = ChangeDiffRequestPresentable.checkAssociate(myProject, filePath, context); if (! nowItIsText) { final SimpleDiffRequest request = new SimpleDiffRequest(myProject, null); return new MyResult(request, DiffPresentationReturnValue.removeFromList);