Search in sources :

Example 26 with HashMap

use of com.intellij.util.containers.HashMap in project intellij-community by JetBrains.

the class JavaPullUpHelper method buildConstructorsToSubConstructorsMap.

private HashMap<PsiMethod, HashSet<PsiMethod>> buildConstructorsToSubConstructorsMap(final PsiMethod[] constructors) {
    final HashMap<PsiMethod, HashSet<PsiMethod>> constructorsToSubConstructors = new HashMap<>();
    for (PsiMethod constructor : constructors) {
        final HashSet<PsiMethod> referencingSubConstructors = new HashSet<>();
        constructorsToSubConstructors.put(constructor, referencingSubConstructors);
        if (constructor != null) {
            // find references
            for (PsiReference reference : ReferencesSearch.search(constructor, new LocalSearchScope(mySourceClass), false)) {
                final PsiElement element = reference.getElement();
                if (element != null && "super".equals(element.getText())) {
                    PsiMethod parentMethod = PsiTreeUtil.getParentOfType(element, PsiMethod.class);
                    if (parentMethod != null && parentMethod.isConstructor()) {
                        referencingSubConstructors.add(parentMethod);
                    }
                }
            }
        }
        // check default constructor
        if (constructor == null || constructor.getParameterList().getParametersCount() == 0) {
            RefactoringUtil.visitImplicitSuperConstructorUsages(mySourceClass, new RefactoringUtil.ImplicitConstructorUsageVisitor() {

                public void visitConstructor(PsiMethod constructor, PsiMethod baseConstructor) {
                    referencingSubConstructors.add(constructor);
                }

                public void visitClassWithoutConstructors(PsiClass aClass) {
                }
            }, myTargetSuperClass);
        }
    }
    return constructorsToSubConstructors;
}
Also used : LocalSearchScope(com.intellij.psi.search.LocalSearchScope) HashMap(com.intellij.util.containers.HashMap) RefactoringUtil(com.intellij.refactoring.util.RefactoringUtil)

Example 27 with HashMap

use of com.intellij.util.containers.HashMap in project intellij-community by JetBrains.

the class FileAnnotation method createDefaultPreviousFileRevisionProvider.

@Nullable
private static PreviousFileRevisionProvider createDefaultPreviousFileRevisionProvider(@NotNull FileAnnotation annotation) {
    List<VcsFileRevision> revisions = annotation.getRevisions();
    if (revisions == null)
        return null;
    Map<VcsRevisionNumber, VcsFileRevision> map = new HashMap<>();
    for (int i = 0; i < revisions.size(); i++) {
        VcsFileRevision revision = revisions.get(i);
        VcsFileRevision previousRevision = i + 1 < revisions.size() ? revisions.get(i + 1) : null;
        map.put(revision.getRevisionNumber(), previousRevision);
    }
    List<VcsFileRevision> lineToRevision = new ArrayList<>(annotation.getLineCount());
    for (int i = 0; i < annotation.getLineCount(); i++) {
        lineToRevision.add(map.get(annotation.getLineRevisionNumber(i)));
    }
    VcsFileRevision lastRevision = ContainerUtil.getFirstItem(revisions);
    return new PreviousFileRevisionProvider() {

        @Nullable
        @Override
        public VcsFileRevision getPreviousRevision(int lineNumber) {
            LOG.assertTrue(lineNumber >= 0 && lineNumber < lineToRevision.size());
            return lineToRevision.get(lineNumber);
        }

        @Nullable
        @Override
        public VcsFileRevision getLastRevision() {
            return lastRevision;
        }
    };
}
Also used : HashMap(com.intellij.util.containers.HashMap) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision) Nullable(org.jetbrains.annotations.Nullable)

Example 28 with HashMap

use of com.intellij.util.containers.HashMap in project intellij-community by JetBrains.

the class ProjectRootContainerImpl method finishChange.

@Override
public void finishChange() {
    LOG.assertTrue(myInsideChange);
    HashMap<OrderRootType, VirtualFile[]> oldRoots = new HashMap<>(myFiles);
    boolean changes = false;
    for (OrderRootType orderRootType : OrderRootType.getAllTypes()) {
        final VirtualFile[] roots = myRoots.get(orderRootType).getVirtualFiles();
        changes = changes || !Comparing.equal(roots, oldRoots.get(orderRootType));
        myFiles.put(orderRootType, roots);
    }
    if (changes) {
        fireRootsChanged();
    }
    myInsideChange = false;
}
Also used : HashMap(com.intellij.util.containers.HashMap) OrderRootType(com.intellij.openapi.roots.OrderRootType) PersistentOrderRootType(com.intellij.openapi.roots.PersistentOrderRootType)

Example 29 with HashMap

use of com.intellij.util.containers.HashMap in project intellij-community by JetBrains.

the class SourceScope method buildAllDependencies.

public static Map<Module, Collection<Module>> buildAllDependencies(final Project project) {
    Graph<Module> graph = ModuleManager.getInstance(project).moduleGraph();
    Map<Module, Collection<Module>> result = new HashMap<>();
    for (final Module module : graph.getNodes()) {
        buildDependenciesForModule(module, graph, result);
    }
    return result;
}
Also used : HashMap(com.intellij.util.containers.HashMap) Module(com.intellij.openapi.module.Module)

Example 30 with HashMap

use of com.intellij.util.containers.HashMap in project intellij-community by JetBrains.

the class LibraryImpl method initRoots.

private Map<OrderRootType, VirtualFilePointerContainer> initRoots() {
    Disposer.register(this, myPointersDisposable);
    Map<OrderRootType, VirtualFilePointerContainer> result = new HashMap<>(4);
    for (OrderRootType rootType : getAllRootTypes()) {
        result.put(rootType, VirtualFilePointerManager.getInstance().createContainer(myPointersDisposable));
    }
    return result;
}
Also used : HashMap(com.intellij.util.containers.HashMap) OrderRootType(com.intellij.openapi.roots.OrderRootType) VirtualFilePointerContainer(com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer)

Aggregations

HashMap (com.intellij.util.containers.HashMap)118 NotNull (org.jetbrains.annotations.NotNull)23 VirtualFile (com.intellij.openapi.vfs.VirtualFile)22 File (java.io.File)22 Nullable (org.jetbrains.annotations.Nullable)18 Map (java.util.Map)17 Module (com.intellij.openapi.module.Module)15 Project (com.intellij.openapi.project.Project)15 ArrayList (java.util.ArrayList)14 PsiElement (com.intellij.psi.PsiElement)11 HashSet (com.intellij.util.containers.HashSet)10 List (java.util.List)9 IncorrectOperationException (com.intellij.util.IncorrectOperationException)8 IOException (java.io.IOException)8 Pair (com.intellij.openapi.util.Pair)6 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)6 SearchScope (com.intellij.psi.search.SearchScope)6 Logger (com.intellij.openapi.diagnostic.Logger)5 PsiFile (com.intellij.psi.PsiFile)5 UsageInfo (com.intellij.usageView.UsageInfo)5