Function object replaced by a normal function

This commit is contained in:
Andrey Breslav
2014-04-08 18:24:24 +04:00
parent 54d3f6df19
commit ebd44816d0
3 changed files with 8 additions and 20 deletions
@@ -34,30 +34,18 @@ public abstract class JetFilesProvider {
return ServiceManager.getService(project, JetFilesProvider.class); return ServiceManager.getService(project, JetFilesProvider.class);
} }
public final Function<JetFile, Collection<JetFile>> allPackageFiles() { public final Collection<JetFile> allPackageFiles(@NotNull JetFile file) {
return new Function<JetFile, Collection<JetFile>>() { final FqName name = file.getPackageFqName();
return Collections2.filter(sampleToAllFilesInModule().fun(file), new Predicate<PsiFile>() {
@Override @Override
public Collection<JetFile> fun(JetFile file) { public boolean apply(PsiFile psiFile) {
return Collections2.filter(sampleToAllFilesInModule().fun(file), new SameJetFilePredicate(file)); return ((JetFile) psiFile).getPackageFqName().equals(name);
} }
}; });
} }
public abstract Function<JetFile, Collection<JetFile>> sampleToAllFilesInModule(); public abstract Function<JetFile, Collection<JetFile>> sampleToAllFilesInModule();
@NotNull @NotNull
public abstract Collection<JetFile> allInScope(@NotNull GlobalSearchScope scope); public abstract Collection<JetFile> allInScope(@NotNull GlobalSearchScope scope);
public abstract boolean isFileInScope(@NotNull JetFile file, @NotNull GlobalSearchScope scope); public abstract boolean isFileInScope(@NotNull JetFile file, @NotNull GlobalSearchScope scope);
public static class SameJetFilePredicate implements Predicate<PsiFile> {
private final FqName name;
public SameJetFilePredicate(JetFile file) {
this.name = file.getPackageFqName();
}
@Override
public boolean apply(PsiFile psiFile) {
return ((JetFile) psiFile).getPackageFqName().equals(name);
}
}
} }
@@ -199,7 +199,7 @@ public class JetPositionManager implements PositionManager {
AnalyzeExhaust analyzeExhaust = AnalyzerFacadeWithCache.analyzeFileWithCache(file); AnalyzeExhaust analyzeExhaust = AnalyzerFacadeWithCache.analyzeFileWithCache(file);
analyzeExhaust.throwIfError(); analyzeExhaust.throwIfError();
Collection<JetFile> packageFiles = JetFilesProvider.getInstance(file.getProject()).allPackageFiles().fun(file); Collection<JetFile> packageFiles = JetFilesProvider.getInstance(file.getProject()).allPackageFiles(file);
DelegatingBindingTrace bindingTrace = new DelegatingBindingTrace(analyzeExhaust.getBindingContext(), "trace created in JetPositionManager"); DelegatingBindingTrace bindingTrace = new DelegatingBindingTrace(analyzeExhaust.getBindingContext(), "trace created in JetPositionManager");
JetTypeMapper typeMapper = new JetTypeMapper(bindingTrace, ClassBuilderMode.FULL); JetTypeMapper typeMapper = new JetTypeMapper(bindingTrace, ClassBuilderMode.FULL);
@@ -63,7 +63,7 @@ public class DebuggerUtils {
return anyFile; return anyFile;
} }
Collection<JetFile> allPackageFiles = filesProvider.allPackageFiles().fun(anyFile); Collection<JetFile> allPackageFiles = filesProvider.allPackageFiles(anyFile);
JetFile file = PsiCodegenPredictor.getFileForPackagePartName(allPackageFiles, className); JetFile file = PsiCodegenPredictor.getFileForPackagePartName(allPackageFiles, className);
if (file != null) { if (file != null) {
return file; return file;