Search in sources :

Example 16 with MultiMap

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

the class GrIntroduceClosureParameterProcessor method preprocessUsages.

@Override
protected boolean preprocessUsages(@NotNull Ref<UsageInfo[]> refUsages) {
    UsageInfo[] usagesIn = refUsages.get();
    MultiMap<PsiElement, String> conflicts = new MultiMap<>();
    if (!mySettings.generateDelegate()) {
        detectAccessibilityConflicts(usagesIn, conflicts);
    }
    final GrExpression expression = mySettings.getExpression();
    if (expression != null && toSearchFor instanceof PsiMember) {
        final AnySupers anySupers = new AnySupers();
        expression.accept(anySupers);
        if (anySupers.containsSupers()) {
            final PsiElement containingClass = PsiUtil.getFileOrClassContext(toReplaceIn);
            for (UsageInfo usageInfo : usagesIn) {
                if (!(usageInfo.getElement() instanceof PsiMethod) && !(usageInfo instanceof InternalUsageInfo)) {
                    if (!PsiTreeUtil.isAncestor(containingClass, usageInfo.getElement(), false)) {
                        conflicts.putValue(expression, RefactoringBundle.message("parameter.initializer.contains.0.but.not.all.calls.to.method.are.in.its.class", CommonRefactoringUtil.htmlEmphasize(PsiKeyword.SUPER)));
                        break;
                    }
                }
            }
        }
    }
    return showConflicts(conflicts, usagesIn);
}
Also used : MultiMap(com.intellij.util.containers.MultiMap) ExternalUsageInfo(com.intellij.refactoring.introduceParameter.ExternalUsageInfo) UsageInfo(com.intellij.usageView.UsageInfo) InternalUsageInfo(com.intellij.refactoring.introduceParameter.InternalUsageInfo) AnySupers(org.jetbrains.plugins.groovy.refactoring.util.AnySupers) InternalUsageInfo(com.intellij.refactoring.introduceParameter.InternalUsageInfo)

Example 17 with MultiMap

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

the class ResourceBundleFileStructureViewElement method getChildren.

@NotNull
public synchronized StructureViewTreeElement[] getChildren() {
    final MultiMap<String, IProperty> propertyNames = getPropertiesMap(myResourceBundle, myShowOnlyIncomplete);
    final HashSet<String> remains = new HashSet<>(myElements.keySet());
    for (Map.Entry<String, Collection<IProperty>> entry : propertyNames.entrySet()) {
        final String propKey = entry.getKey();
        Collection<IProperty> properties = entry.getValue();
        final ResourceBundlePropertyStructureViewElement oldPropertyNode = myElements.get(propKey);
        if (oldPropertyNode != null && properties.contains(oldPropertyNode.getProperty())) {
            remains.remove(propKey);
            continue;
        }
        final IProperty representative = properties.iterator().next();
        myElements.put(propKey, new ResourceBundlePropertyStructureViewElement(representative));
    }
    for (String remain : remains) {
        myElements.remove(remain);
    }
    return myElements.values().toArray(StructureViewTreeElement.EMPTY_ARRAY);
}
Also used : IProperty(com.intellij.lang.properties.IProperty) Collection(java.util.Collection) TObjectIntHashMap(gnu.trove.TObjectIntHashMap) Map(java.util.Map) MultiMap(com.intellij.util.containers.MultiMap) HashSet(com.intellij.util.containers.HashSet) NotNull(org.jetbrains.annotations.NotNull)

Example 18 with MultiMap

use of com.intellij.util.containers.MultiMap in project kotlin by JetBrains.

the class KotlinCodegenFacade method doGenerateFiles.

public static void doGenerateFiles(@NotNull Collection<KtFile> files, @NotNull GenerationState state, @NotNull CompilationErrorHandler errorHandler) {
    MultiMap<FqName, KtFile> filesInPackages = new MultiMap<FqName, KtFile>();
    MultiMap<FqName, KtFile> filesInMultifileClasses = new MultiMap<FqName, KtFile>();
    for (KtFile file : files) {
        if (file == null)
            throw new IllegalArgumentException("A null file given for compilation");
        JvmFileClassInfo fileClassInfo = state.getFileClassesProvider().getFileClassInfo(file);
        if (fileClassInfo.getWithJvmMultifileClass()) {
            filesInMultifileClasses.putValue(fileClassInfo.getFacadeClassFqName(), file);
        } else {
            filesInPackages.putValue(file.getPackageFqName(), file);
        }
    }
    Set<FqName> obsoleteMultifileClasses = new HashSet<FqName>(state.getObsoleteMultifileClasses());
    for (FqName multifileClassFqName : Sets.union(filesInMultifileClasses.keySet(), obsoleteMultifileClasses)) {
        doCheckCancelled(state);
        generateMultifileClass(state, multifileClassFqName, filesInMultifileClasses.get(multifileClassFqName), errorHandler);
    }
    Set<FqName> packagesWithObsoleteParts = new HashSet<FqName>(state.getPackagesWithObsoleteParts());
    for (FqName packageFqName : Sets.union(packagesWithObsoleteParts, filesInPackages.keySet())) {
        doCheckCancelled(state);
        generatePackage(state, packageFqName, filesInPackages.get(packageFqName), errorHandler);
    }
    doCheckCancelled(state);
    state.getFactory().done();
}
Also used : MultiMap(com.intellij.util.containers.MultiMap) JvmFileClassInfo(org.jetbrains.kotlin.fileClasses.JvmFileClassInfo) FqName(org.jetbrains.kotlin.name.FqName) KtFile(org.jetbrains.kotlin.psi.KtFile) HashSet(java.util.HashSet)

Example 19 with MultiMap

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

the class MvcModuleStructureUtil method updateGlobalPluginModule.

public static void updateGlobalPluginModule(@NotNull Project project, @NotNull MvcFramework framework) {
    MultiMap<VirtualFile, Module> map = new MultiMap<>();
    for (Module module : ModuleManager.getInstance(project).getModules()) {
        if (framework.hasSupport(module)) {
            VirtualFile globalPluginsDir = refreshAndFind(framework.getGlobalPluginsDir(module));
            if (globalPluginsDir != null && hasChildDirectory(globalPluginsDir)) {
                map.putValue(globalPluginsDir, module);
            }
        }
    }
    Map<VirtualFile, Module> globalAuxModules = new HashMap<>();
    for (Module module : ModuleManager.getInstance(project).getModules()) {
        if (framework.isGlobalPluginModule(module)) {
            VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots();
            VirtualFile parent = null;
            if (contentRoots.length > 0) {
                parent = contentRoots[0].getParent();
                if (!map.containsKey(parent)) {
                    parent = null;
                } else {
                    for (int i = 1; i < contentRoots.length; i++) {
                        if (!Comparing.equal(parent, contentRoots[i].getParent())) {
                            parent = null;
                            break;
                        }
                    }
                }
            }
            if (parent == null) {
                removeAuxiliaryModule(module);
            } else {
                globalAuxModules.put(parent, module);
            }
        }
    }
    for (VirtualFile virtualFile : map.keySet()) {
        if (!globalAuxModules.containsKey(virtualFile)) {
            Module appModule = map.get(virtualFile).iterator().next();
            Module module = createAuxiliaryModule(appModule, generateUniqueModuleName(project, framework.getGlobalPluginsModuleName()), framework);
            globalAuxModules.put(virtualFile, module);
        }
    }
    assert map.size() == globalAuxModules.size();
    for (VirtualFile virtualFile : map.keySet()) {
        List<VirtualFile> pluginRoots = new ArrayList<>();
        for (VirtualFile child : virtualFile.getChildren()) {
            if (child.isDirectory()) {
                pluginRoots.add(child);
            }
        }
        assert !pluginRoots.isEmpty();
        Module auxModule = globalAuxModules.get(virtualFile);
        updateAuxModuleStructure(auxModule, pluginRoots, framework);
        for (Module appModule : map.get(virtualFile)) {
            ensureDependency(appModule, auxModule, false);
            Module commonPluginsModule = framework.findCommonPluginsModule(appModule);
            if (commonPluginsModule != null) {
                ensureDependency(commonPluginsModule, auxModule, false);
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MultiMap(com.intellij.util.containers.MultiMap) Module(com.intellij.openapi.module.Module)

Example 20 with MultiMap

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

the class VcsAnnotationLocalChangesListenerImpl method processUnderFile.

private void processUnderFile(VirtualFile file) {
    final MultiMap<VirtualFile, FileAnnotation> annotations = new MultiMap<>();
    synchronized (myLock) {
        for (VirtualFile virtualFile : myFileAnnotationMap.keySet()) {
            if (VfsUtilCore.isAncestor(file, virtualFile, true)) {
                final Collection<FileAnnotation> values = myFileAnnotationMap.get(virtualFile);
                for (FileAnnotation value : values) {
                    annotations.putValue(virtualFile, value);
                }
            }
        }
    }
    if (!annotations.isEmpty()) {
        for (Map.Entry<VirtualFile, Collection<FileAnnotation>> entry : annotations.entrySet()) {
            final VirtualFile key = entry.getKey();
            final VcsRevisionNumber number = fromDiffProvider(key);
            if (number == null)
                continue;
            final Collection<FileAnnotation> fileAnnotations = entry.getValue();
            for (FileAnnotation annotation : fileAnnotations) {
                if (annotation.isBaseRevisionChanged(number)) {
                    annotation.close();
                }
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MultiMap(com.intellij.util.containers.MultiMap) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) FileAnnotation(com.intellij.openapi.vcs.annotate.FileAnnotation) MultiMap(com.intellij.util.containers.MultiMap)

Aggregations

MultiMap (com.intellij.util.containers.MultiMap)141 NotNull (org.jetbrains.annotations.NotNull)38 UsageInfo (com.intellij.usageView.UsageInfo)26 VirtualFile (com.intellij.openapi.vfs.VirtualFile)25 Project (com.intellij.openapi.project.Project)19 PsiElement (com.intellij.psi.PsiElement)18 Collection (java.util.Collection)17 ConflictsDialog (com.intellij.refactoring.ui.ConflictsDialog)16 Nullable (org.jetbrains.annotations.Nullable)16 Map (java.util.Map)15 Module (com.intellij.openapi.module.Module)11 File (java.io.File)11 ArrayList (java.util.ArrayList)11 ContainerUtil (com.intellij.util.containers.ContainerUtil)10 HashSet (com.intellij.util.containers.HashSet)10 THashSet (gnu.trove.THashSet)9 java.util (java.util)9 Pair (com.intellij.openapi.util.Pair)8 com.intellij.psi (com.intellij.psi)8 HashSet (java.util.HashSet)8