From 64846024547894c46d3347d08a33f2820ecb80fd Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 8 Oct 2013 18:22:21 +0400 Subject: [PATCH] make TempFileSystem extends LocalFileSystem to simplify clients and tests --- .../intellij/images/index/ImageInfoIndex.java | 5 ++- .../LossyEncodingInspection.java | 5 +-- .../openapi/vfs/ex/temp/TempFileSystem.java | 35 ++++++++++++++++--- .../testFramework/PlatformTestUtil.java | 8 +++-- .../index/Html5CustomAttributesIndex.java | 7 +--- 5 files changed, 40 insertions(+), 20 deletions(-) diff --git a/images/src/org/intellij/images/index/ImageInfoIndex.java b/images/src/org/intellij/images/index/ImageInfoIndex.java index 42c50afefa3f..28838b5e316d 100644 --- a/images/src/org/intellij/images/index/ImageInfoIndex.java +++ b/images/src/org/intellij/images/index/ImageInfoIndex.java @@ -17,7 +17,6 @@ package org.intellij.images.index; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.openapi.vfs.ex.temp.TempFileSystem; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.util.indexing.*; import com.intellij.util.io.DataExternalizer; @@ -94,8 +93,8 @@ public class ImageInfoIndex extends SingleEntryFileBasedIndexExtension addRootsToWatch(@NotNull Collection rootPaths, boolean watchRecursively) { + throw new IncorrectOperationException(); + } + + @Override + public void removeWatchedRoots(@NotNull Collection watchRequests) { + throw new IncorrectOperationException(); + } + + @Override + public Set replaceWatchedRoots(@NotNull Collection watchRequests, + @Nullable Collection recursiveRoots, + @Nullable Collection flatRoots) { + throw new IncorrectOperationException(); + } + + @Nullable + @Override + protected String normalize(@NotNull String path) { + return path; + } } diff --git a/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java b/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java index ee0051b80099..fac110eec634 100644 --- a/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java +++ b/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 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. @@ -44,6 +44,7 @@ import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileFilter; +import com.intellij.openapi.vfs.ex.temp.TempFileSystem; import com.intellij.util.Alarm; import com.intellij.util.ArrayUtil; import com.intellij.util.ThrowableRunnable; @@ -608,13 +609,14 @@ public class PlatformTestUtil { FileDocumentManager.getInstance().saveAllDocuments(); VirtualFile[] childrenAfter = dirAfter.getChildren(); - if (dirAfter.isInLocalFileSystem()) { + + if (dirAfter.isInLocalFileSystem() && dirAfter.getFileSystem() != TempFileSystem.getInstance()) { File[] ioAfter = new File(dirAfter.getPath()).listFiles(); shallowCompare(childrenAfter, ioAfter); } VirtualFile[] childrenBefore = dirBefore.getChildren(); - if (dirBefore.isInLocalFileSystem()) { + if (dirBefore.isInLocalFileSystem() && dirBefore.getFileSystem() != TempFileSystem.getInstance()) { File[] ioBefore = new File(dirBefore.getPath()).listFiles(); shallowCompare(childrenBefore, ioBefore); } diff --git a/xml/impl/src/com/intellij/html/index/Html5CustomAttributesIndex.java b/xml/impl/src/com/intellij/html/index/Html5CustomAttributesIndex.java index c09d8b87558b..ed0538bf6820 100644 --- a/xml/impl/src/com/intellij/html/index/Html5CustomAttributesIndex.java +++ b/xml/impl/src/com/intellij/html/index/Html5CustomAttributesIndex.java @@ -25,7 +25,6 @@ import com.intellij.openapi.fileTypes.FileTypeManager; import com.intellij.openapi.fileTypes.LanguageFileType; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.openapi.vfs.ex.temp.TempFileSystem; import com.intellij.psi.tree.IElementType; import com.intellij.psi.xml.XmlTokenType; import com.intellij.util.containers.HashMap; @@ -97,11 +96,7 @@ public class Html5CustomAttributesIndex extends ScalarIndexExtension { return new DefaultFileTypeSpecificInputFilter(StdFileTypes.HTML, StdFileTypes.XHTML) { @Override public boolean acceptInput(final VirtualFile file) { - if (!file.isInLocalFileSystem() && !(file.getFileSystem() instanceof TempFileSystem)) { - return false; - } - - return true; + return file.isInLocalFileSystem(); } }; }