use of com.intellij.util.containers.MultiMap in project intellij-community by JetBrains.
the class ExtractClosureFromMethodProcessor method preprocessUsages.
@Override
protected boolean preprocessUsages(@NotNull Ref<UsageInfo[]> refUsages) {
UsageInfo[] usagesIn = refUsages.get();
MultiMap<PsiElement, String> conflicts = new MultiMap<>();
final GrStatement[] statements = myHelper.getStatements();
for (GrStatement statement : statements) {
GroovyIntroduceParameterUtil.detectAccessibilityConflicts(statement, usagesIn, conflicts, false, myProject);
}
for (UsageInfo info : usagesIn) {
if (info instanceof OtherLanguageUsageInfo) {
final String lang = CommonRefactoringUtil.htmlEmphasize(info.getElement().getLanguage().getDisplayName());
conflicts.putValue(info.getElement(), GroovyRefactoringBundle.message("cannot.process.usage.in.language.{0}", lang));
}
}
if (!myMethod.hasModifierProperty(PsiModifier.PRIVATE)) {
final AnySupers anySupers = new AnySupers();
for (GrStatement statement : statements) {
statement.accept(anySupers);
}
if (anySupers.containsSupers()) {
for (UsageInfo usageInfo : usagesIn) {
if (!(usageInfo.getElement() instanceof PsiMethod) && !(usageInfo instanceof InternalUsageInfo)) {
if (!PsiTreeUtil.isAncestor(myMethod.getContainingClass(), usageInfo.getElement(), false)) {
conflicts.putValue(statements[0], RefactoringBundle.message("parameter.initializer.contains.0.but.not.all.calls.to.method.are.in.its.class", CommonRefactoringUtil.htmlEmphasize(PsiKeyword.SUPER)));
break;
}
}
}
}
}
if (!conflicts.isEmpty() && ApplicationManager.getApplication().isUnitTestMode()) {
throw new ConflictsInTestsException(conflicts.values());
}
if (!conflicts.isEmpty()) {
final ConflictsDialog conflictsDialog = prepareConflictsDialog(conflicts, usagesIn);
if (!conflictsDialog.showAndGet()) {
if (conflictsDialog.isShowConflicts())
prepareSuccessful();
return false;
}
}
prepareSuccessful();
return true;
}
use of com.intellij.util.containers.MultiMap in project intellij-community by JetBrains.
the class GroovyInlineLocalProcessor method preprocessUsages.
@Override
protected boolean preprocessUsages(@NotNull Ref<UsageInfo[]> refUsages) {
final MultiMap<PsiElement, String> conflicts = new MultiMap<>();
final UsageInfo[] usages = refUsages.get();
for (UsageInfo usage : usages) {
collectConflicts(usage.getReference(), conflicts);
}
return showConflicts(conflicts, usages);
}
use of com.intellij.util.containers.MultiMap in project intellij-community by JetBrains.
the class MavenProjectsTree method resolve.
public void resolve(@NotNull Project project, @NotNull Collection<MavenProject> mavenProjects, @NotNull MavenGeneralSettings generalSettings, @NotNull MavenEmbeddersManager embeddersManager, @NotNull MavenConsole console, @NotNull ResolveContext context, @NotNull MavenProgressIndicator process) throws MavenProcessCanceledException {
MultiMap<File, MavenProject> projectMultiMap = groupByBasedir(mavenProjects);
for (Map.Entry<File, Collection<MavenProject>> entry : projectMultiMap.entrySet()) {
String baseDir = entry.getKey().getPath();
MavenEmbedderWrapper embedder = embeddersManager.getEmbedder(MavenEmbeddersManager.FOR_DEPENDENCIES_RESOLVE, baseDir, baseDir);
try {
embedder.customizeForResolve(getWorkspaceMap(), console, process, generalSettings.isAlwaysUpdateSnapshots());
doResolve(project, entry.getValue(), generalSettings, embedder, context, process);
} finally {
embeddersManager.release(embedder);
}
}
}
use of com.intellij.util.containers.MultiMap in project intellij-community by JetBrains.
the class MavenProjectsTree method downloadSourcesAndJavadocs.
public MavenArtifactDownloader.DownloadResult downloadSourcesAndJavadocs(@NotNull Project project, @NotNull Collection<MavenProject> projects, @Nullable Collection<MavenArtifact> artifacts, boolean downloadSources, boolean downloadDocs, @NotNull MavenEmbeddersManager embeddersManager, @NotNull MavenConsole console, @NotNull MavenProgressIndicator process) throws MavenProcessCanceledException {
MultiMap<File, MavenProject> projectMultiMap = groupByBasedir(projects);
MavenArtifactDownloader.DownloadResult result = new MavenArtifactDownloader.DownloadResult();
for (Map.Entry<File, Collection<MavenProject>> entry : projectMultiMap.entrySet()) {
String baseDir = entry.getKey().getPath();
MavenEmbedderWrapper embedder = embeddersManager.getEmbedder(MavenEmbeddersManager.FOR_DOWNLOAD, baseDir, baseDir);
try {
embedder.customizeForResolve(console, process);
MavenArtifactDownloader.DownloadResult result1 = MavenArtifactDownloader.download(project, this, projects, artifacts, downloadSources, downloadDocs, embedder, process);
for (MavenProject each : projects) {
fireArtifactsDownloaded(each);
}
result.resolvedDocs.addAll(result1.resolvedDocs);
result.resolvedSources.addAll(result1.resolvedSources);
result.unresolvedDocs.addAll(result1.unresolvedDocs);
result.unresolvedSources.addAll(result1.unresolvedSources);
} finally {
embeddersManager.release(embedder);
}
}
return result;
}
use of com.intellij.util.containers.MultiMap in project intellij-community by JetBrains.
the class MavenDuplicateDependenciesInspection method checkManagedDependencies.
private static void checkManagedDependencies(@NotNull MavenDomProjectModel projectModel, @NotNull DomElementAnnotationHolder holder) {
MultiMap<DependencyConflictId, MavenDomDependency> duplicates = MultiMap.createSet();
collect(duplicates, projectModel.getDependencyManagement().getDependencies());
for (Map.Entry<DependencyConflictId, Collection<MavenDomDependency>> entry : duplicates.entrySet()) {
Collection<MavenDomDependency> set = entry.getValue();
if (set.size() <= 1)
continue;
for (MavenDomDependency dependency : set) {
holder.createProblem(dependency, HighlightSeverity.WARNING, "Duplicated dependency");
}
}
}
Aggregations