mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Remove unused methods + fix yellow code
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.intellij.analysis;
|
||||
|
||||
import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.codeInsight.daemon.ProblemHighlightFilter;
|
||||
import com.intellij.lang.injection.InjectedLanguageManager;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -168,7 +167,6 @@ public class AnalysisScope {
|
||||
|
||||
@NotNull
|
||||
protected PsiElementVisitor createFileSearcher() {
|
||||
final FileIndex fileIndex = getFileIndex();
|
||||
final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
|
||||
if (indicator != null) {
|
||||
indicator.setText(AnalysisScopeBundle.message("scanning.scope.progress.title"));
|
||||
@@ -180,7 +178,7 @@ public class AnalysisScope {
|
||||
if (mySearchInLibraries || !(file instanceof PsiCompiledElement)) {
|
||||
final VirtualFile virtualFile = file.getVirtualFile();
|
||||
if (virtualFile == null) return;
|
||||
if (isFiltered(virtualFile, fileIndex)) {
|
||||
if (isFiltered(virtualFile)) {
|
||||
return;
|
||||
}
|
||||
if (!shouldHighlightFile(file)) return;
|
||||
@@ -190,7 +188,7 @@ public class AnalysisScope {
|
||||
};
|
||||
}
|
||||
|
||||
private boolean isFiltered(VirtualFile virtualFile, FileIndex fileIndex) {
|
||||
private boolean isFiltered(VirtualFile virtualFile) {
|
||||
if (myFilter != null && !myFilter.contains(virtualFile)) {
|
||||
return true;
|
||||
}
|
||||
@@ -229,7 +227,7 @@ public class AnalysisScope {
|
||||
}
|
||||
if (myType == PROJECT) { //optimization
|
||||
final ProjectFileIndex index = ProjectRootManager.getInstance(myProject).getFileIndex();
|
||||
return index.isInContent(file) && !isFiltered(file, index);
|
||||
return index.isInContent(file) && !isFiltered(file);
|
||||
}
|
||||
initFilesSet();
|
||||
}
|
||||
@@ -282,7 +280,7 @@ public class AnalysisScope {
|
||||
accept(file -> {
|
||||
if (file.isDirectory()) return true;
|
||||
if (ProjectCoreUtil.isProjectOrWorkspaceFile(file)) return true;
|
||||
if (fileIndex.isInContent(file) && !isFiltered(file, fileIndex)
|
||||
if (fileIndex.isInContent(file) && !isFiltered(file)
|
||||
&& !GeneratedSourcesFilter.isGeneratedSourceByAnyFilter(file, myProject)) {
|
||||
return processFile(file, visitor, psiManager, needReadAction, clearResolveCache);
|
||||
}
|
||||
@@ -293,16 +291,15 @@ public class AnalysisScope {
|
||||
public boolean accept(@NotNull final Processor<VirtualFile> processor) {
|
||||
if (myType == VIRTUAL_FILES) {
|
||||
if (myFilesSet == null) initFilesSet();
|
||||
final FileIndex index = ProjectRootManager.getInstance(myProject).getFileIndex();
|
||||
for (final VirtualFile file : myFilesSet) {
|
||||
if (isFiltered(file, index)) continue;
|
||||
if (isFiltered(file)) continue;
|
||||
if (!processor.process(file)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
final FileIndex projectFileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
|
||||
if (myScope instanceof GlobalSearchScope) {
|
||||
final ContentIterator contentIterator = createScopeIterator(processor, projectFileIndex, myScope);
|
||||
final ContentIterator contentIterator = createScopeIterator(processor, myScope);
|
||||
if (!projectFileIndex.iterateContent(contentIterator)) return false;
|
||||
if (mySearchInLibraries) {
|
||||
final VirtualFile[] libraryRoots = LibraryUtil.getLibraryRoots(myProject, false, false);
|
||||
@@ -332,7 +329,7 @@ public class AnalysisScope {
|
||||
if (modules != null) {
|
||||
for (final Module module : modules) {
|
||||
final FileIndex moduleFileIndex = ModuleRootManager.getInstance(module).getFileIndex();
|
||||
if (!moduleFileIndex.iterateContent(createScopeIterator(processor, moduleFileIndex, null))) {
|
||||
if (!moduleFileIndex.iterateContent(createScopeIterator(processor, null))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -352,12 +349,11 @@ public class AnalysisScope {
|
||||
return file == null || processor.process(file);
|
||||
}
|
||||
|
||||
return projectFileIndex.iterateContent(createScopeIterator(processor, projectFileIndex, null));
|
||||
return projectFileIndex.iterateContent(createScopeIterator(processor, null));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private ContentIterator createScopeIterator(@NotNull final Processor<VirtualFile> processor,
|
||||
@NotNull final FileIndex projectFileIndex,
|
||||
private ContentIterator createScopeIterator(@NotNull final Processor<VirtualFile> processor,
|
||||
@Nullable final SearchScope searchScope) {
|
||||
return new ContentIterator() {
|
||||
@Override
|
||||
@@ -365,7 +361,7 @@ public class AnalysisScope {
|
||||
final boolean isInScope = ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
|
||||
@Override
|
||||
public Boolean compute() {
|
||||
if (isFiltered(fileOrDir, projectFileIndex)) return false;
|
||||
if (isFiltered(fileOrDir)) return false;
|
||||
if (GeneratedSourcesFilter.isGeneratedSourceByAnyFilter(fileOrDir, myProject)) return false;
|
||||
return searchScope == null || ((GlobalSearchScope)searchScope).contains(fileOrDir);
|
||||
}
|
||||
@@ -439,14 +435,13 @@ public class AnalysisScope {
|
||||
|
||||
protected boolean accept(@NotNull final PsiDirectory dir, @NotNull final Processor<VirtualFile> processor) {
|
||||
final Project project = dir.getProject();
|
||||
final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
|
||||
//we should analyze generated source files only if the action is explicitly invoked for a directory located under generated roots
|
||||
final boolean processGeneratedFiles = GeneratedSourcesFilter.isGeneratedSourceByAnyFilter(dir.getVirtualFile(), project);
|
||||
return VfsUtilCore.iterateChildrenRecursively(dir.getVirtualFile(), VirtualFileFilter.ALL, new ContentIterator() {
|
||||
@Override
|
||||
@SuppressWarnings({"SimplifiableIfStatement"})
|
||||
public boolean processFile(@NotNull final VirtualFile fileOrDir) {
|
||||
if (isFiltered(fileOrDir, index)) return true;
|
||||
if (isFiltered(fileOrDir)) return true;
|
||||
if (!processGeneratedFiles && GeneratedSourcesFilter.isGeneratedSourceByAnyFilter(fileOrDir, project)) return true;
|
||||
if (!fileOrDir.isDirectory()) {
|
||||
return processor.process(fileOrDir);
|
||||
@@ -560,15 +555,6 @@ public class AnalysisScope {
|
||||
return myFilesSet.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* scope elements should be checked only when needed
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean checkScopeWritable(@NotNull Project project) {
|
||||
if (myFilesSet == null) initFilesSet();
|
||||
return !FileModificationService.getInstance().prepareVirtualFilesForWrite(project, myFilesSet);
|
||||
}
|
||||
|
||||
public void invalidate(){
|
||||
if (myType == VIRTUAL_FILES) {
|
||||
for (Iterator<VirtualFile> i = myVFiles.iterator(); i.hasNext();) {
|
||||
|
||||
+1
-2
@@ -74,8 +74,7 @@ public class BackwardDependenciesBuilder extends DependenciesBuilder {
|
||||
|
||||
@Override
|
||||
public void analyze() {
|
||||
AnalysisScope scope = myForwardScope;
|
||||
final DependenciesBuilder builder = new ForwardDependenciesBuilder(getProject(), scope, getScopeOfInterest());
|
||||
final DependenciesBuilder builder = new ForwardDependenciesBuilder(getProject(), myForwardScope, getScopeOfInterest());
|
||||
builder.setTotalFileCount(myTotalFileCount);
|
||||
builder.analyze();
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.openapi.roots.impl.DirectoryIndex;
|
||||
import com.intellij.openapi.roots.ui.configuration.CommonContentEntriesEditor;
|
||||
import com.intellij.openapi.roots.ui.configuration.ProjectSettingsService;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -94,7 +95,7 @@ public class PlatformPackageUtil {
|
||||
boolean askUserToCreate,
|
||||
ThreeState chooseFlag) throws IncorrectOperationException {
|
||||
PsiDirectory psiDirectory = null;
|
||||
if (chooseFlag == ThreeState.UNSURE && !"".equals(packageName)) {
|
||||
if (chooseFlag == ThreeState.UNSURE && StringUtil.isNotEmpty(packageName)) {
|
||||
String rootPackage = findLongestExistingPackage(project, packageName, scope);
|
||||
if (rootPackage != null) {
|
||||
int beginIndex = rootPackage.length() + 1;
|
||||
@@ -112,7 +113,7 @@ public class PlatformPackageUtil {
|
||||
if (psiDirectory == null) {
|
||||
if (chooseFlag == ThreeState.NO && baseDir != null) {
|
||||
VirtualFile sourceRoot = ProjectRootManager.getInstance(project).getFileIndex().getSourceRootForFile(baseDir.getVirtualFile());
|
||||
psiDirectory = PsiManager.getInstance(project).findDirectory(sourceRoot);
|
||||
psiDirectory = sourceRoot != null ? PsiManager.getInstance(project).findDirectory(sourceRoot) : null;
|
||||
}
|
||||
else {
|
||||
if (module != null && !checkSourceRootsConfigured(module)) return null;
|
||||
@@ -125,7 +126,7 @@ public class PlatformPackageUtil {
|
||||
File.separatorChar + packageName.replace('.', File.separatorChar));
|
||||
if (psiDirectory == null) return null;
|
||||
final VirtualFile sourceRoot = ProjectRootManager.getInstance(project).getFileIndex().getSourceRootForFile(psiDirectory.getVirtualFile());
|
||||
psiDirectory = PsiManager.getInstance(project).findDirectory(sourceRoot);
|
||||
psiDirectory = sourceRoot != null ? PsiManager.getInstance(project).findDirectory(sourceRoot) : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +134,7 @@ public class PlatformPackageUtil {
|
||||
boolean askedToCreate = false;
|
||||
while (restOfName.length() > 0) {
|
||||
final String name = getLeftPart(restOfName);
|
||||
PsiDirectory foundExistingDirectory = psiDirectory.findSubdirectory(name);
|
||||
PsiDirectory foundExistingDirectory = psiDirectory != null ? psiDirectory.findSubdirectory(name) : null;
|
||||
if (foundExistingDirectory == null) {
|
||||
if (!askedToCreate && askUserToCreate) {
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
@@ -153,7 +154,7 @@ public class PlatformPackageUtil {
|
||||
psiDirectory = ActionRunner.runInsideWriteAction(new ActionRunner.InterruptibleRunnableWithResult<PsiDirectory>() {
|
||||
@Override
|
||||
public PsiDirectory run() throws Exception {
|
||||
return psiDirectory_.createSubdirectory(name);
|
||||
return psiDirectory_ != null ? psiDirectory_.createSubdirectory(name) : null;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -198,9 +199,9 @@ public class PlatformPackageUtil {
|
||||
final PsiManager manager = PsiManager.getInstance(project);
|
||||
|
||||
Query<VirtualFile> query = DirectoryIndex.getInstance(scope.getProject()).getDirectoriesByPackageName(rootPackage, true);
|
||||
query = new FilteredQuery<VirtualFile>(query, virtualFile -> scope.contains(virtualFile));
|
||||
query = new FilteredQuery<VirtualFile>(query, scope::contains);
|
||||
|
||||
List<PsiDirectory> directories = ContainerUtil.mapNotNull(query.findAll(), virtualFile -> manager.findDirectory(virtualFile));
|
||||
List<PsiDirectory> directories = ContainerUtil.mapNotNull(query.findAll(), manager::findDirectory);
|
||||
return directories.toArray(new PsiDirectory[directories.size()]);
|
||||
}
|
||||
|
||||
@@ -234,31 +235,6 @@ public class PlatformPackageUtil {
|
||||
return index > -1 ? packageName.substring(index + 1) : "";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiDirectory findPossiblePackageDirectoryInModule(Module module, GlobalSearchScope scope, String packageName) {
|
||||
if (!"".equals(packageName)) {
|
||||
String rootPackage = findLongestExistingPackage(module.getProject(), packageName, scope);
|
||||
if (rootPackage != null) {
|
||||
final PsiDirectory[] psiDirectories = getPackageDirectories(module.getProject(), rootPackage, scope);
|
||||
if (psiDirectories.length > 0) {
|
||||
return psiDirectories[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!checkSourceRootsConfigured(module)) return null;
|
||||
|
||||
final VirtualFile[] sourceRoots = ModuleRootManager.getInstance(module).getSourceRoots();
|
||||
for (VirtualFile sourceRoot : sourceRoots) {
|
||||
final PsiDirectory directory = PsiManager.getInstance(module.getProject()).findDirectory(sourceRoot);
|
||||
if (directory != null) {
|
||||
return directory;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiDirectory getDirectory(@Nullable PsiElement element) {
|
||||
if (element == null) return null;
|
||||
|
||||
Reference in New Issue
Block a user