use of com.intellij.ide.util.projectWizard.importSources.DetectedProjectRoot in project intellij-community by JetBrains.
the class ProjectLayoutPanel method getElementText.
protected static String getElementText(Object element) {
if (element instanceof LibraryDescriptor) {
final StringBuilder builder = StringBuilderSpinAllocator.alloc();
try {
builder.append(((LibraryDescriptor) element).getName());
final Collection<File> jars = ((LibraryDescriptor) element).getJars();
if (jars.size() == 1) {
final File parentFile = jars.iterator().next().getParentFile();
if (parentFile != null) {
builder.append(" (");
builder.append(parentFile.getPath());
builder.append(")");
}
}
return builder.toString();
} finally {
StringBuilderSpinAllocator.dispose(builder);
}
}
if (element instanceof File) {
final StringBuilder builder = StringBuilderSpinAllocator.alloc();
try {
builder.append(((File) element).getName());
final File parentFile = ((File) element).getParentFile();
if (parentFile != null) {
builder.append(" (");
builder.append(parentFile.getPath());
builder.append(")");
}
return builder.toString();
} finally {
StringBuilderSpinAllocator.dispose(builder);
}
}
if (element instanceof ModuleDescriptor) {
final ModuleDescriptor moduleDescriptor = (ModuleDescriptor) element;
final StringBuilder builder = StringBuilderSpinAllocator.alloc();
try {
builder.append(moduleDescriptor.getName());
final Set<File> contents = moduleDescriptor.getContentRoots();
final int rootCount = contents.size();
if (rootCount > 0) {
builder.append(" (");
builder.append(contents.iterator().next().getPath());
if (rootCount > 1) {
builder.append("...");
}
builder.append(")");
}
final Collection<? extends DetectedProjectRoot> sourceRoots = moduleDescriptor.getSourceRoots();
if (sourceRoots.size() > 0) {
builder.append(" [");
for (Iterator<? extends DetectedProjectRoot> it = sourceRoots.iterator(); it.hasNext(); ) {
DetectedProjectRoot root = it.next();
builder.append(root.getDirectory().getName());
if (it.hasNext()) {
builder.append(",");
}
}
builder.append("]");
}
return builder.toString();
} finally {
StringBuilderSpinAllocator.dispose(builder);
}
}
return "";
}
use of com.intellij.ide.util.projectWizard.importSources.DetectedProjectRoot in project intellij-community by JetBrains.
the class RootDetectionProcessor method detectRoots.
private List<DetectedRootData> detectRoots() {
Map<ProjectStructureDetector, List<DetectedProjectRoot>> roots = runDetectors();
if (myProgressIndicator != null) {
myProgressIndicator.setText2("Processing " + roots.values().size() + " project roots...");
}
Map<File, DetectedRootData> rootData = new LinkedHashMap<>();
for (ProjectStructureDetector detector : roots.keySet()) {
for (DetectedProjectRoot detectedRoot : roots.get(detector)) {
if (isUnderIncompatibleRoot(detectedRoot, rootData)) {
continue;
}
final DetectedRootData data = rootData.get(detectedRoot.getDirectory());
if (data == null) {
rootData.put(detectedRoot.getDirectory(), new DetectedRootData(detector, detectedRoot));
} else {
detectedRoot = data.addRoot(detector, detectedRoot);
}
removeIncompatibleRoots(detectedRoot, rootData);
}
}
List<DetectedRootData> dataCollection = mergeContentRoots(rootData);
if (myProgressIndicator != null) {
myProgressIndicator.setText2("");
}
return dataCollection;
}
use of com.intellij.ide.util.projectWizard.importSources.DetectedProjectRoot in project android by JetBrains.
the class AndroidProjectStructureDetector method setupProjectStructure.
@Override
public void setupProjectStructure(@NotNull Collection<DetectedProjectRoot> roots, @NotNull ProjectDescriptor projectDescriptor, @NotNull ProjectFromSourcesBuilder builder) {
final List<File> existingRoots = new ArrayList<File>();
for (ProjectStructureDetector detector : ProjectStructureDetector.EP_NAME.getExtensions()) {
if (detector != this) {
for (DetectedProjectRoot root : builder.getProjectRoots(detector)) {
existingRoots.add(root.getDirectory());
}
}
}
final List<ModuleDescriptor> modules = new ArrayList<ModuleDescriptor>();
for (DetectedProjectRoot root : roots) {
final File dir = root.getDirectory();
boolean javaSrcRootInside = false;
for (File javaSourceRoot : existingRoots) {
if (FileUtil.isAncestor(dir, javaSourceRoot, false)) {
javaSrcRootInside = true;
}
}
if (!javaSrcRootInside) {
modules.add(new ModuleDescriptor(root.getDirectory(), JavaModuleType.getModuleType(), Collections.<DetectedSourceRoot>emptyList()));
}
}
projectDescriptor.setModules(modules);
}
use of com.intellij.ide.util.projectWizard.importSources.DetectedProjectRoot in project intellij-elixir by KronicDeth.
the class ElixirProjectStructureDetector method setupProjectStructure.
/**
* This detector just for import non-organization project which not like mix-project
* So that it's no need to detect directories such as libs, deps, tests etc
*
* And mix-project will imported by the MixProjectImportBuilder.java
* */
@Override
public void setupProjectStructure(@NotNull Collection<DetectedProjectRoot> roots, @NotNull ProjectDescriptor projectDescriptor, @NotNull ProjectFromSourcesBuilder builder) {
if (!roots.isEmpty() && !builder.hasRootsFromOtherDetectors(this)) {
List<ModuleDescriptor> modules = projectDescriptor.getModules();
if (modules.isEmpty()) {
modules = new ArrayList<ModuleDescriptor>();
for (DetectedProjectRoot root : roots) {
modules.add(new ModuleDescriptor(root.getDirectory(), ElixirModuleType.getInstance(), ContainerUtil.<DetectedSourceRoot>emptyList()));
}
projectDescriptor.setModules(modules);
}
}
}
use of com.intellij.ide.util.projectWizard.importSources.DetectedProjectRoot in project intellij-community by JetBrains.
the class ModuleDescriptor method toString.
/**
* For debug purposes only
*/
public String toString() {
@NonNls final StringBuilder builder = new StringBuilder();
builder.append("[Module: ").append(getContentRoots()).append(" | ");
for (DetectedProjectRoot sourceRoot : getSourceRoots()) {
builder.append(sourceRoot.getDirectory().getName()).append(",");
}
builder.append("]");
return builder.toString();
}
Aggregations