new framework detection: migrated usages of old excludes configuration

This commit is contained in:
nik
2011-08-08 13:18:54 +04:00
parent 58e0fd9fe8
commit aee1f4e4cf
8 changed files with 49 additions and 22 deletions
@@ -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);
@@ -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);
}
@@ -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<VirtualFile> files,
final FrameworkType frameworkType);
public abstract void addExcludedUrl(@NotNull String url, @Nullable FrameworkType type);
}
@@ -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");
}
@@ -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<DetectedFrameworkDescription> getDisabledDescriptions(@NotNull List<? extends DetectedFrameworkDescription> allDescriptions) {
List<DetectedFrameworkDescription> disabled = new ArrayList<DetectedFrameworkDescription>();
for (DetectedFrameworkDescription description : allDescriptions) {
@@ -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<VirtualFile> files, final FrameworkType frameworkType) {
ensureOldSettingsLoaded();
if (myExcludedFrameworks.contains(frameworkType.getId())) {
@@ -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<FACET_TYPE extends Facet, FACET_CONFIG_TYPE
MavenProjectChanges changes,
MavenModifiableModelsProvider modifiableModelsProvider) {
prepareImporter(mavenProject);
disableFacetAutodetection(module);
disableFacetAutodetection(module, modifiableModelsProvider);
ensureFacetExists(module, mavenProject, modifiableModelsProvider);
}
@@ -78,9 +81,14 @@ public abstract class FacetImporter<FACET_TYPE extends Facet, FACET_CONFIG_TYPE
protected void prepareImporter(MavenProject p) {
}
private void disableFacetAutodetection(Module module) {
FacetAutodetectingManager m = FacetAutodetectingManager.getInstance(module.getProject());
m.disableAutodetectionInModule(myFacetType, module);
private void disableFacetAutodetection(Module module, MavenModifiableModelsProvider provider) {
final DetectionExcludesConfiguration excludesConfiguration = DetectionExcludesConfiguration.getInstance(module.getProject());
final FrameworkType frameworkType = FrameworkDetectionUtil.findFrameworkTypeForFacetDetector(myFacetType);
if (frameworkType != null) {
for (VirtualFile file : provider.getContentRoots(module)) {
excludesConfiguration.addExcludedFile(file, frameworkType);
}
}
}
protected abstract void setupFacet(FACET_TYPE f, MavenProject mavenProject);