Use Java 8 lambdas instead of anonymous classes in compiler modules
This commit is contained in:
+12
-24
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.asJava.finder;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
@@ -179,12 +178,7 @@ public class JavaElementFinder extends PsiElementFinder implements KotlinFinderM
|
||||
|
||||
Collection<FqName> subpackages = lightClassGenerationSupport.getSubPackages(packageFQN, scope);
|
||||
|
||||
Collection<PsiPackage> answer = Collections2.transform(subpackages, new Function<FqName, PsiPackage>() {
|
||||
@Override
|
||||
public PsiPackage apply(@Nullable FqName input) {
|
||||
return new KtLightPackage(psiManager, input, scope);
|
||||
}
|
||||
});
|
||||
Collection<PsiPackage> answer = Collections2.transform(subpackages, input -> new KtLightPackage(psiManager, input, scope));
|
||||
|
||||
return answer.toArray(new PsiPackage[answer.size()]);
|
||||
}
|
||||
@@ -219,29 +213,23 @@ public class JavaElementFinder extends PsiElementFinder implements KotlinFinderM
|
||||
@Override
|
||||
@Nullable
|
||||
public Condition<PsiFile> getPackageFilesFilter(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope) {
|
||||
return new Condition<PsiFile>() {
|
||||
@Override
|
||||
public boolean value(PsiFile input) {
|
||||
if (!(input instanceof KtFile)) {
|
||||
return true;
|
||||
}
|
||||
return psiPackage.getQualifiedName().equals(((KtFile) input).getPackageFqName().asString());
|
||||
return input -> {
|
||||
if (!(input instanceof KtFile)) {
|
||||
return true;
|
||||
}
|
||||
return psiPackage.getQualifiedName().equals(((KtFile) input).getPackageFqName().asString());
|
||||
};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Comparator<PsiElement> byClasspathComparator(@NotNull GlobalSearchScope searchScope) {
|
||||
return new Comparator<PsiElement>() {
|
||||
@Override
|
||||
public int compare(@NotNull PsiElement o1, @NotNull PsiElement o2) {
|
||||
VirtualFile f1 = PsiUtilCore.getVirtualFile(o1);
|
||||
VirtualFile f2 = PsiUtilCore.getVirtualFile(o2);
|
||||
if (f1 == f2) return 0;
|
||||
if (f1 == null) return -1;
|
||||
if (f2 == null) return 1;
|
||||
return searchScope.compare(f2, f1);
|
||||
}
|
||||
return (o1, o2) -> {
|
||||
VirtualFile f1 = PsiUtilCore.getVirtualFile(o1);
|
||||
VirtualFile f2 = PsiUtilCore.getVirtualFile(o2);
|
||||
if (f1 == f2) return 0;
|
||||
if (f1 == null) return -1;
|
||||
if (f2 == null) return 1;
|
||||
return searchScope.compare(f2, f1);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user