From 3ad72015bffeca3956f3785c8b96f475a69c7d20 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Thu, 23 Aug 2012 18:52:48 +0400 Subject: [PATCH] Stop using deprecated method --- .../JavaAPIUsagesInspectionTest.java | 22 +++++++++++++++++-- .../com/intellij/analysis/AnalysisScope.java | 6 ++--- .../intellij/find/impl/FindInProjectUtil.java | 18 ++++++++------- .../openapi/roots/impl/FileIndexImplUtil.java | 5 +++++ .../roots/impl/ModuleFileIndexImpl.java | 5 +++-- .../roots/impl/ProjectFileIndexImpl.java | 5 +++-- .../vcs/actions/CommonCheckinFilesAction.java | 6 ++--- 7 files changed, 47 insertions(+), 20 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/JavaAPIUsagesInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/JavaAPIUsagesInspectionTest.java index cebf9a0d346b..d93b6ff8b0db 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/JavaAPIUsagesInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/JavaAPIUsagesInspectionTest.java @@ -1,3 +1,19 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /* * User: anna * Date: 11-Sep-2007 @@ -8,9 +24,9 @@ import com.intellij.JavaTestUtil; import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; import com.intellij.codeInspection.java15api.Java15APIUsageInspection; import com.intellij.openapi.roots.ContentIterator; -import com.intellij.openapi.roots.impl.FileIndexImplUtil; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.vfs.JarFileSystem; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileFilter; import com.intellij.pom.java.LanguageLevel; @@ -45,6 +61,7 @@ public class JavaAPIUsagesInspectionTest extends InspectionTestCase { doTest(); } + @SuppressWarnings("UnusedDeclaration") public void _testCollectSinceApiUsages() { final String version = "1.4"; final ContentIterator contentIterator = new ContentIterator() { @@ -77,6 +94,7 @@ public class JavaAPIUsagesInspectionTest extends InspectionTestCase { } }; final VirtualFile srcFile = JarFileSystem.getInstance().findFileByPath("c:/program files/java/jdk1.6.0_12/src.zip!/"); - FileIndexImplUtil.iterateRecursively(srcFile, VirtualFileFilter.ALL, contentIterator); + assert srcFile != null; + VfsUtilCore.iterateChildrenRecursively(srcFile, VirtualFileFilter.ALL, contentIterator); } } diff --git a/platform/lang-api/src/com/intellij/analysis/AnalysisScope.java b/platform/lang-api/src/com/intellij/analysis/AnalysisScope.java index a1c765404cb4..5d2ba0741dd7 100644 --- a/platform/lang-api/src/com/intellij/analysis/AnalysisScope.java +++ b/platform/lang-api/src/com/intellij/analysis/AnalysisScope.java @@ -29,12 +29,12 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectCoreUtil; import com.intellij.openapi.project.ProjectUtil; import com.intellij.openapi.roots.*; -import com.intellij.openapi.roots.impl.FileIndexImplUtil; import com.intellij.openapi.roots.libraries.LibraryUtil; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.ReadonlyStatusHandler; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileFilter; import com.intellij.profile.ProjectProfileManager; @@ -269,7 +269,7 @@ public class AnalysisScope { if (mySearchInLibraries) { final VirtualFile[] libraryRoots = LibraryUtil.getLibraryRoots(myProject, false, false); for (VirtualFile libraryRoot : libraryRoots) { - FileIndexImplUtil.iterateRecursively(libraryRoot, VirtualFileFilter.ALL, contentIterator); + VfsUtilCore.iterateChildrenRecursively(libraryRoot, VirtualFileFilter.ALL, contentIterator); } } } @@ -396,7 +396,7 @@ public class AnalysisScope { final Project project = dir.getProject(); final PsiManager psiManager = PsiManager.getInstance(project); final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex(); - FileIndexImplUtil.iterateRecursively(dir.getVirtualFile(), VirtualFileFilter.ALL, new ContentIterator() { + VfsUtilCore.iterateChildrenRecursively(dir.getVirtualFile(), VirtualFileFilter.ALL, new ContentIterator() { @Override @SuppressWarnings({"SimplifiableIfStatement"}) public boolean processFile(@NotNull final VirtualFile fileOrDir) { diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindInProjectUtil.java b/platform/lang-impl/src/com/intellij/find/impl/FindInProjectUtil.java index a5445696ec3f..10773fe818d3 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/FindInProjectUtil.java +++ b/platform/lang-impl/src/com/intellij/find/impl/FindInProjectUtil.java @@ -34,9 +34,11 @@ import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; -import com.intellij.openapi.project.*; +import com.intellij.openapi.project.DumbService; +import com.intellij.openapi.project.IndexNotReadyException; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.project.ProjectCoreUtil; import com.intellij.openapi.roots.*; -import com.intellij.openapi.roots.impl.FileIndexImplUtil; import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Factory; @@ -45,17 +47,17 @@ import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.util.text.TrigramBuilder; -import com.intellij.openapi.vfs.JarFileSystem; -import com.intellij.openapi.vfs.LocalFileSystem; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.openapi.vfs.VirtualFileFilter; +import com.intellij.openapi.vfs.*; import com.intellij.openapi.wm.ToolWindowId; import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.psi.*; import com.intellij.psi.impl.cache.CacheManager; import com.intellij.psi.search.*; import com.intellij.usageView.UsageInfo; -import com.intellij.usages.*; +import com.intellij.usages.FindUsagesProcessPresentation; +import com.intellij.usages.UsageLimitUtil; +import com.intellij.usages.UsageTarget; +import com.intellij.usages.UsageViewPresentation; import com.intellij.util.CommonProcessors; import com.intellij.util.Function; import com.intellij.util.PatternUtil; @@ -454,7 +456,7 @@ public class FindInProjectUtil { } }; for (VirtualFile file : files) { - if (!FileIndexImplUtil.iterateRecursively(file, contentFilter, iterator)) return false; + if (!VfsUtilCore.iterateChildrenRecursively(file, contentFilter, iterator)) return false; } return true; } diff --git a/platform/projectModel-api/src/com/intellij/openapi/roots/impl/FileIndexImplUtil.java b/platform/projectModel-api/src/com/intellij/openapi/roots/impl/FileIndexImplUtil.java index 37f29516e495..ac0782588a69 100644 --- a/platform/projectModel-api/src/com/intellij/openapi/roots/impl/FileIndexImplUtil.java +++ b/platform/projectModel-api/src/com/intellij/openapi/roots/impl/FileIndexImplUtil.java @@ -21,9 +21,14 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileFilter; import org.jetbrains.annotations.NotNull; +@SuppressWarnings("UnusedDeclaration") public class FileIndexImplUtil { private FileIndexImplUtil() { } + /** + * @deprecated use {@linkplain VfsUtilCore#iterateChildrenRecursively(com.intellij.openapi.vfs.VirtualFile, + * com.intellij.openapi.vfs.VirtualFileFilter, com.intellij.openapi.roots.ContentIterator)} (to remove in IDEA 13) + */ public static boolean iterateRecursively(@NotNull final VirtualFile root, @NotNull final VirtualFileFilter filter, @NotNull final ContentIterator iterator) { diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleFileIndexImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleFileIndexImpl.java index 1697af20ac88..b3b0db77914a 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleFileIndexImpl.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleFileIndexImpl.java @@ -23,6 +23,7 @@ import com.intellij.openapi.roots.ContentIterator; import com.intellij.openapi.roots.ModuleFileIndex; import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.roots.OrderEntry; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileFilter; import com.intellij.util.SmartList; @@ -57,7 +58,7 @@ public class ModuleFileIndexImpl implements ModuleFileIndex { if (parentInfo != null && myModule.equals(parentInfo.module)) continue; // inner content - skip it } - boolean finished = FileIndexImplUtil.iterateRecursively(contentRoot, myContentFilter, iterator); + boolean finished = VfsUtilCore.iterateChildrenRecursively(contentRoot, myContentFilter, iterator); if (!finished) return false; } @@ -66,7 +67,7 @@ public class ModuleFileIndexImpl implements ModuleFileIndex { @Override public boolean iterateContentUnderDirectory(@NotNull VirtualFile dir, @NotNull ContentIterator iterator) { - return FileIndexImplUtil.iterateRecursively(dir, myContentFilter, iterator); + return VfsUtilCore.iterateChildrenRecursively(dir, myContentFilter, iterator); } @Override diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ProjectFileIndexImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ProjectFileIndexImpl.java index d18cb38b96c4..f49f4df48fb0 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ProjectFileIndexImpl.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ProjectFileIndexImpl.java @@ -27,6 +27,7 @@ import com.intellij.openapi.roots.ContentIterator; import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.roots.OrderEntry; import com.intellij.openapi.roots.ProjectFileIndex; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileFilter; import org.jetbrains.annotations.NotNull; @@ -67,7 +68,7 @@ public class ProjectFileIndexImpl implements ProjectFileIndex { if (parentInfo != null && parentInfo.module != null) continue; // inner content - skip it } - boolean finished = FileIndexImplUtil.iterateRecursively(contentRoot, myContentFilter, iterator); + boolean finished = VfsUtilCore.iterateChildrenRecursively(contentRoot, myContentFilter, iterator); if (!finished) return false; } } @@ -85,7 +86,7 @@ public class ProjectFileIndexImpl implements ProjectFileIndex { } public boolean iterateContentUnderDirectory(@NotNull VirtualFile dir, @NotNull ContentIterator iterator) { - return FileIndexImplUtil.iterateRecursively(dir, myContentFilter, iterator); + return VfsUtilCore.iterateChildrenRecursively(dir, myContentFilter, iterator); } public boolean isIgnored(@NotNull VirtualFile file) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/CommonCheckinFilesAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/CommonCheckinFilesAction.java index 070e617793cd..ae2c9d342b35 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/CommonCheckinFilesAction.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/CommonCheckinFilesAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ContentIterator; import com.intellij.openapi.roots.FileIndexFacade; -import com.intellij.openapi.roots.impl.FileIndexImplUtil; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Ref; import com.intellij.openapi.vcs.*; @@ -28,6 +27,7 @@ import com.intellij.openapi.vcs.changes.Change; import com.intellij.openapi.vcs.changes.ChangeListManager; import com.intellij.openapi.vcs.changes.LocalChangeList; import com.intellij.openapi.vcs.checkin.CheckinEnvironment; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileFilter; @@ -88,7 +88,7 @@ public class CommonCheckinFilesAction extends AbstractCommonCheckinAction { }); } }; - FileIndexImplUtil.iterateRecursively(file, filter, new ContentIterator() { + VfsUtilCore.iterateChildrenRecursively(file, filter, new ContentIterator() { public boolean processFile(final VirtualFile fileOrDir) { final Change c = changeListManager.getChange(fileOrDir); if (c != null) {