Java Code Examples for com.intellij.util.containers.HashMap#get()

The following examples show how to use com.intellij.util.containers.HashMap#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HaxePullUpHelper.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
@Override
public void moveFieldInitializations(LinkedHashSet<PsiField> movedFields) {
  PsiMethod[] constructors = myTargetSuperClass.getConstructors();

  if (constructors.length == 0) {
    constructors = new PsiMethod[]{null};
  }

  HashMap<PsiMethod,HashSet<PsiMethod>> constructorsToSubConstructors = buildConstructorsToSubConstructorsMap(constructors);
  for (PsiMethod constructor : constructors) {
    HashSet<PsiMethod> subConstructors = constructorsToSubConstructors.get(constructor);
    tryToMoveInitializers(constructor, subConstructors, movedFields);
  }
}
 
Example 2
Source File: CoverageSuiteChooserDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void groupSuites(final HashMap<CoverageRunner, Map<String, List<CoverageSuite>>> grouped,
                                final CoverageSuite[] suites,
                                final CoverageEngine engine) {
  for (CoverageSuite suite : suites) {
    if (engine != null && suite.getCoverageEngine() != engine) continue;
    final CoverageFileProvider provider = suite.getCoverageDataFileProvider();
    if (provider instanceof DefaultCoverageFileProvider &&
        Comparing.strEqual(((DefaultCoverageFileProvider)provider).getSourceProvider(), DefaultCoverageFileProvider.class.getName())) {
      if (!provider.ensureFileExists()) continue;
    }
    final CoverageRunner runner = suite.getRunner();
    Map<String, List<CoverageSuite>> byProviders = grouped.get(runner);
    if (byProviders == null) {
      byProviders = new HashMap<String, List<CoverageSuite>>();
      grouped.put(runner, byProviders);
    }
    final String sourceProvider = provider instanceof DefaultCoverageFileProvider
                                  ? ((DefaultCoverageFileProvider)provider).getSourceProvider()
                                  : provider.getClass().getName();
    List<CoverageSuite> list = byProviders.get(sourceProvider);
    if (list == null) {
      list = new ArrayList<CoverageSuite>();
      byProviders.put(sourceProvider, list);
    }
    list.add(suite);
  }
}
 
Example 3
Source File: PlatformTestUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("UnsafeVfsRecursion")
public static void assertDirectoriesEqual(VirtualFile dirAfter, VirtualFile dirBefore, @Nullable VirtualFileFilter fileFilter) throws IOException {
  FileDocumentManager.getInstance().saveAllDocuments();

  VirtualFile[] childrenAfter = dirAfter.getChildren();
  if (dirAfter.isInLocalFileSystem()) {
    File[] ioAfter = new File(dirAfter.getPath()).listFiles();
    shallowCompare(childrenAfter, ioAfter);
  }

  VirtualFile[] childrenBefore = dirBefore.getChildren();
  if (dirBefore.isInLocalFileSystem()) {
    File[] ioBefore = new File(dirBefore.getPath()).listFiles();
    shallowCompare(childrenBefore, ioBefore);
  }

  HashMap<String, VirtualFile> mapAfter = buildNameToFileMap(childrenAfter, fileFilter);
  HashMap<String, VirtualFile> mapBefore = buildNameToFileMap(childrenBefore, fileFilter);

  Set<String> keySetAfter = mapAfter.keySet();
  Set<String> keySetBefore = mapBefore.keySet();
  assertEquals(dirAfter.getPath(), keySetAfter, keySetBefore);

  for (String name : keySetAfter) {
    VirtualFile fileAfter = mapAfter.get(name);
    VirtualFile fileBefore = mapBefore.get(name);
    if (fileAfter.isDirectory()) {
      assertDirectoriesEqual(fileAfter, fileBefore, fileFilter);
    }
    else {
      assertFilesEqual(fileAfter, fileBefore);
    }
  }
}
 
Example 4
Source File: HaxeCalleeMethodsTreeStructure.java    From intellij-haxe with Apache License 2.0 4 votes vote down vote up
@NotNull
protected final Object[] buildChildren(@NotNull final HierarchyNodeDescriptor descriptor) {
  final HaxeHierarchyTimeoutHandler timeoutHandler = new HaxeHierarchyTimeoutHandler();

  try {
    final PsiMember enclosingElement = ((CallHierarchyNodeDescriptor)descriptor).getEnclosingElement();
    if (!(enclosingElement instanceof PsiMethod)) {
      return ArrayUtil.EMPTY_OBJECT_ARRAY;
    }
    final PsiMethod method = (PsiMethod)enclosingElement;

    final ArrayList<PsiMethod> methods = new ArrayList<PsiMethod>();

    final PsiCodeBlock body = method.getBody();
    if (body != null) {
      visitor(body, methods);
    }

    final PsiMethod baseMethod = (PsiMethod)((CallHierarchyNodeDescriptor)getBaseDescriptor()).getTargetElement();
    final PsiClass baseClass = baseMethod.getContainingClass();

    final HashMap<PsiMethod, CallHierarchyNodeDescriptor> methodToDescriptorMap = new HashMap<PsiMethod, CallHierarchyNodeDescriptor>();

    final ArrayList<CallHierarchyNodeDescriptor> result = new ArrayList<CallHierarchyNodeDescriptor>();

    for (final PsiMethod calledMethod : methods) {
      if (timeoutHandler.checkAndCancelIfNecessary()) {
        break;
      }

      if (!isInScope(baseClass, calledMethod, myScopeType)) continue;

      CallHierarchyNodeDescriptor d = methodToDescriptorMap.get(calledMethod);
      if (d == null) {
        d = new CallHierarchyNodeDescriptor(myProject, descriptor, calledMethod, false, false);
        methodToDescriptorMap.put(calledMethod, d);
        result.add(d);
      }
      else {
        d.incrementUsageCount();
      }
    }

    // also add overriding methods as children
    if (!timeoutHandler.isCanceled()) {
      Query<PsiMethod> query = HaxeMethodsSearch.search(method, timeoutHandler);
      query.forEach(new Processor<PsiMethod>() {
        @Override
        public boolean process(PsiMethod overridingMethod) {
          if (isInScope(baseClass, overridingMethod, myScopeType)) {
            final CallHierarchyNodeDescriptor node =
              new CallHierarchyNodeDescriptor(myProject, descriptor, overridingMethod, false, false);
            if (!result.contains(node)) result.add(node);
          }
          return timeoutHandler.checkAndCancelIfNecessary();
        }
      });
    }

    return ArrayUtil.toObjectArray(result);

  } finally {
    // This is in a finally clause because a cancellation would otherwise throw
    // right past us.

    timeoutHandler.stop(); // Clean up.
    if (timeoutHandler.isCanceled()) {
      timeoutHandler.postCanceledDialog(myProject);
    }
  }
}
 
Example 5
Source File: KeymapImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public HashMap<String, ArrayList<KeyboardShortcut>> getConflicts(String actionId, KeyboardShortcut keyboardShortcut) {
  HashMap<String, ArrayList<KeyboardShortcut>> result = new HashMap<String, ArrayList<KeyboardShortcut>>();

  String[] actionIds = getActionIds(keyboardShortcut.getFirstKeyStroke());
  for (String id : actionIds) {
    if (id.equals(actionId)) {
      continue;
    }

    if (actionId.startsWith(EDITOR_ACTION_PREFIX) && id.equals("$" + actionId.substring(6))) {
      continue;
    }
    if (StringUtil.startsWithChar(actionId, '$') && id.equals(EDITOR_ACTION_PREFIX + actionId.substring(1))) {
      continue;
    }

    final String useShortcutOf = myKeymapManager.getActionBinding(id);
    if (useShortcutOf != null && useShortcutOf.equals(actionId)) {
      continue;
    }

    Shortcut[] shortcuts = getShortcuts(id);
    for (Shortcut shortcut1 : shortcuts) {
      if (!(shortcut1 instanceof KeyboardShortcut)) {
        continue;
      }

      KeyboardShortcut shortcut = (KeyboardShortcut)shortcut1;

      if (!shortcut.getFirstKeyStroke().equals(keyboardShortcut.getFirstKeyStroke())) {
        continue;
      }

      if (keyboardShortcut.getSecondKeyStroke() != null &&
          shortcut.getSecondKeyStroke() != null &&
          !keyboardShortcut.getSecondKeyStroke().equals(shortcut.getSecondKeyStroke())) {
        continue;
      }

      ArrayList<KeyboardShortcut> list = result.get(id);
      if (list == null) {
        list = new ArrayList<KeyboardShortcut>();
        result.put(id, list);
      }

      list.add(shortcut);
    }
  }

  return result;
}