Several comparators automatically replaced with Comparator.comparing

This commit is contained in:
Tagir Valeev
2016-09-14 13:22:08 +07:00
parent e47c438b25
commit 1ab0ea609b
11 changed files with 23 additions and 23 deletions
@@ -135,7 +135,7 @@ public class ValidationConfigurable implements SearchableConfigurable, Configura
public void reset() {
myValidateBox.setSelected(myConfiguration.VALIDATE_ON_BUILD);
final List<Compiler> validators = getValidators();
Collections.sort(validators, (o1, o2) -> o1.getDescription().compareTo(o2.getDescription()));
Collections.sort(validators, Comparator.comparing(Compiler::getDescription));
myValidators.setElements(validators, false);
myValidators.markElements(getMarkedValidators());
myExcludedConfigurable.reset();
@@ -126,7 +126,7 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo
artifactState.getPropertiesList().add(propertiesState);
}
}
Collections.sort(artifactState.getPropertiesList(), (o1, o2) -> o1.getId().compareTo(o2.getId()));
Collections.sort(artifactState.getPropertiesList(), Comparator.comparing(ArtifactPropertiesState::getId));
}
state.getArtifacts().add(artifactState);
}
@@ -37,7 +37,7 @@ public abstract class ChunkCustomCompilerExtension {
* Comparator that compares extensions using names. It is used for make order of elements predictable.
*/
protected static final Comparator<ChunkCustomCompilerExtension> COMPARATOR =
(o1, o2) -> o1.getClass().getName().compareTo(o2.getClass().getName());
Comparator.comparing(o -> o.getClass().getName());
/**
* Generate custom compile task inside compile target. Note that if more
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,11 @@
*/
package com.intellij.ide.util.importProject;
import com.intellij.ui.ListCellRendererWrapper;
import com.intellij.ide.util.projectWizard.importSources.DetectedProjectRoot;
import com.intellij.openapi.ui.ComboBox;
import com.intellij.openapi.ui.ComboBoxTableRenderer;
import com.intellij.ui.CollectionComboBoxModel;
import com.intellij.ui.ListCellRendererWrapper;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.table.TableView;
import com.intellij.util.EventDispatcher;
@@ -220,7 +220,7 @@ public class DetectedRootsChooser {
column.setMaxWidth(width);
myTable.updateColumnSizes();
List<DetectedRootData> sortedRoots = new ArrayList<>(roots);
Collections.sort(sortedRoots, (o1, o2) -> o1.getDirectory().compareTo(o2.getDirectory()));
Collections.sort(sortedRoots, Comparator.comparing(DetectedRootData::getDirectory));
myModel.setItems(sortedRoots);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -167,7 +167,7 @@ public class FunctionalInterfaceSuggester {
}
final ArrayList<PsiType> typesToSuggest = new ArrayList<>(types);
Collections.sort(typesToSuggest, (o1, o2) -> o1.getCanonicalText().compareTo(o2.getCanonicalText()));
Collections.sort(typesToSuggest, Comparator.comparing(PsiType::getCanonicalText));
return typesToSuggest;
}
@@ -91,7 +91,7 @@ public class ActionsTreeUtil {
ActionManagerEx managerEx = ActionManagerEx.getInstanceEx();
final List<IdeaPluginDescriptor> plugins = new ArrayList<>();
Collections.addAll(plugins, PluginManagerCore.getPlugins());
Collections.sort(plugins, (o1, o2) -> o1.getName().compareTo(o2.getName()));
Collections.sort(plugins, Comparator.comparing(IdeaPluginDescriptor::getName));
List<PluginId> collected = new ArrayList<>();
for (IdeaPluginDescriptor plugin : plugins) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -149,7 +149,7 @@ public class AddFileOrDirectoryAction extends ActionOnSelectedElement {
}
addFilesToCollection(result, file);
}
Collections.sort(result, (o1, o2) -> o1.getPath().compareTo(o2.getPath()));
Collections.sort(result, Comparator.comparing(VirtualFile::getPath));
return result;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,7 +41,7 @@ public class WatchersPanel extends JPanel{
}
public Comparator<WatcherInfo> getComparator() {
return (o, o1) -> o.getUser().compareTo(o1.getUser());
return Comparator.comparing(WatcherInfo::getUser);
}
};
@@ -51,7 +51,7 @@ public class WatchersPanel extends JPanel{
}
public Comparator<WatcherInfo> getComparator() {
return (o, o1) -> o.getActions().compareTo(o1.getActions());
return Comparator.comparing(WatcherInfo::getActions);
}
};
@@ -61,7 +61,7 @@ public class WatchersPanel extends JPanel{
}
public Comparator<WatcherInfo> getComparator() {
return (o, o1) -> o.getFile().compareTo(o1.getFile());
return Comparator.comparing(WatcherInfo::getFile);
}
};
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ import com.intellij.lang.parameterInfo.*;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.meta.PsiMetaData;
import com.intellij.psi.xml.XmlFile;
import com.intellij.psi.xml.XmlTag;
import com.intellij.psi.xml.XmlToken;
@@ -40,7 +41,7 @@ import java.util.Comparator;
* @author Maxim.Mossienko
*/
public class XmlParameterInfoHandler implements ParameterInfoHandler<XmlTag,XmlElementDescriptor> {
private static final Comparator<XmlAttributeDescriptor> COMPARATOR = (o1, o2) -> o1.getName().compareTo(o2.getName());
private static final Comparator<XmlAttributeDescriptor> COMPARATOR = Comparator.comparing(PsiMetaData::getName);
@Override
public Object[] getParametersForLookup(LookupElement item, ParameterInfoContext context) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,7 +36,6 @@ import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.colors.EditorFontType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
@@ -45,11 +44,11 @@ import com.intellij.psi.XmlElementFactory;
import com.intellij.psi.impl.source.tree.Factory;
import com.intellij.psi.impl.source.tree.LeafElement;
import com.intellij.psi.impl.source.xml.XmlContentDFA;
import com.intellij.psi.meta.PsiMetaData;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.xml.*;
import com.intellij.refactoring.util.CommonRefactoringUtil;
import com.intellij.ui.components.JBList;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.xml.XmlAttributeDescriptor;
import com.intellij.xml.XmlElementDescriptor;
@@ -82,7 +81,7 @@ public class GenerateXmlTagAction extends SimpleCodeInsightAction {
XmlElementDescriptor currentTagDescriptor = contextTag.getDescriptor();
assert currentTagDescriptor != null;
final XmlElementDescriptor[] descriptors = currentTagDescriptor.getElementsDescriptors(contextTag);
Arrays.sort(descriptors, (o1, o2) -> o1.getName().compareTo(o2.getName()));
Arrays.sort(descriptors, Comparator.comparing(PsiMetaData::getName));
final JBList list = new JBList(descriptors);
list.setCellRenderer(new MyListCellRenderer());
Runnable runnable = () -> {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -815,7 +815,7 @@ public class XmlUtil {
else {
final XmlAttribute[] attributes = tag.getAttributes();
ContainerUtil.sort(list);
Arrays.sort(attributes, (attr1, attr2) -> attr1.getName().compareTo(attr2.getName()));
Arrays.sort(attributes, Comparator.comparing(XmlAttribute::getName));
final Iterator<MyAttributeInfo> iter = list.iterator();
list = new ArrayList<>();