From 18ebe8d9522b7878e8ef787f120d7ada446c4903 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Thu, 18 Apr 2019 23:06:00 +0200 Subject: [PATCH] Cleanup (inlines and deprecates pointless wrapper) --- .../debugger/settings/TraceSettings.java | 7 +++--- .../properties/JavaBreakpointProperties.java | 7 +++--- .../ui/SingleInspectionProfilePanel.java | 4 ++-- .../intellij/ui/treeStructure/SimpleNode.java | 22 ++++--------------- .../openapi/keymap/impl/ui/ActionsTree.java | 18 ++------------- .../openapi/roots/impl/OrderEntryUtil.java | 19 +++------------- .../src/com/intellij/tasks/impl/TaskUtil.java | 2 +- .../com/intellij/openapi/util/Comparing.java | 7 ++---- .../src/com/intellij/util/ui/ColorsIcon.java | 19 ++-------------- .../vcs/changes/ui/IgnoredSettingsPanel.java | 6 ++--- .../GrImmediateClosureSignatureImpl.java | 9 ++++---- .../execution/junit/JUnitConfiguration.java | 4 +++- .../propertyTable/PropertyTablePanel.java | 5 +++-- 13 files changed, 38 insertions(+), 91 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/settings/TraceSettings.java b/java/debugger/impl/src/com/intellij/debugger/settings/TraceSettings.java index a4ec786c01eb..bb163005be1a 100644 --- a/java/debugger/impl/src/com/intellij/debugger/settings/TraceSettings.java +++ b/java/debugger/impl/src/com/intellij/debugger/settings/TraceSettings.java @@ -1,15 +1,16 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.debugger.settings; import com.intellij.openapi.components.PersistentStateComponent; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.components.State; import com.intellij.openapi.components.Storage; -import com.intellij.openapi.util.Comparing; import com.intellij.ui.classFilter.ClassFilter; import com.intellij.util.xmlb.annotations.XCollection; import org.jetbrains.annotations.NotNull; +import java.util.Arrays; + @State(name = "TraceSettings", storages = @Storage("debugger.xml")) public class TraceSettings implements PersistentStateComponent { private ClassFilter[] myClassFilters; @@ -30,7 +31,7 @@ public class TraceSettings implements PersistentStateComponent { if ((a == null || a.length == 0) && (b == null || b.length == 0)) { return true; } - return Comparing.equal(a, b); + return Arrays.equals(a, b); } @XCollection(propertyElementName = "class-exclusion-filters") diff --git a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaBreakpointProperties.java b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaBreakpointProperties.java index c15e1f2687c6..68d9dab4b85a 100644 --- a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaBreakpointProperties.java +++ b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaBreakpointProperties.java @@ -1,8 +1,7 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.java.debugger.breakpoints.properties; import com.intellij.debugger.InstanceFilter; -import com.intellij.openapi.util.Comparing; import com.intellij.ui.classFilter.ClassFilter; import com.intellij.util.ArrayUtil; import com.intellij.util.xmlb.annotations.OptionTag; @@ -11,6 +10,8 @@ import com.intellij.xdebugger.breakpoints.XBreakpointProperties; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.Arrays; + /** * @author egor */ @@ -68,7 +69,7 @@ public class JavaBreakpointProperties extend if ((a == null || a.length == 0) && (b == null || b.length == 0)) { return true; } - return Comparing.equal(a, b); + return Arrays.equals(a, b); } @XCollection(propertyElementName = "class-exclusion-filters") diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java index 721bbdfbcbe3..c4392523245f 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.profile.codeInspection.ui; @@ -1008,7 +1008,7 @@ public class SingleInspectionProfilePanel extends JPanel { if (myProfile.isChanged()) return true; if (myProfile.getSource().isProjectLevel() != myProfile.isProjectLevel()) return true; if (!Comparing.strEqual(myProfile.getSource().getName(), myProfile.getName())) return true; - if (!Comparing.equal(myInitialScopesOrder, myProfile.getScopesOrder())) return true; + if (!Arrays.equals(myInitialScopesOrder, myProfile.getScopesOrder())) return true; return descriptorsAreChanged(); } diff --git a/platform/platform-api/src/com/intellij/ui/treeStructure/SimpleNode.java b/platform/platform-api/src/com/intellij/ui/treeStructure/SimpleNode.java index b05579b867ee..84c8f71390c2 100644 --- a/platform/platform-api/src/com/intellij/ui/treeStructure/SimpleNode.java +++ b/platform/platform-api/src/com/intellij/ui/treeStructure/SimpleNode.java @@ -1,25 +1,10 @@ -/* - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ui.treeStructure; import com.intellij.ide.projectView.PresentationData; import com.intellij.ide.util.treeView.NodeDescriptor; import com.intellij.ide.util.treeView.PresentableNodeDescriptor; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Comparing; import com.intellij.openapi.vcs.FileStatus; import com.intellij.ui.JBColor; import com.intellij.ui.SimpleTextAttributes; @@ -34,6 +19,7 @@ import javax.swing.*; import java.awt.*; import java.awt.event.InputEvent; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; public abstract class SimpleNode extends PresentableNodeDescriptor implements ComparableObject, LeafState.Supplier { @@ -109,8 +95,8 @@ public abstract class SimpleNode extends PresentableNodeDescriptor implements Co myName = getName(); presentation.setPresentableText(myName); - presentation.setChanged(!Comparing.equal(new Object[]{getIcon(), myName, oldFragments, myColor}, - new Object[]{oldIcon, oldName, oldFragments, oldColor})); + presentation.setChanged(!Arrays.equals(new Object[]{getIcon(), myName, oldFragments, myColor}, + new Object[]{oldIcon, oldName, oldFragments, oldColor})); presentation.setForcedTextForeground(myColor); presentation.setIcon(getIcon()); diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ActionsTree.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ActionsTree.java index 47e2560b1c56..64aca3922fff 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ActionsTree.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ActionsTree.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.keymap.impl.ui; import com.intellij.icons.AllIcons; @@ -319,7 +305,7 @@ public class ActionsTree { Shortcut[] oldShortcuts = oldKeymap.getShortcuts(actionId); Shortcut[] newShortcuts = newKeymap.getShortcuts(actionId); - return !Comparing.equal(oldShortcuts, newShortcuts); + return !Arrays.equals(oldShortcuts, newShortcuts); } private static boolean isGroupChanged(Group group, Keymap oldKeymap, Keymap newKeymap) { diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/OrderEntryUtil.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/OrderEntryUtil.java index 119e2bda1144..4e4e98f4c2b4 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/OrderEntryUtil.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/OrderEntryUtil.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.roots.impl; import com.intellij.openapi.module.Module; @@ -28,6 +14,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; public class OrderEntryUtil { @@ -121,7 +108,7 @@ public class OrderEntryUtil { if (library2.getTable() != null) return false; for (OrderRootType type : OrderRootType.getAllTypes()) { - if (!Comparing.equal(library1.getUrls(type), library2.getUrls(type))) { + if (!Arrays.equals(library1.getUrls(type), library2.getUrls(type))) { return false; } } diff --git a/platform/tasks-platform-impl/src/com/intellij/tasks/impl/TaskUtil.java b/platform/tasks-platform-impl/src/com/intellij/tasks/impl/TaskUtil.java index c66d9c2befe6..a1e4f5500037 100644 --- a/platform/tasks-platform-impl/src/com/intellij/tasks/impl/TaskUtil.java +++ b/platform/tasks-platform-impl/src/com/intellij/tasks/impl/TaskUtil.java @@ -160,7 +160,7 @@ public class TaskUtil { if (!Comparing.equal(t1.getCreated(), t2.getCreated())) return false; if (!Comparing.equal(t1.getUpdated(), t2.getUpdated())) return false; if (!Comparing.equal(t1.getIssueUrl(), t2.getIssueUrl())) return false; - if (!Comparing.equal(t1.getComments(), t2.getComments())) return false; + if (!Arrays.equals(t1.getComments(), t2.getComments())) return false; if (!Comparing.equal(t1.getIcon(), t2.getIcon())) return false; if (!Comparing.equal(t1.getCustomIcon(), t2.getCustomIcon())) return false; return Comparing.equal(t1.getRepository(), t2.getRepository()); diff --git a/platform/util-rt/src/com/intellij/openapi/util/Comparing.java b/platform/util-rt/src/com/intellij/openapi/util/Comparing.java index 39e46211905a..7681968d898e 100644 --- a/platform/util-rt/src/com/intellij/openapi/util/Comparing.java +++ b/platform/util-rt/src/com/intellij/openapi/util/Comparing.java @@ -31,12 +31,9 @@ public class Comparing { return arg1.equals(arg2); } - @Contract(value = "null,!null -> false; !null,null -> false; null,null -> true", pure = true) + /** @deprecated same as {@link Arrays#equals(Object[], Object[])} */ + @Deprecated public static boolean equal(@Nullable T[] arr1, @Nullable T[] arr2) { - if (arr1 == null || arr2 == null) { - //noinspection ArrayEquality - return arr1 == arr2; - } return Arrays.equals(arr1, arr2); } diff --git a/platform/util/src/com/intellij/util/ui/ColorsIcon.java b/platform/util/src/com/intellij/util/ui/ColorsIcon.java index 8019c2bab8f7..c539624ed5f6 100644 --- a/platform/util/src/com/intellij/util/ui/ColorsIcon.java +++ b/platform/util/src/com/intellij/util/ui/ColorsIcon.java @@ -1,22 +1,7 @@ -/* - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.util.ui; import com.intellij.openapi.ui.GraphicsConfig; -import com.intellij.openapi.util.Comparing; import com.intellij.ui.Gray; import com.intellij.ui.JBColor; import com.intellij.ui.paint.RectanglePainter; @@ -113,7 +98,7 @@ public class ColorsIcon extends ColorIcon { if (getIconWidth() != icon.getIconWidth()) return false; if (getIconHeight() != icon.getIconHeight()) return false; - if (!Comparing.equal(myColors, icon.myColors)) return false; + if (!Arrays.equals(myColors, icon.myColors)) return false; return true; } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/IgnoredSettingsPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/IgnoredSettingsPanel.java index 87d8b5b115af..fab732660501 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/IgnoredSettingsPanel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/IgnoredSettingsPanel.java @@ -1,11 +1,10 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.vcs.changes.ui; import com.intellij.openapi.options.Configurable; import com.intellij.openapi.options.SearchableConfigurable; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Comparing; import com.intellij.openapi.vcs.VcsBundle; import com.intellij.openapi.vcs.changes.ChangeListManagerImpl; import com.intellij.openapi.vcs.changes.IgnoreSettingsType; @@ -19,6 +18,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; +import java.util.Arrays; import java.util.HashSet; import java.util.Set; @@ -110,7 +110,7 @@ public class IgnoredSettingsPanel implements SearchableConfigurable, Configurabl @Override public boolean isModified() { - return !Comparing.equal(myChangeListManager.getFilesToIgnore(), getItems()); + return !Arrays.equals(myChangeListManager.getFilesToIgnore(), getItems()); } @Override diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrImmediateClosureSignatureImpl.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrImmediateClosureSignatureImpl.java index 8432eeebedb1..7380550c3122 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrImmediateClosureSignatureImpl.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrImmediateClosureSignatureImpl.java @@ -1,8 +1,7 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.plugins.groovy.lang.psi.impl.signatures; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import org.jetbrains.annotations.NotNull; @@ -11,6 +10,8 @@ import org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignature; import org.jetbrains.plugins.groovy.lang.psi.api.types.GrClosureParameter; import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil; +import java.util.Arrays; + /** * @author Maxim.Medvedev */ @@ -96,8 +97,8 @@ public class GrImmediateClosureSignatureImpl implements GrSignature { @Override public boolean equals(Object obj) { if (obj instanceof GrSignature) { - return Comparing.equal(myParameters, ((GrSignature)obj).getParameters()) && - Comparing.equal(myIsVarargs, ((GrSignature)obj).isVarargs()); + return Arrays.equals(myParameters, ((GrSignature)obj).getParameters()) && + myIsVarargs == ((GrSignature)obj).isVarargs(); } return super.equals(obj); } diff --git a/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java b/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java index 145663dc3801..337f9560c904 100644 --- a/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java +++ b/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java @@ -622,6 +622,7 @@ public class JUnitConfiguration extends JavaTestConfigurationWithDiscoverySuppor private Map myEnvs = new LinkedHashMap<>(); private String myChangeList = "All"; + @Override public boolean equals(final Object object) { if (!(object instanceof Data)) return false; final Data second = (Data)object; @@ -636,12 +637,13 @@ public class JUnitConfiguration extends JavaTestConfigurationWithDiscoverySuppor Comparing.equal(FORK_MODE, second.FORK_MODE) && Comparing.equal(DIR_NAME, second.DIR_NAME) && Comparing.equal(CATEGORY_NAME, second.CATEGORY_NAME) && - Comparing.equal(UNIQUE_ID, second.UNIQUE_ID) && + Arrays.equals(UNIQUE_ID, second.UNIQUE_ID) && Comparing.equal(TAGS, second.TAGS) && Comparing.equal(REPEAT_MODE, second.REPEAT_MODE) && REPEAT_COUNT == second.REPEAT_COUNT; } + @Override public int hashCode() { return Comparing.hashcode(TEST_OBJECT) ^ Comparing.hashcode(getMainClassName()) ^ diff --git a/plugins/ui-designer-core/src/com/intellij/designer/propertyTable/PropertyTablePanel.java b/plugins/ui-designer-core/src/com/intellij/designer/propertyTable/PropertyTablePanel.java index 6755a947e5f7..703cdbc2e989 100644 --- a/plugins/ui-designer-core/src/com/intellij/designer/propertyTable/PropertyTablePanel.java +++ b/plugins/ui-designer-core/src/com/intellij/designer/propertyTable/PropertyTablePanel.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.designer.propertyTable; import com.intellij.designer.DesignerBundle; @@ -25,6 +25,7 @@ import javax.swing.event.ListSelectionListener; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.util.Arrays; /** * @author Alexander Lobas @@ -127,7 +128,7 @@ public final class PropertyTablePanel extends JPanel implements ListSelectionLis public void setArea(@Nullable DesignerEditorPanel designer, @Nullable EditableArea area) { PropertyTableTab[] tabs = designer == null ? null : designer.getPropertyTableTabs(); - if (!Comparing.equal(myTabs, tabs)) { + if (!Arrays.equals(myTabs, tabs)) { myTabs = tabs; myTabPanel.removeAll();