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);
}
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);
}
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();
}
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);
}
}
}
}
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();
}
}
}
}
}
Aggregations