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