From 52e9d7f98d16d3036116cdb7168f54dad5c50e06 Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 23 Oct 2013 17:26:16 +0400 Subject: [PATCH] framework detection excludes: method extracted to API --- .../detection/DetectionExcludesConfiguration.java | 2 ++ .../impl/exclude/DetectionExcludesConfigurationImpl.java | 9 +++++++++ .../detection/ConvertingOldDetectionExcludesTest.java | 8 +------- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/platform/lang-api/src/com/intellij/framework/detection/DetectionExcludesConfiguration.java b/platform/lang-api/src/com/intellij/framework/detection/DetectionExcludesConfiguration.java index ad3afb49a97c..2f2ebe07e886 100644 --- a/platform/lang-api/src/com/intellij/framework/detection/DetectionExcludesConfiguration.java +++ b/platform/lang-api/src/com/intellij/framework/detection/DetectionExcludesConfiguration.java @@ -33,4 +33,6 @@ public abstract class DetectionExcludesConfiguration { public abstract void addExcludedFramework(@NotNull FrameworkType type); public abstract void addExcludedFile(@NotNull VirtualFile file, @Nullable FrameworkType type); public abstract void addExcludedUrl(@NotNull String url, @Nullable FrameworkType type); + + public abstract boolean isExcludedFromDetection(@NotNull VirtualFile file, @NotNull FrameworkType frameworkType); } diff --git a/platform/lang-impl/src/com/intellij/framework/detection/impl/exclude/DetectionExcludesConfigurationImpl.java b/platform/lang-impl/src/com/intellij/framework/detection/impl/exclude/DetectionExcludesConfigurationImpl.java index c6b351530b6a..3572f0ccfbe6 100644 --- a/platform/lang-impl/src/com/intellij/framework/detection/impl/exclude/DetectionExcludesConfigurationImpl.java +++ b/platform/lang-impl/src/com/intellij/framework/detection/impl/exclude/DetectionExcludesConfigurationImpl.java @@ -134,6 +134,15 @@ public class DetectionExcludesConfigurationImpl extends DetectionExcludesConfigu } } + @Override + public boolean isExcludedFromDetection(@NotNull VirtualFile file, @NotNull FrameworkType frameworkType) { + ensureOldSettingsLoaded(); + if (myExcludedFrameworks.contains(frameworkType.getId())) { + return true; + } + return isFileExcluded(file, frameworkType.getId()); + } + private boolean isFileExcluded(@NotNull VirtualFile file, @Nullable String typeId) { if (myExcludedFiles.containsKey(typeId) && isUnder(file, myExcludedFiles.get(typeId))) return true; return typeId != null && myExcludedFiles.containsKey(null) && isUnder(file, myExcludedFiles.get(null)); diff --git a/platform/platform-tests/testSrc/com/intellij/framework/detection/ConvertingOldDetectionExcludesTest.java b/platform/platform-tests/testSrc/com/intellij/framework/detection/ConvertingOldDetectionExcludesTest.java index 11ccbad81fe7..983f1ef0661b 100644 --- a/platform/platform-tests/testSrc/com/intellij/framework/detection/ConvertingOldDetectionExcludesTest.java +++ b/platform/platform-tests/testSrc/com/intellij/framework/detection/ConvertingOldDetectionExcludesTest.java @@ -26,9 +26,6 @@ import com.intellij.testFramework.PlatformTestCase; import com.intellij.testFramework.PsiTestUtil; import com.intellij.testFramework.TempFiles; -import java.util.ArrayList; -import java.util.List; - /** * @author nik */ @@ -91,10 +88,7 @@ public class ConvertingOldDetectionExcludesTest extends PlatformTestCase { } private boolean isFileExcluded(VirtualFile file) { - final List files = new ArrayList(); - files.add(file); - getNewConfiguration().removeExcluded(files, new MockFrameworkType(FRAMEWORK_ID)); - return files.isEmpty(); + return getNewConfiguration().isExcludedFromDetection(file, new MockFrameworkType(FRAMEWORK_ID)); } public void testConvert() {