Commit 0f7eaad5 authored by Sergey Simonchik's avatar Sergey Simonchik
Browse files

skip files under node_modules completely when importing project/module (WEB-35513)

Since node_modules/ contains dependencies only (not actual project code), detecting roots/frameworks from these files is not needed, moreover, it takes time to traverse.

https://upsource.jetbrains.com/IDEA/review/IDEA-CR-42501
parent 29e3a121
Showing with 10 additions and 5 deletions
+10 -5
......@@ -15,6 +15,7 @@
*/
package com.intellij.ide.util.importProject;
import com.intellij.framework.detection.impl.FrameworkDetectionProcessor;
import com.intellij.ide.util.projectWizard.importSources.DetectedContentRoot;
import com.intellij.ide.util.projectWizard.importSources.DetectedProjectRoot;
import com.intellij.ide.util.projectWizard.importSources.DetectedSourceRoot;
......@@ -165,7 +166,7 @@ public class RootDetectionProcessor {
if (!enabledForChildren.isEmpty()) {
for (File child : children) {
if (child.isDirectory()) {
if (child.isDirectory() && !FrameworkDetectionProcessor.SKIPPED_DIRECTORIES.contains(child.getName())) {
final List<Pair<File, Integer>> toSkip = processRecursively(child, enabledForChildren, parentDirectories);
if (!toSkip.isEmpty()) {
if (enabledForChildren == enabledDetectors) {
......
......@@ -34,9 +34,6 @@ public abstract class JavaSourceRootDetector extends ProjectStructureDetector {
@Override
public DirectoryProcessingResult detectRoots(@NotNull File dir, @NotNull File[] children, @NotNull File base,
@NotNull List<DetectedProjectRoot> result) {
if (dir.getName().equals("node_modules")) {
return DirectoryProcessingResult.SKIP_CHILDREN;
}
final String fileExtension = getFileExtension();
if (JavaFileType.DEFAULT_EXTENSION.equals(fileExtension)) {
for (File child : children) {
......
......@@ -27,6 +27,7 @@ import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileVisitor;
import com.intellij.patterns.ElementPattern;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
import com.intellij.util.indexing.FileContent;
import com.intellij.util.indexing.FileContentImpl;
......@@ -43,6 +44,9 @@ import java.util.Set;
* @author nik
*/
public class FrameworkDetectionProcessor {
public static final Set<String> SKIPPED_DIRECTORIES = ContainerUtil.newHashSet("node_modules");
private static final Logger LOG = Logger.getInstance("#com.intellij.framework.detection.impl.FrameworkDetectionProcessor");
private final ProgressIndicator myProgressIndicator;
private final MultiMap<FileType, FrameworkDetectorData> myDetectorsByFileType;
......@@ -82,7 +86,7 @@ public class FrameworkDetectionProcessor {
// Since this code is invoked from New Project Wizard it's very possible that VFS isn't loaded to memory yet, so we need to do it
// manually, otherwise refresh will do nothing
myProgressIndicator.checkCanceled();
return true;
return !(file.isDirectory() && SKIPPED_DIRECTORIES.contains(file.getName()));
}
});
file.refresh(false, true);
......@@ -91,6 +95,9 @@ public class FrameworkDetectionProcessor {
@Override
public boolean visitFile(@NotNull VirtualFile file) {
myProgressIndicator.checkCanceled();
if (file.isDirectory() && SKIPPED_DIRECTORIES.contains(file.getName())) {
return false;
}
if (!myProcessedFiles.add(file)) {
return false;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment