use of com.intellij.util.containers.HashSet in project intellij-community by JetBrains.
the class ExtractSuperClassTest method doTest.
private void doTest(MemberInfo[] members, @NonNls String newClassName, String targetPackageName, VirtualFile rootDir, PsiClass psiClass, String[] conflicts) throws IOException {
PsiDirectory targetDirectory;
if (targetPackageName == null) {
targetDirectory = psiClass.getContainingFile().getContainingDirectory();
} else {
final PsiPackage aPackage = myJavaFacade.findPackage(targetPackageName);
assertNotNull(aPackage);
targetDirectory = aPackage.getDirectories()[0];
}
ExtractSuperClassProcessor processor = new ExtractSuperClassProcessor(myProject, targetDirectory, newClassName, psiClass, members, false, new DocCommentPolicy<>(DocCommentPolicy.ASIS));
final PsiPackage targetPackage;
if (targetDirectory != null) {
targetPackage = JavaDirectoryService.getInstance().getPackage(targetDirectory);
} else {
targetPackage = null;
}
final PsiClass superClass = psiClass.getExtendsListTypes().length > 0 ? psiClass.getSuperClass() : null;
final MultiMap<PsiElement, String> conflictsMap = PullUpConflictsUtil.checkConflicts(members, psiClass, superClass, targetPackage, targetDirectory, psiMethod -> PullUpProcessor.checkedInterfacesContain(Arrays.asList(members), psiMethod), false);
if (conflicts != null) {
if (conflictsMap.isEmpty()) {
fail("Conflicts were not detected");
}
final HashSet<String> expectedConflicts = new HashSet<>(Arrays.asList(conflicts));
final HashSet<String> actualConflicts = new HashSet<>(conflictsMap.values());
assertEquals(expectedConflicts.size(), actualConflicts.size());
for (String actualConflict : actualConflicts) {
if (!expectedConflicts.contains(actualConflict)) {
fail("Unexpected conflict: " + actualConflict);
}
}
} else if (!conflictsMap.isEmpty()) {
fail("Unexpected conflicts!!!");
}
processor.run();
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
FileDocumentManager.getInstance().saveAllDocuments();
String rootAfter = getRoot() + "/after";
VirtualFile rootDir2 = LocalFileSystem.getInstance().findFileByPath(rootAfter.replace(File.separatorChar, '/'));
myProject.getComponent(PostprocessReformattingAspect.class).doPostponedFormatting();
IdeaTestUtil.assertDirectoriesEqual(rootDir2, rootDir);
}
use of com.intellij.util.containers.HashSet in project intellij-community by JetBrains.
the class SuperClassHasFrequentlyUsedInheritorsInspectionTest method doTest.
private void doTest(final int expectedSize) {
myFixture.configureByFile(getTestName(false) + ".java");
myFixture.enableInspections(SuperClassHasFrequentlyUsedInheritorsInspection.class);
final Set<Pair<String, Integer>> actualSet = new HashSet<Pair<String, Integer>>();
for (IntentionAction intentionAction : myFixture.getAvailableIntentions()) {
if (intentionAction instanceof QuickFixWrapper) {
ChangeSuperClassFix changeSuperClassFix = getQuickFixFromWrapper((QuickFixWrapper) intentionAction);
if (changeSuperClassFix != null) {
actualSet.add(Pair.create(changeSuperClassFix.getNewSuperClass().getQualifiedName(), changeSuperClassFix.getPercent()));
}
}
}
assertSize(expectedSize, actualSet);
}
use of com.intellij.util.containers.HashSet in project intellij-community by JetBrains.
the class ActionMacroConfigurationPanel method apply.
public void apply() {
if (myRenamingList != null) {
for (Couple<String> pair : myRenamingList) {
Keymap[] allKeymaps = KeymapManagerEx.getInstanceEx().getAllKeymaps();
for (Keymap keymap : allKeymaps) {
keymap.removeAllActionShortcuts(ActionMacro.MACRO_ACTION_PREFIX + pair.getSecond());
for (Shortcut shortcut : keymap.getShortcuts(ActionMacro.MACRO_ACTION_PREFIX + pair.getFirst())) {
keymap.addShortcut(ActionMacro.MACRO_ACTION_PREFIX + pair.getSecond(), shortcut);
}
keymap.removeAllActionShortcuts(ActionMacro.MACRO_ACTION_PREFIX + pair.getFirst());
}
}
}
final ActionMacroManager manager = ActionMacroManager.getInstance();
ActionMacro[] macros = manager.getAllMacros();
HashSet<String> removedIds = new HashSet<>();
for (ActionMacro macro1 : macros) {
removedIds.add(macro1.getActionId());
}
manager.removeAllMacros();
final Enumeration newMacros = myMacrosModel.elements();
while (newMacros.hasMoreElements()) {
ActionMacro macro = (ActionMacro) newMacros.nextElement();
manager.addMacro(macro);
removedIds.remove(macro.getActionId());
}
manager.registerActions();
for (String id : removedIds) {
Keymap[] allKeymaps = KeymapManagerEx.getInstanceEx().getAllKeymaps();
for (Keymap keymap : allKeymaps) {
keymap.removeAllActionShortcuts(id);
}
}
}
use of com.intellij.util.containers.HashSet in project intellij-community by JetBrains.
the class FeaturesUsageCollector method getUsages.
@NotNull
@Override
public Set<UsageDescriptor> getUsages() {
Set<UsageDescriptor> usages = new HashSet<>();
final ProductivityFeaturesRegistry registry = ProductivityFeaturesRegistry.getInstance();
for (String featureId : registry.getFeatureIds()) {
final FeatureDescriptor featureDescriptor = registry.getFeatureDescriptor(featureId);
if (featureDescriptor != null) {
usages.add(new UsageDescriptor(featureId, featureDescriptor.getUsageCount()));
}
}
return usages;
}
use of com.intellij.util.containers.HashSet in project intellij-plugins by JetBrains.
the class CfmlAttributeNamesCompletionProvider method addCompletions.
public void addCompletions(@NotNull final CompletionParameters parameters, final ProcessingContext context, @NotNull final CompletionResultSet result) {
PsiElement element = parameters.getPosition();
String tagName = "";
while (element != null && !(element instanceof CfmlTag) && !(element instanceof CfmlComponent) && !(element instanceof CfmlPropertyImpl)) {
PsiElement prevNode = element.getPrevSibling();
PsiElement superPrevNode = prevNode != null ? prevNode.getPrevSibling() : null;
if (superPrevNode != null && superPrevNode.getText().equalsIgnoreCase("property")) {
tagName = "cfproperty";
break;
}
element = element.getParent();
}
if (element == null) {
return;
}
if (tagName.isEmpty()) {
tagName = element instanceof CfmlTag ? ((CfmlTag) element).getTagName() : element instanceof CfmlPropertyImpl ? "cfproperty" : "cfcomponent";
}
Set<String> excluded = new HashSet<>();
final CfmlAttributeImpl[] attributes = PsiTreeUtil.getChildrenOfType(element, CfmlAttributeImpl.class);
if (attributes != null) {
for (CfmlAttributeImpl attribute : attributes) {
excluded.add(attribute.getAttributeName());
}
}
for (CfmlAttributeDescription s : CfmlUtil.getAttributes(tagName, element.getProject())) {
if (s.getName() == null) {
continue;
}
if (excluded.contains(s.getName())) {
continue;
}
result.addElement(TailTypeDecorator.withTail(LookupElementBuilder.create(s.getName()).withCaseSensitivity(false), new TailType() {
public int processTail(Editor editor, int tailOffset) {
HighlighterIterator iterator = ((EditorEx) editor).getHighlighter().createIterator(tailOffset);
if (!iterator.atEnd() && iterator.getTokenType() == CfmlTokenTypes.WHITE_SPACE)
iterator.advance();
if (!iterator.atEnd() && iterator.getTokenType() == CfmlTokenTypes.ASSIGN) {
iterator.advance();
} else {
editor.getDocument().insertString(tailOffset, "=\"\"");
return moveCaret(editor, tailOffset, 2);
}
int offset = iterator.getStart();
if (!iterator.atEnd() && iterator.getTokenType() == CfmlTokenTypes.WHITE_SPACE)
iterator.advance();
if (!iterator.atEnd() && CfmlTokenTypes.STRING_ELEMENTS.contains(iterator.getTokenType())) {
return tailOffset;
}
editor.getDocument().insertString(offset, "\"\"");
return moveCaret(editor, tailOffset, offset - tailOffset + 1);
}
}));
}
}
Aggregations