api corrected

This commit is contained in:
nik
2010-07-07 16:08:20 +04:00
parent 49b9b10fc7
commit 1a5d43b980
5 changed files with 48 additions and 47 deletions
@@ -24,7 +24,9 @@ import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.*;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.encoding.EncodingProjectManager;
import com.intellij.util.NotNullFunction;
import com.intellij.util.PairFunction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.nio.charset.Charset;
@@ -65,20 +67,19 @@ public class JavaParameters extends SimpleJavaParameters {
}
setDefaultCharset(module.getProject());
final PairFunction<OrderEntry, OrderRootType, VirtualFile[]> substitutor = computeSubstitutor(classPathType, jdk);
configureEnumerator(OrderEnumerator.orderEntries(module).runtimeOnly().recursively().substituteFiles(substitutor)
, classPathType).classes().collectPaths(getClassPath());
configureEnumerator(OrderEnumerator.orderEntries(module).runtimeOnly().recursively(), classPathType, jdk).collectPaths(getClassPath());
}
@Nullable
private static PairFunction<OrderEntry, OrderRootType, VirtualFile[]> computeSubstitutor(int classPathType, final Sdk jdk) {
return (classPathType & JDK_ONLY) == 0 ? null : new PairFunction<OrderEntry, OrderRootType, VirtualFile[]>() {
@Override
public VirtualFile[] fun(OrderEntry orderEntry, OrderRootType orderRootType) {
private static NotNullFunction<OrderEntry, VirtualFile[]> computeRootProvider(int classPathType, final Sdk jdk) {
return (classPathType & JDK_ONLY) == 0 ? null : new NotNullFunction<OrderEntry, VirtualFile[]>() {
@NotNull
@Override
public VirtualFile[] fun(OrderEntry orderEntry) {
if (orderEntry instanceof JdkOrderEntry) {
return jdk.getRootProvider().getFiles(orderRootType);
return jdk.getRootProvider().getFiles(OrderRootType.CLASSES);
}
return orderEntry.getFiles(orderRootType);
return orderEntry.getFiles(OrderRootType.CLASSES);
}
};
}
@@ -117,17 +118,21 @@ public class JavaParameters extends SimpleJavaParameters {
if ((classPathType & CLASSES_ONLY) == 0) {
return;
}
final PairFunction<OrderEntry, OrderRootType, VirtualFile[]> substitutor = computeSubstitutor(classPathType, jdk);
configureEnumerator(OrderEnumerator.orderEntries(project).runtimeOnly().substituteFiles(substitutor), classPathType).classes().collectPaths(getClassPath());
configureEnumerator(OrderEnumerator.orderEntries(project).runtimeOnly(), classPathType, jdk).collectPaths(getClassPath());
}
private static OrderEnumerator configureEnumerator(OrderEnumerator enumerator, int classPathType) {
private static OrderRootsEnumerator configureEnumerator(OrderEnumerator enumerator, int classPathType, Sdk jdk) {
if ((classPathType & JDK_ONLY) == 0) {
enumerator = enumerator.withoutSdk();
}
if ((classPathType & TESTS_ONLY) == 0) {
enumerator = enumerator.productionOnly();
}
return enumerator;
OrderRootsEnumerator rootsEnumerator = enumerator.classes();
final NotNullFunction<OrderEntry, VirtualFile[]> provider = computeRootProvider(classPathType, jdk);
if (provider != null) {
rootsEnumerator = rootsEnumerator.usingCustomRootProvider(provider);
}
return rootsEnumerator;
}
}