diff --git a/java/idea-ui/src/com/intellij/facet/impl/autodetecting/FacetAutodetectingManager.java b/java/idea-ui/src/com/intellij/facet/impl/autodetecting/FacetAutodetectingManager.java index 9c7770c122d0..63ef7c113fc8 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/autodetecting/FacetAutodetectingManager.java +++ b/java/idea-ui/src/com/intellij/facet/impl/autodetecting/FacetAutodetectingManager.java @@ -29,8 +29,6 @@ public abstract class FacetAutodetectingManager { return project.getComponent(FacetAutodetectingManager.class); } - public abstract void disableAutodetectionInDirs(@NotNull Module module, @NotNull String... dirUrls); - public abstract void disableAutodetectionInFiles(@NotNull FacetType type, @NotNull Module module, @NotNull String... fileUrls); public abstract void disableAutodetectionInModule(FacetType type, Module module); diff --git a/java/idea-ui/src/com/intellij/facet/impl/autodetecting/FacetAutodetectingManagerImpl.java b/java/idea-ui/src/com/intellij/facet/impl/autodetecting/FacetAutodetectingManagerImpl.java index 70e6b806f072..0a1b40c27e89 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/autodetecting/FacetAutodetectingManagerImpl.java +++ b/java/idea-ui/src/com/intellij/facet/impl/autodetecting/FacetAutodetectingManagerImpl.java @@ -279,14 +279,6 @@ public class FacetAutodetectingManagerImpl extends FacetAutodetectingManager imp myDisabledAutodetectionInfo.addDisabled(type.getStringId(), module.getName()); } - public void disableAutodetectionInDirs(@NotNull Module module, @NotNull String... dirUrls) { - for (FacetType facetType : myFacetTypesWithDetectors) { - for (String dirUrl : dirUrls) { - myDisabledAutodetectionInfo.addDisabled(facetType.getStringId(), module.getName(), dirUrl, true); - } - } - } - public void disableAutodetectionInFiles(@NotNull final FacetType type, @NotNull final Module module, @NotNull final String... fileUrls) { myDisabledAutodetectionInfo.addDisabled(type.getStringId(), module.getName(), fileUrls); } diff --git a/platform/lang-impl/src/com/intellij/framework/FrameworkType.java b/platform/lang-api/src/com/intellij/framework/FrameworkType.java similarity index 100% rename from platform/lang-impl/src/com/intellij/framework/FrameworkType.java rename to platform/lang-api/src/com/intellij/framework/FrameworkType.java diff --git a/platform/lang-impl/src/com/intellij/framework/detection/DetectionExcludesConfiguration.java b/platform/lang-api/src/com/intellij/framework/detection/DetectionExcludesConfiguration.java similarity index 88% rename from platform/lang-impl/src/com/intellij/framework/detection/DetectionExcludesConfiguration.java rename to platform/lang-api/src/com/intellij/framework/detection/DetectionExcludesConfiguration.java index 201cf1d27f20..ad3afb49a97c 100644 --- a/platform/lang-impl/src/com/intellij/framework/detection/DetectionExcludesConfiguration.java +++ b/platform/lang-api/src/com/intellij/framework/detection/DetectionExcludesConfiguration.java @@ -22,8 +22,6 @@ import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Collection; - /** * @author nik */ @@ -34,7 +32,5 @@ public abstract class DetectionExcludesConfiguration { public abstract void addExcludedFramework(@NotNull FrameworkType type); public abstract void addExcludedFile(@NotNull VirtualFile file, @Nullable FrameworkType type); - - public abstract void removeExcluded(@NotNull Collection files, - final FrameworkType frameworkType); + public abstract void addExcludedUrl(@NotNull String url, @Nullable FrameworkType type); } diff --git a/platform/lang-impl/src/com/intellij/framework/detection/impl/FrameworkDetectionManager.java b/platform/lang-impl/src/com/intellij/framework/detection/impl/FrameworkDetectionManager.java index b098f8e633c0..e22a2b42ed82 100644 --- a/platform/lang-impl/src/com/intellij/framework/detection/impl/FrameworkDetectionManager.java +++ b/platform/lang-impl/src/com/intellij/framework/detection/impl/FrameworkDetectionManager.java @@ -21,6 +21,7 @@ import com.intellij.codeHighlighting.TextEditorHighlightingPassRegistrar; import com.intellij.framework.detection.DetectedFrameworkDescription; import com.intellij.framework.detection.DetectionExcludesConfiguration; import com.intellij.framework.detection.FrameworkDetector; +import com.intellij.framework.detection.impl.exclude.DetectionExcludesConfigurationImpl; import com.intellij.framework.detection.impl.ui.ConfigureDetectedFrameworksDialog; import com.intellij.notification.Notification; import com.intellij.notification.NotificationGroup; @@ -202,7 +203,7 @@ public class FrameworkDetectionManager extends AbstractProjectComponent implemen return Collections.emptyList(); } - excludesConfiguration.removeExcluded(filesToProcess, detector.getFrameworkType()); + ((DetectionExcludesConfigurationImpl)excludesConfiguration).removeExcluded(filesToProcess, detector.getFrameworkType()); if (LOG.isDebugEnabled()) { LOG.debug("Detector '" + detector.getDetectorId() + "': " + acceptedFiles.size() + " accepted files, " + filesToProcess.size() + " files to process"); } diff --git a/platform/lang-impl/src/com/intellij/framework/detection/impl/FrameworkDetectionUtil.java b/platform/lang-impl/src/com/intellij/framework/detection/impl/FrameworkDetectionUtil.java index 3cc0563e0e16..b3376caee9b5 100644 --- a/platform/lang-impl/src/com/intellij/framework/detection/impl/FrameworkDetectionUtil.java +++ b/platform/lang-impl/src/com/intellij/framework/detection/impl/FrameworkDetectionUtil.java @@ -15,13 +15,18 @@ */ package com.intellij.framework.detection.impl; +import com.intellij.facet.FacetType; +import com.intellij.framework.FrameworkType; import com.intellij.framework.detection.DetectedFrameworkDescription; +import com.intellij.framework.detection.FacetBasedFrameworkDetector; +import com.intellij.framework.detection.FrameworkDetector; import com.intellij.openapi.application.AccessToken; import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.PlatformModifiableModelsProvider; import com.intellij.openapi.roots.ui.configuration.DefaultModulesProvider; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; @@ -33,6 +38,17 @@ public class FrameworkDetectionUtil { private FrameworkDetectionUtil() { } + @Nullable + public static FrameworkType findFrameworkTypeForFacetDetector(@NotNull FacetType facetType) { + for (FrameworkDetector detector : FrameworkDetector.EP_NAME.getExtensions()) { + if (detector instanceof FacetBasedFrameworkDetector && + ((FacetBasedFrameworkDetector)detector).getFacetType().equals(facetType)) { + return detector.getFrameworkType(); + } + } + return null; + } + public static List getDisabledDescriptions(@NotNull List allDescriptions) { List disabled = new ArrayList(); for (DetectedFrameworkDescription description : allDescriptions) { 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 4fb3c2c71095..6e6746dd66cf 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 @@ -26,6 +26,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer; import com.intellij.openapi.vfs.pointers.VirtualFilePointerManager; import com.intellij.util.containers.FactoryMap; @@ -96,6 +97,22 @@ public class DetectionExcludesConfigurationImpl extends DetectionExcludesConfigu container.add(file); } + @Override + public void addExcludedUrl(@NotNull String url, @Nullable FrameworkType type) { + final VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(url); + if (file != null) { + addExcludedFile(file, type); + return; + } + + convert(); + final String typeId = type != null ? type.getId() : null; + if (typeId != null && myExcludedFrameworks.contains(typeId)) { + return; + } + myExcludedFiles.get(typeId).add(url); + } + private void convert() { ensureOldSettingsLoaded(); markAsConverted(); @@ -138,7 +155,6 @@ public class DetectionExcludesConfigurationImpl extends DetectionExcludesConfigu } } - @Override public void removeExcluded(@NotNull Collection files, final FrameworkType frameworkType) { ensureOldSettingsLoaded(); if (myExcludedFrameworks.contains(frameworkType.getId())) { diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/FacetImporter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/FacetImporter.java index 4f325edb5d8c..c2987b0af5fa 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/FacetImporter.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/FacetImporter.java @@ -16,9 +16,12 @@ package org.jetbrains.idea.maven.importing; import com.intellij.facet.*; -import com.intellij.facet.impl.autodetecting.FacetAutodetectingManager; +import com.intellij.framework.FrameworkType; +import com.intellij.framework.detection.DetectionExcludesConfiguration; +import com.intellij.framework.detection.impl.FrameworkDetectionUtil; import com.intellij.openapi.module.Module; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.ArrayUtil; import com.intellij.util.PathUtil; import org.jetbrains.idea.maven.project.MavenProject; @@ -60,7 +63,7 @@ public abstract class FacetImporter