IDEA-78309 Gradle: Correct processing of library doc roots on importing

This commit is contained in:
Denis.Zhdanov
2011-12-06 13:17:47 +03:00
parent 25408f78c1
commit f1086f8d2b
2 changed files with 12 additions and 16 deletions
@@ -45,6 +45,15 @@ import java.util.concurrent.TimeUnit;
*/
public class GradleModulesImporter {
private static final Map<LibraryPathType, OrderRootType> LIBRARY_ROOT_MAPPINGS
= new EnumMap<LibraryPathType, OrderRootType>(LibraryPathType.class);
static {
LIBRARY_ROOT_MAPPINGS.put(LibraryPathType.BINARY, OrderRootType.CLASSES);
LIBRARY_ROOT_MAPPINGS.put(LibraryPathType.SOURCE, OrderRootType.SOURCES);
LIBRARY_ROOT_MAPPINGS.put(LibraryPathType.DOC, JavadocOrderRootType.getInstance());
assert LibraryPathType.values().length == LIBRARY_ROOT_MAPPINGS.size();
}
/**
* We can't modify project modules (add/remove) until it's initialised, so, we delay that activity. Current constant
* holds number of milliseconds to wait between 'after project initialisation' processing attempts.
@@ -463,7 +472,7 @@ public class GradleModulesImporter {
continue;
}
if (virtualFile.isDirectory()) {
model.addRoot(virtualFile, pathType.getRootType());
model.addRoot(virtualFile, LIBRARY_ROOT_MAPPINGS.get(pathType));
}
else {
VirtualFile jarRoot = JarFileSystem.getInstance().getJarRootForLocalFile(virtualFile);
@@ -473,7 +482,7 @@ public class GradleModulesImporter {
));
continue;
}
model.addRoot(jarRoot, pathType.getRootType());
model.addRoot(jarRoot, LIBRARY_ROOT_MAPPINGS.get(pathType));
}
}
}
@@ -1,7 +1,6 @@
package org.jetbrains.plugins.gradle.model;
import com.intellij.openapi.roots.OrderRootType;
import org.jetbrains.annotations.NotNull;
/**
* Note that current enum duplicates {@link OrderRootType}. We can't use the later directly because it's not properly setup
@@ -11,17 +10,5 @@ import org.jetbrains.annotations.NotNull;
* @since 8/10/11 6:37 PM
*/
public enum LibraryPathType {
BINARY(OrderRootType.CLASSES), SOURCE(OrderRootType.SOURCES), DOC(OrderRootType.DOCUMENTATION);
private final transient OrderRootType myRootType;
LibraryPathType(@NotNull OrderRootType rootType) {
myRootType = rootType;
}
@NotNull
public OrderRootType getRootType() {
return myRootType;
}
BINARY, SOURCE, DOC
}