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