Function object replaced by a normal function
+ unneededly public member made protected
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.jet.cli.jvm.compiler;
|
||||
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.util.Function;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.java.JetFilesProvider;
|
||||
@@ -28,21 +27,14 @@ import java.util.List;
|
||||
|
||||
public class CliJetFilesProvider extends JetFilesProvider {
|
||||
private final JetCoreEnvironment environment;
|
||||
private final Function<JetFile,Collection<JetFile>> allFiles = new Function<JetFile, Collection<JetFile>>() {
|
||||
@Override
|
||||
public Collection<JetFile> fun(JetFile file) {
|
||||
return environment.getSourceFiles();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public CliJetFilesProvider(JetCoreEnvironment environment) {
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Function<JetFile, Collection<JetFile>> sampleToAllFilesInModule() {
|
||||
return allFiles;
|
||||
protected Collection<JetFile> sampleToAllFilesInModule(@NotNull JetFile file) {
|
||||
return environment.getSourceFiles();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+2
-3
@@ -22,7 +22,6 @@ import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.util.Function;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
@@ -36,7 +35,7 @@ public abstract class JetFilesProvider {
|
||||
|
||||
public final Collection<JetFile> allPackageFiles(@NotNull JetFile file) {
|
||||
final FqName name = file.getPackageFqName();
|
||||
return Collections2.filter(sampleToAllFilesInModule().fun(file), new Predicate<PsiFile>() {
|
||||
return Collections2.filter(sampleToAllFilesInModule(file), new Predicate<PsiFile>() {
|
||||
@Override
|
||||
public boolean apply(PsiFile psiFile) {
|
||||
return ((JetFile) psiFile).getPackageFqName().equals(name);
|
||||
@@ -44,7 +43,7 @@ public abstract class JetFilesProvider {
|
||||
});
|
||||
}
|
||||
|
||||
public abstract Function<JetFile, Collection<JetFile>> sampleToAllFilesInModule();
|
||||
protected abstract Collection<JetFile> sampleToAllFilesInModule(@NotNull JetFile file);
|
||||
@NotNull
|
||||
public abstract Collection<JetFile> allInScope(@NotNull GlobalSearchScope scope);
|
||||
public abstract boolean isFileInScope(@NotNull JetFile file, @NotNull GlobalSearchScope scope);
|
||||
|
||||
@@ -67,49 +67,45 @@ public class PluginJetFilesProvider extends JetFilesProvider {
|
||||
);
|
||||
}
|
||||
|
||||
public static final Function<JetFile, Collection<JetFile>> WHOLE_PROJECT_DECLARATION_PROVIDER = new Function<JetFile, Collection<JetFile>>() {
|
||||
public static Collection<JetFile> allFilesInProject(@NotNull final JetFile rootFile) {
|
||||
final Project project = rootFile.getProject();
|
||||
final Set<JetFile> files = Sets.newLinkedHashSet();
|
||||
|
||||
@Override
|
||||
public Collection<JetFile> fun(final JetFile rootFile) {
|
||||
final Project project = rootFile.getProject();
|
||||
final Set<JetFile> files = Sets.newLinkedHashSet();
|
||||
Module rootModule = ModuleUtil.findModuleForPsiElement(rootFile);
|
||||
if (rootModule != null) {
|
||||
Set<Module> allModules = new HashSet<Module>();
|
||||
ModuleUtil.getDependencies(rootModule, allModules);
|
||||
|
||||
Module rootModule = ModuleUtil.findModuleForPsiElement(rootFile);
|
||||
if (rootModule != null) {
|
||||
Set<Module> allModules = new HashSet<Module>();
|
||||
ModuleUtil.getDependencies(rootModule, allModules);
|
||||
for (Module module : allModules) {
|
||||
final ModuleFileIndex index = ModuleRootManager.getInstance(module).getFileIndex();
|
||||
index.iterateContent(new ContentIterator() {
|
||||
@Override
|
||||
public boolean processFile(VirtualFile file) {
|
||||
if (file.isDirectory()) return true;
|
||||
if (!index.isInSourceContent(file) && !index.isInTestSourceContent(file)) return true;
|
||||
if (JetPluginUtil.isKtFileInGradleProjectInWrongFolder(file, project)) return true;
|
||||
|
||||
for (Module module : allModules) {
|
||||
final ModuleFileIndex index = ModuleRootManager.getInstance(module).getFileIndex();
|
||||
index.iterateContent(new ContentIterator() {
|
||||
@Override
|
||||
public boolean processFile(VirtualFile file) {
|
||||
if (file.isDirectory()) return true;
|
||||
if (!index.isInSourceContent(file) && !index.isInTestSourceContent(file)) return true;
|
||||
if (JetPluginUtil.isKtFileInGradleProjectInWrongFolder(file, project)) return true;
|
||||
|
||||
FileType fileType = FileTypeManager.getInstance().getFileTypeByFile(file);
|
||||
if (fileType != JetFileType.INSTANCE) return true;
|
||||
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
|
||||
if (psiFile instanceof JetFile) {
|
||||
if (rootFile.getOriginalFile() != psiFile) {
|
||||
files.add((JetFile) psiFile);
|
||||
}
|
||||
FileType fileType = FileTypeManager.getInstance().getFileTypeByFile(file);
|
||||
if (fileType != JetFileType.INSTANCE) return true;
|
||||
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
|
||||
if (psiFile instanceof JetFile) {
|
||||
if (rootFile.getOriginalFile() != psiFile) {
|
||||
files.add((JetFile) psiFile);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
files.add(rootFile);
|
||||
return files;
|
||||
}
|
||||
};
|
||||
|
||||
files.add(rootFile);
|
||||
return files;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Function<JetFile, Collection<JetFile>> sampleToAllFilesInModule() {
|
||||
return WHOLE_PROJECT_DECLARATION_PROVIDER;
|
||||
protected Collection<JetFile> sampleToAllFilesInModule(@NotNull JetFile file) {
|
||||
return allFilesInProject(file);
|
||||
}
|
||||
|
||||
private boolean isKotlinSourceVirtualFile(@NotNull VirtualFile virtualFile) {
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ public class AddOverrideToEqualsHashCodeToStringFix extends JetIntentionAction<P
|
||||
|
||||
@Override
|
||||
protected void invoke(@NotNull Project project, Editor editor, JetFile file) throws IncorrectOperationException {
|
||||
Collection<JetFile> files = PluginJetFilesProvider.WHOLE_PROJECT_DECLARATION_PROVIDER.fun(file);
|
||||
Collection<JetFile> files = PluginJetFilesProvider.allFilesInProject(file);
|
||||
|
||||
AnalyzeExhaust analyzeExhaust = MigrateSureInProjectFix.analyzeFiles(file, files);
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ public class MigrateSureInProjectFix extends JetIntentionAction<PsiElement> {
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, JetFile file) throws IncorrectOperationException {
|
||||
Collection<JetFile> files = PluginJetFilesProvider.WHOLE_PROJECT_DECLARATION_PROVIDER.fun(file);
|
||||
Collection<JetFile> files = PluginJetFilesProvider.allFilesInProject(file);
|
||||
|
||||
AnalyzeExhaust analyzeExhaust = analyzeFiles(file, files);
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public class RemoveValVarFromParametersFix implements IntentionAction {
|
||||
// TODO after M6, this quick fix should remove val/var only for current parameter
|
||||
|
||||
JetFile initialFile = (JetFile) file;
|
||||
Collection<JetFile> files = PluginJetFilesProvider.WHOLE_PROJECT_DECLARATION_PROVIDER.fun(initialFile);
|
||||
Collection<JetFile> files = PluginJetFilesProvider.allFilesInProject(initialFile);
|
||||
for (JetFile jetFile : files) {
|
||||
jetFile.acceptChildren(new JetVisitorVoid() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user