Search in sources :

Example 1 with DetectedProjectRoot

use of com.intellij.ide.util.projectWizard.importSources.DetectedProjectRoot in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoProjectStructureDetector method detectRoots.

@NotNull
@Override
public DirectoryProcessingResult detectRoots(@NotNull File dir, @NotNull File[] children, @NotNull File base, @NotNull List<DetectedProjectRoot> result) {
    Pattern pattern = Pattern.compile(".*\\.go");
    List<File> filesByMask = FileUtil.findFilesByMask(pattern, base);
    if (!filesByMask.isEmpty()) {
        result.add(new DetectedProjectRoot(dir) {

            @NotNull
            @Override
            public String getRootTypeName() {
                return GoConstants.GO;
            }
        });
    }
    return DirectoryProcessingResult.SKIP_CHILDREN;
}
Also used : Pattern(java.util.regex.Pattern) DetectedProjectRoot(com.intellij.ide.util.projectWizard.importSources.DetectedProjectRoot) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with DetectedProjectRoot

use of com.intellij.ide.util.projectWizard.importSources.DetectedProjectRoot in project intellij-elixir by KronicDeth.

the class ElixirProjectStructureDetector method detectRoots.

@NotNull
@Override
public DirectoryProcessingResult detectRoots(@NotNull File dir, @NotNull File[] children, @NotNull File base, @NotNull List<DetectedProjectRoot> result) {
    Pattern pattern = Pattern.compile(".*\\.ex[s]*");
    List<File> filesByMask = FileUtil.findFilesByMask(pattern, base);
    if (!filesByMask.isEmpty()) {
        result.add(new DetectedProjectRoot(dir) {

            @NotNull
            @Override
            public String getRootTypeName() {
                return "Elixir";
            }
        });
    }
    return DirectoryProcessingResult.SKIP_CHILDREN;
}
Also used : Pattern(java.util.regex.Pattern) DetectedProjectRoot(com.intellij.ide.util.projectWizard.importSources.DetectedProjectRoot) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with DetectedProjectRoot

use of com.intellij.ide.util.projectWizard.importSources.DetectedProjectRoot in project intellij-community by JetBrains.

the class GroovySdkForProjectFromSourcesStep method updateDataModel.

@Override
public void updateDataModel() {
    super.updateDataModel();
    List<ModuleDescriptor> modules = new ArrayList<>();
    for (DetectedProjectRoot root : myBuilder.getProjectRoots(myDetector)) {
        final ModuleDescriptor descriptor = new ModuleDescriptor(root.getDirectory(), StdModuleTypes.JAVA, Collections.<DetectedSourceRoot>emptyList());
        descriptor.addConfigurationUpdater(createModuleConfigurationUpdater());
        modules.add(descriptor);
    }
    myProjectDescriptor.setModules(modules);
}
Also used : ModuleDescriptor(com.intellij.ide.util.importProject.ModuleDescriptor) DetectedProjectRoot(com.intellij.ide.util.projectWizard.importSources.DetectedProjectRoot) ArrayList(java.util.ArrayList)

Example 4 with DetectedProjectRoot

use of com.intellij.ide.util.projectWizard.importSources.DetectedProjectRoot in project intellij-community by JetBrains.

the class DetectedRootsChooser method setElements.

public void setElements(List<? extends DetectedRootData> roots) {
    Set<String> rootTypes = new HashSet<>();
    for (DetectedRootData root : roots) {
        for (DetectedProjectRoot projectRoot : root.getAllRoots()) {
            rootTypes.add(projectRoot.getRootTypeName());
        }
    }
    myModel.setColumnInfos(new ColumnInfo[] { myIncludedColumn, ROOT_COLUMN, ROOT_TYPE_COLUMN });
    int max = 0;
    for (String rootType : rootTypes) {
        max = Math.max(max, myTable.getFontMetrics(myTable.getFont()).stringWidth(rootType));
    }
    final TableColumn column = myTable.getColumnModel().getColumn(2);
    //add space for combobox button
    int width = max + 20;
    column.setPreferredWidth(width);
    column.setMaxWidth(width);
    myTable.updateColumnSizes();
    List<DetectedRootData> sortedRoots = new ArrayList<>(roots);
    Collections.sort(sortedRoots, Comparator.comparing(DetectedRootData::getDirectory));
    myModel.setItems(sortedRoots);
}
Also used : DetectedProjectRoot(com.intellij.ide.util.projectWizard.importSources.DetectedProjectRoot) TableColumn(javax.swing.table.TableColumn)

Example 5 with DetectedProjectRoot

use of com.intellij.ide.util.projectWizard.importSources.DetectedProjectRoot in project intellij-community by JetBrains.

the class ModuleInsight method buildModuleDependencies.

private void buildModuleDependencies(final Map<File, ModuleDescriptor> contentRootToModules) {
    final Set<File> moduleContentRoots = contentRootToModules.keySet();
    for (File contentRoot : moduleContentRoots) {
        final ModuleDescriptor checkedModule = contentRootToModules.get(contentRoot);
        myProgress.setText2("Building library dependencies for module " + checkedModule.getName());
        buildJarDependencies(checkedModule);
        myProgress.setText2("Building module dependencies for module " + checkedModule.getName());
        for (File aContentRoot : moduleContentRoots) {
            final ModuleDescriptor aModule = contentRootToModules.get(aContentRoot);
            if (checkedModule.equals(aModule)) {
                // avoid self-dependencies
                continue;
            }
            final Collection<? extends DetectedProjectRoot> aModuleRoots = aModule.getSourceRoots();
            checkModules: for (DetectedProjectRoot srcRoot : checkedModule.getSourceRoots()) {
                final Set<String> referencedBySourceRoot = mySourceRootToReferencedPackagesMap.get(srcRoot.getDirectory());
                for (DetectedProjectRoot aSourceRoot : aModuleRoots) {
                    if (ContainerUtil.intersects(referencedBySourceRoot, mySourceRootToPackagesMap.get(aSourceRoot.getDirectory()))) {
                        checkedModule.addDependencyOn(aModule);
                        break checkModules;
                    }
                }
            }
        }
    }
}
Also used : DetectedProjectRoot(com.intellij.ide.util.projectWizard.importSources.DetectedProjectRoot) File(java.io.File)

Aggregations

DetectedProjectRoot (com.intellij.ide.util.projectWizard.importSources.DetectedProjectRoot)16 File (java.io.File)8 ProjectStructureDetector (com.intellij.ide.util.projectWizard.importSources.ProjectStructureDetector)5 ModuleDescriptor (com.intellij.ide.util.importProject.ModuleDescriptor)3 DetectedSourceRoot (com.intellij.ide.util.projectWizard.importSources.DetectedSourceRoot)3 ArrayList (java.util.ArrayList)3 Pattern (java.util.regex.Pattern)2 NotNull (org.jetbrains.annotations.NotNull)2 DetectedRootData (com.intellij.ide.util.importProject.DetectedRootData)1 AbstractStepWithProgress (com.intellij.ide.util.projectWizard.AbstractStepWithProgress)1 ModuleWizardStep (com.intellij.ide.util.projectWizard.ModuleWizardStep)1 DetectedContentRoot (com.intellij.ide.util.projectWizard.importSources.DetectedContentRoot)1 JavaModuleSourceRoot (com.intellij.ide.util.projectWizard.importSources.JavaModuleSourceRoot)1 ModuleType (com.intellij.openapi.module.ModuleType)1 SmartList (com.intellij.util.SmartList)1 MultiMap (com.intellij.util.containers.MultiMap)1 TableColumn (javax.swing.table.TableColumn)1 NonNls (org.jetbrains.annotations.NonNls)1