@@ -0,0 +1,2463 @@
+/*%0A * Copyright 2000-2015 JetBrains s.r.o.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.intellij.psi.util;%0A%0Aimport java.util.Collection;%0Aimport java.util.Collections;%0Aimport java.util.Set;%0A%0Aimport org.jetbrains.annotations.NonNls;%0Aimport org.jetbrains.annotations.NotNull;%0Aimport com.intellij.openapi.module.Module;%0Aimport com.intellij.openapi.project.Project;%0Aimport com.intellij.openapi.roots.OrderEntry;%0Aimport com.intellij.openapi.roots.ProjectFileIndex;%0Aimport com.intellij.openapi.roots.ProjectRootManager;%0Aimport com.intellij.openapi.vfs.VirtualFile;%0Aimport com.intellij.psi.JavaPsiFacade;%0Aimport com.intellij.psi.PsiClass;%0Aimport com.intellij.psi.search.GlobalSearchScope;%0Aimport com.intellij.util.containers.ContainerUtil;%0A%0Apublic class FindClassUtil%0A%7B%0A%09/**%0A%09 * Searches the project for modules that contain the class with the specified full-qualified name within%0A%09 * the module dependencies or libraries.%0A%09 *%0A%09 * @param qualifiedName the full-qualified name of the class to find.%0A%09 * @return the modules that contain the given class in dependencies or libraries.%0A%09 */%0A%09@NotNull%0A%09public static Collection%3CModule%3E findModulesWithClass(@NotNull Project project, @NonNls @NotNull String qualifiedName)%0A%09%7B%0A%09%09GlobalSearchScope allScope = GlobalSearchScope.allScope(project);%0A%09%09JavaPsiFacade facade = JavaPsiFacade.getInstance(project);%0A%09%09PsiClass%5B%5D possibleClasses = facade.findClasses(qualifiedName, allScope);%0A%09%09if(possibleClasses.length == 0)%0A%09%09%7B%0A%09%09%09return Collections.emptyList();%0A%09%09%7D%0A%09%09Set%3CModule%3E relevantModules = ContainerUtil.newLinkedHashSet();%0A%09%09ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();%0A%09%09for(PsiClass aClass : possibleClasses)%0A%09%09%7B%0A%09%09%09VirtualFile classFile = aClass.getContainingFile().getVirtualFile();%0A%09%09%09for(OrderEntry orderEntry : fileIndex.getOrderEntriesForFile(classFile))%0A%09%09%09%7B%0A%09%09%09%09relevantModules.add(orderEntry.getOwnerModule());%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return relevantModules;%0A%09%7D%0A%7D%0A

add FindClassUtil