diff --git a/java/debugger/impl/intellij.java.debugger.impl.iml b/java/debugger/impl/intellij.java.debugger.impl.iml index ee3e3bc1212b..41bce589a612 100644 --- a/java/debugger/impl/intellij.java.debugger.impl.iml +++ b/java/debugger/impl/intellij.java.debugger.impl.iml @@ -38,8 +38,8 @@ - + diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/JavaSmartStepIntoHandler.java b/java/debugger/impl/src/com/intellij/debugger/actions/JavaSmartStepIntoHandler.java index 1f42259493b7..a2d882fea556 100644 --- a/java/debugger/impl/src/com/intellij/debugger/actions/JavaSmartStepIntoHandler.java +++ b/java/debugger/impl/src/com/intellij/debugger/actions/JavaSmartStepIntoHandler.java @@ -33,7 +33,7 @@ import com.intellij.util.containers.ContainerUtil; import com.sun.jdi.Location; import com.sun.jdi.Method; import com.sun.jdi.ReferenceType; -import gnu.trove.TObjectIntHashMap; +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import one.util.streamex.StreamEx; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -455,7 +455,7 @@ public class JavaSmartStepIntoHandler extends JvmSmartStepIntoHandler { } private static void visitLinesInstructions(Location location, boolean full, Set lines, MethodInsnVisitor visitor) { - TObjectIntHashMap myCounter = new TObjectIntHashMap<>(); + Object2IntOpenHashMap myCounter = new Object2IntOpenHashMap<>(); MethodBytecodeUtil.visit(location.method(), full ? Long.MAX_VALUE : location.codeIndex(), new MethodVisitor(Opcodes.API_VERSION) { boolean myLineMatch = false; @@ -481,8 +481,7 @@ public class JavaSmartStepIntoHandler extends JvmSmartStepIntoHandler { public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { if (myLineMatch) { String key = owner + "." + name + desc; - int currentCount = myCounter.get(key); - myCounter.put(key, currentCount + 1); + int currentCount = myCounter.addTo(key, 1); if (name.startsWith("access$")) { // bridge method ReferenceType cls = ContainerUtil.getFirstItem(location.virtualMachine().classesByName(Type.getObjectType(owner).getClassName())); diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/ThreadDumpAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/ThreadDumpAction.java index c7846f23c79f..5b49b9ba8fb8 100644 --- a/java/debugger/impl/src/com/intellij/debugger/actions/ThreadDumpAction.java +++ b/java/debugger/impl/src/com/intellij/debugger/actions/ThreadDumpAction.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-2020 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.actions; @@ -22,7 +22,7 @@ import com.intellij.unscramble.ThreadState; import com.intellij.util.SmartList; import com.intellij.xdebugger.XDebugSession; import com.sun.jdi.*; -import gnu.trove.TIntObjectHashMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -31,8 +31,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -public class ThreadDumpAction extends DumbAwareAction implements AnAction.TransparentUpdate { - +public final class ThreadDumpAction extends DumbAwareAction implements AnAction.TransparentUpdate { @Override public void actionPerformed(@NotNull AnActionEvent e) { final Project project = e.getProject(); @@ -159,7 +158,7 @@ public class ThreadDumpAction extends DumbAwareAction implements AnAction.Transp final List frames = threadReference.frames(); hasEmptyStack = frames.size() == 0; - final TIntObjectHashMap> lockedAt = new TIntObjectHashMap<>(); + final Int2ObjectOpenHashMap> lockedAt = new Int2ObjectOpenHashMap<>(); if (vmProxy.canGetMonitorFrameInfo()) { for (Object m : threadReference.ownedMonitorsAndFrames()) { if (m instanceof MonitorInfo) { // see JRE-937 diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/SuspendManagerUtil.java b/java/debugger/impl/src/com/intellij/debugger/engine/SuspendManagerUtil.java index 12709171d48d..729aab663c4e 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/SuspendManagerUtil.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/SuspendManagerUtil.java @@ -4,11 +4,11 @@ package com.intellij.debugger.engine; import com.intellij.debugger.jdi.ThreadReferenceProxyImpl; import com.intellij.openapi.diagnostic.Logger; import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.containers.SmartHashSet; import com.sun.jdi.request.EventRequest; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.HashSet; import java.util.Set; import java.util.stream.Collectors; @@ -50,7 +50,7 @@ public final class SuspendManagerUtil { DebuggerManagerThreadImpl.assertIsManagerThread(); return suspendManager.getEventContexts().stream() .filter(suspendContext -> suspendContext.suspends(thread)) - .collect(Collectors.toCollection(SmartHashSet::new)); + .collect(Collectors.toCollection(HashSet::new)); } @Nullable diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/HotSwapManager.java b/java/debugger/impl/src/com/intellij/debugger/impl/HotSwapManager.java index a3cec7d57ad1..2b48a73694ac 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/HotSwapManager.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/HotSwapManager.java @@ -1,4 +1,4 @@ -// 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. +// Copyright 2000-2020 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.impl; import com.intellij.debugger.JavaDebuggerBundle; @@ -15,7 +15,6 @@ import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.containers.JBIterable; -import gnu.trove.THashMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -96,7 +95,7 @@ public final class HotSwapManager { } } - public static Map> findModifiedClasses(List sessions, Map> generatedPaths) { + public static Map> findModifiedClasses(List sessions, Map> generatedPaths) { final Map> result = new HashMap<>(); List> sessionWithStamps = new ArrayList<>(); for (DebuggerSession session : sessions) { @@ -123,17 +122,17 @@ public final class HotSwapManager { } @NotNull - public static Map> scanForModifiedClasses(@NotNull List sessions, + public static Map> scanForModifiedClasses(@NotNull List sessions, @NotNull HotSwapProgress swapProgress) { return scanForModifiedClasses(sessions, null, swapProgress); } @NotNull - public static Map> scanForModifiedClasses(@NotNull List sessions, + public static Map> scanForModifiedClasses(@NotNull List sessions, @Nullable NotNullLazyValue> outputPaths, @NotNull HotSwapProgress swapProgress) { - final Map> modifiedClasses = new THashMap<>(); + final Map> modifiedClasses = new HashMap<>(); final MultiProcessCommand scanClassesCommand = new MultiProcessCommand(); swapProgress.setCancelWorker(() -> scanClassesCommand.cancel()); for (DebuggerSession debuggerSession : sessions) { diff --git a/java/debugger/impl/src/com/intellij/debugger/jdi/StackFrameProxyImpl.java b/java/debugger/impl/src/com/intellij/debugger/jdi/StackFrameProxyImpl.java index 40f95c2df5ee..6ab267bf88f4 100644 --- a/java/debugger/impl/src/com/intellij/debugger/jdi/StackFrameProxyImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/jdi/StackFrameProxyImpl.java @@ -15,15 +15,11 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.util.ThreeState; import com.intellij.util.containers.ContainerUtil; import com.sun.jdi.*; -import gnu.trove.THashMap; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; +import java.util.*; public class StackFrameProxyImpl extends JdiProxy implements StackFrameProxyEx { private static final Logger LOG = Logger.getInstance(StackFrameProxyImpl.class); @@ -307,7 +303,7 @@ public class StackFrameProxyImpl extends JdiProxy implements StackFrameProxyEx { } throw new EvaluateException(error.getMessage(), error); } - + @Override public Value getVariableValue(@NotNull LocalVariableProxy localVariable) throws EvaluateException { if (localVariable instanceof LocalVariableProxyImpl) { @@ -380,7 +376,7 @@ public class StackFrameProxyImpl extends JdiProxy implements StackFrameProxyEx { if (myAllValues == null) { try { StackFrame stackFrame = getStackFrame(); - myAllValues = new THashMap<>(stackFrame.getValues(stackFrame.visibleVariables())); + myAllValues = new HashMap<>(stackFrame.getValues(stackFrame.visibleVariables())); } catch (AbsentInformationException e) { throw EvaluateExceptionUtil.createEvaluateException(e); @@ -389,14 +385,14 @@ public class StackFrameProxyImpl extends JdiProxy implements StackFrameProxyEx { // extra logging for IDEA-141270 if (e.errorCode() == JvmtiError.INVALID_SLOT || e.errorCode() == JvmtiError.ABSENT_INFORMATION) { LOG.info(e); - myAllValues = new THashMap<>(); + myAllValues = new HashMap<>(); } else throw e; } catch (Exception e) { if (!getVirtualMachine().canBeModified()) { // do not care in read only vms LOG.debug(e); - myAllValues = new THashMap<>(); + myAllValues = new HashMap<>(); } else { throw e; diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapProgressImpl.java b/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapProgressImpl.java index 9bd6dc8deefc..4070b74efdba 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapProgressImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapProgressImpl.java @@ -30,7 +30,8 @@ import com.intellij.util.ui.update.MergingUpdateQueue; import com.intellij.util.ui.update.Update; import com.intellij.xdebugger.XDebugSession; import com.intellij.xdebugger.impl.XDebugSessionImpl; -import gnu.trove.TIntObjectHashMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.ints.IntIterator; import one.util.streamex.StreamEx; import org.jetbrains.annotations.NotNull; @@ -40,10 +41,10 @@ import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.List; -public class HotSwapProgressImpl extends HotSwapProgress { +public final class HotSwapProgressImpl extends HotSwapProgress { static final NotificationGroup NOTIFICATION_GROUP = NotificationGroup.toolWindowGroup("HotSwap", ToolWindowId.DEBUG); - private final TIntObjectHashMap> myMessages = new TIntObjectHashMap<>(); + private final Int2ObjectOpenHashMap> myMessages = new Int2ObjectOpenHashMap<>(); private final ProgressWindow myProgressWindow; private @NlsContexts.ProgressTitle String myTitle = JavaDebuggerBundle.message("progress.hot.swap.title"); private final MergingUpdateQueue myUpdateQueue; @@ -97,8 +98,8 @@ public class HotSwapProgressImpl extends HotSwapProgress { } else if (!myMessages.isEmpty()){ List messages = new ArrayList<>(); - for (int category : myMessages.keys()) { - messages.addAll(getMessages(category)); + for (IntIterator iterator = myMessages.keySet().iterator(); iterator.hasNext(); ) { + messages.addAll(getMessages(iterator.nextInt())); } notifyUser("", buildMessage(messages, false), NotificationType.INFORMATION); } @@ -158,7 +159,7 @@ public class HotSwapProgressImpl extends HotSwapProgress { } return res.toString(); } - + @Override public void addMessage(DebuggerSession session, final int type, final String text) { List messages = myMessages.get(type); diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java index 478ed3bff573..cc68fdba4add 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java @@ -54,7 +54,6 @@ import com.sun.jdi.ThreadReference; import com.sun.jdi.request.EventRequest; import com.sun.jdi.request.EventRequestManager; import com.sun.jdi.request.InvalidRequestStateException; -import gnu.trove.THashMap; import one.util.streamex.StreamEx; import org.jdom.Element; import org.jetbrains.annotations.NonNls; @@ -64,6 +63,7 @@ import org.jetbrains.java.debugger.breakpoints.properties.JavaExceptionBreakpoin import org.jetbrains.java.debugger.breakpoints.properties.JavaMethodBreakpointProperties; import javax.swing.*; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -304,7 +304,7 @@ public class BreakpointManager { private void doRead(@NotNull final Element parentNode) { ApplicationManager.getApplication().runReadAction(() -> { - final Map nameToBreakpointMap = new THashMap<>(); + final Map nameToBreakpointMap = new HashMap<>(); try { final List groups = parentNode.getChildren(); for (final Object group1 : groups) { diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTreeNodeExpression.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTreeNodeExpression.java index 544c0ab0ee69..dc79f017f8c8 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTreeNodeExpression.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTreeNodeExpression.java @@ -12,12 +12,12 @@ import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtil; import com.intellij.util.IncorrectOperationException; -import com.intellij.util.containers.SmartHashSet; import com.sun.jdi.ObjectReference; import com.sun.jdi.ReferenceType; import com.sun.jdi.Value; import org.jetbrains.annotations.Nullable; +import java.util.HashSet; import java.util.Set; public final class DebuggerTreeNodeExpression { @@ -99,7 +99,7 @@ public final class DebuggerTreeNodeExpression { ((PsiTypeCastExpression)parenthExpression.getExpression()).getOperand().replace(expression); Set imports = expression.getUserData(ADDITIONAL_IMPORTS_KEY); if (imports == null) { - imports = new SmartHashSet<>(); + imports = new HashSet<>(); } imports.add(typeName); parenthExpression.putUserData(ADDITIONAL_IMPORTS_KEY, imports); diff --git a/platform/code-style-api/intellij.platform.codeStyle.iml b/platform/code-style-api/intellij.platform.codeStyle.iml index 5af73ff07645..8adaf42eee15 100644 --- a/platform/code-style-api/intellij.platform.codeStyle.iml +++ b/platform/code-style-api/intellij.platform.codeStyle.iml @@ -16,6 +16,5 @@ - \ No newline at end of file diff --git a/platform/code-style-api/src/com/intellij/configurationStore/UnknownElementManager.kt b/platform/code-style-api/src/com/intellij/configurationStore/UnknownElementManager.kt index 8f2e092d8756..c29228957cb1 100644 --- a/platform/code-style-api/src/com/intellij/configurationStore/UnknownElementManager.kt +++ b/platform/code-style-api/src/com/intellij/configurationStore/UnknownElementManager.kt @@ -1,8 +1,6 @@ // Copyright 2000-2020 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.configurationStore -import gnu.trove.THashMap -import gnu.trove.THashSet import org.jdom.Element import java.util.function.Consumer import java.util.function.Function @@ -15,7 +13,7 @@ internal class UnknownElementWriter internal constructor(private val unknownElem } fun write(outElement: Element, items: Collection, itemToTagName: Function, writer: Consumer) { - val knownNameToWriter = THashMap(items.size) + val knownNameToWriter = HashMap(items.size) for (item in items) { knownNameToWriter.put(itemToTagName.apply(item), item) } @@ -47,7 +45,7 @@ internal class UnknownElementWriter internal constructor(private val unknownElem } internal class UnknownElementCollector { - private val knownTagNames = THashSet() + private val knownTagNames = HashSet() fun addKnownName(name: String) { knownTagNames.add(name) @@ -59,7 +57,7 @@ internal class UnknownElementCollector { for (child in iterator) { if (child.name != "option" && !knownTagNames.contains(child.name)) { if (unknownElements == null) { - unknownElements = THashMap() + unknownElements = HashMap() } unknownElements.put(child.name, child) iterator.remove() diff --git a/platform/code-style-api/src/com/intellij/formatting/DependentSpacingRule.java b/platform/code-style-api/src/com/intellij/formatting/DependentSpacingRule.java index 875f9e34e4ba..6ca865108fab 100644 --- a/platform/code-style-api/src/com/intellij/formatting/DependentSpacingRule.java +++ b/platform/code-style-api/src/com/intellij/formatting/DependentSpacingRule.java @@ -1,33 +1,16 @@ -/* - * Copyright 2000-2012 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-2020 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.formatting; import com.intellij.openapi.util.TextRange; -import gnu.trove.TObjectIntHashMap; +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import org.jetbrains.annotations.NotNull; /** * Holds settings that should be used if * {@link Spacing#createDependentLFSpacing(int, int, TextRange, boolean, int, DependentSpacingRule) dependent spacing} * target region changes its 'contains line feeds' status. - * - * @author Denis Zhdanov */ -public class DependentSpacingRule { - +public final class DependentSpacingRule { public enum Anchor { MIN_LINE_FEEDS, MAX_LINE_FEEDS } @@ -39,7 +22,7 @@ public class DependentSpacingRule { public static final DependentSpacingRule DEFAULT = new DependentSpacingRule(Trigger.HAS_LINE_FEEDS).registerData(Anchor.MIN_LINE_FEEDS, 1); - private final TObjectIntHashMap myData = new TObjectIntHashMap<>(); + private final Object2IntOpenHashMap myData = new Object2IntOpenHashMap<>(); @NotNull private final Trigger myTrigger; @@ -87,6 +70,6 @@ public class DependentSpacingRule { "No data is registered for the dependent spacing rule %s. Registered: %s", anchor, myData )); } - return myData.get(anchor); + return myData.getInt(anchor); } } diff --git a/platform/code-style-api/src/com/intellij/psi/codeStyle/CommonCodeStyleSettingsManager.java b/platform/code-style-api/src/com/intellij/psi/codeStyle/CommonCodeStyleSettingsManager.java index 79deded8d343..c1684cdd121a 100644 --- a/platform/code-style-api/src/com/intellij/psi/codeStyle/CommonCodeStyleSettingsManager.java +++ b/platform/code-style-api/src/com/intellij/psi/codeStyle/CommonCodeStyleSettingsManager.java @@ -9,7 +9,6 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.ArrayUtilRt; import com.intellij.util.ObjectUtils; import com.intellij.util.containers.ContainerUtil; -import gnu.trove.THashMap; import org.jdom.Content; import org.jdom.Element; import org.jetbrains.annotations.NonNls; @@ -17,6 +16,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Arrays; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; @@ -202,7 +202,7 @@ final class CommonCodeStyleSettingsManager { return; } - final Map idToLang = new THashMap<>(); + final Map idToLang = new HashMap<>(); for (Language language : myCommonSettingsMap.keySet()) { idToLang.put(language.getID(), language); } diff --git a/platform/code-style-api/src/com/intellij/psi/codeStyle/arrangement/DefaultArrangementSettingsSerializer.java b/platform/code-style-api/src/com/intellij/psi/codeStyle/arrangement/DefaultArrangementSettingsSerializer.java index 3977d8797a7c..470fa7af6b45 100644 --- a/platform/code-style-api/src/com/intellij/psi/codeStyle/arrangement/DefaultArrangementSettingsSerializer.java +++ b/platform/code-style-api/src/com/intellij/psi/codeStyle/arrangement/DefaultArrangementSettingsSerializer.java @@ -1,4 +1,4 @@ -// 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. +// Copyright 2000-2020 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.psi.codeStyle.arrangement; import com.intellij.openapi.diagnostic.Logger; @@ -8,7 +8,6 @@ import com.intellij.psi.codeStyle.arrangement.match.*; import com.intellij.psi.codeStyle.arrangement.std.*; import com.intellij.util.SmartList; import com.intellij.util.containers.ContainerUtil; -import gnu.trove.THashSet; import org.jdom.Attribute; import org.jdom.Element; import org.jetbrains.annotations.NonNls; @@ -16,6 +15,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Set; @@ -145,7 +145,7 @@ public class DefaultArrangementSettingsSerializer implements ArrangementSettings return ((ArrangementExtendableSettings)myDefaultSettings).getRuleAliases(); } - final Set tokenDefinitions = new THashSet<>(); + final Set tokenDefinitions = new HashSet<>(); final List tokens = tokensRoot.getChildren(TOKEN_ELEMENT_NAME); for (Element token : tokens) { final Attribute id = token.getAttribute(TOKEN_ID); diff --git a/platform/code-style-api/src/com/intellij/psi/codeStyle/arrangement/std/StdArrangementExtendableSettings.java b/platform/code-style-api/src/com/intellij/psi/codeStyle/arrangement/std/StdArrangementExtendableSettings.java index 40494ac5f89a..571921eb85ba 100644 --- a/platform/code-style-api/src/com/intellij/psi/codeStyle/arrangement/std/StdArrangementExtendableSettings.java +++ b/platform/code-style-api/src/com/intellij/psi/codeStyle/arrangement/std/StdArrangementExtendableSettings.java @@ -1,4 +1,4 @@ -// 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. +// Copyright 2000-2020 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.psi.codeStyle.arrangement.std; import com.intellij.psi.codeStyle.arrangement.ArrangementExtendableSettings; @@ -14,8 +14,6 @@ import com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition; import com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchConditionVisitor; import com.intellij.util.SmartList; import com.intellij.util.containers.ContainerUtil; -import gnu.trove.THashMap; -import gnu.trove.THashSet; import org.jetbrains.annotations.NotNull; import java.util.*; @@ -23,8 +21,8 @@ import java.util.*; /** * @author Svetlana.Zemlyanskaya */ -public class StdArrangementExtendableSettings extends StdArrangementSettings implements ArrangementExtendableSettings { - @NotNull private final Set myRulesAliases = new THashSet<>(); +public final class StdArrangementExtendableSettings extends StdArrangementSettings implements ArrangementExtendableSettings { + @NotNull private final Set myRulesAliases = new HashSet<>(); // cached values @NotNull private final List myExtendedSectionRules = Collections.synchronizedList(new ArrayList<>()); @@ -34,7 +32,7 @@ public class StdArrangementExtendableSettings extends StdArrangementSettings imp } public StdArrangementExtendableSettings(@NotNull List groupingRules, - @NotNull List sectionRules, + @NotNull List sectionRules, @NotNull Collection rulesAliases) { super(groupingRules, sectionRules); myRulesAliases.addAll(rulesAliases); @@ -56,7 +54,7 @@ public class StdArrangementExtendableSettings extends StdArrangementSettings imp } private Set cloneTokenDefinitions() { - final Set definitions = new THashSet<>(); + final Set definitions = new HashSet<>(); for (StdArrangementRuleAliasToken definition : myRulesAliases) { definitions.add(definition.clone()); } @@ -67,7 +65,7 @@ public class StdArrangementExtendableSettings extends StdArrangementSettings imp public List getExtendedSectionRules() { synchronized (myExtendedSectionRules) { if (myExtendedSectionRules.isEmpty()) { - final Map tokenIdToDefinition = new THashMap<>(myRulesAliases.size()); + final Map tokenIdToDefinition = new HashMap<>(myRulesAliases.size()); for (StdArrangementRuleAliasToken alias : myRulesAliases) { final String id = alias.getId(); tokenIdToDefinition.put(id, alias); diff --git a/platform/core-api/src/com/intellij/lang/LanguageExtension.java b/platform/core-api/src/com/intellij/lang/LanguageExtension.java index c80d3c7e3b4f..c523b26f4a06 100644 --- a/platform/core-api/src/com/intellij/lang/LanguageExtension.java +++ b/platform/core-api/src/com/intellij/lang/LanguageExtension.java @@ -6,18 +6,12 @@ import com.intellij.openapi.util.Key; import com.intellij.openapi.util.KeyedExtensionCollector; import com.intellij.util.KeyedLazyInstance; import com.intellij.util.containers.ContainerUtil; -import gnu.trove.THashSet; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import static com.intellij.lang.LanguageUtil.matchingMetaLanguages; +import java.util.*; public class LanguageExtension extends KeyedExtensionCollector { private final T myDefaultImplementation; @@ -60,7 +54,7 @@ public class LanguageExtension extends KeyedExtensionCollector { for (Language derivedLanguage : languages) { clearCacheForLanguage(derivedLanguage); - Collection metaLanguages = matchingMetaLanguages(derivedLanguage); + Collection metaLanguages = LanguageUtil.matchingMetaLanguages(derivedLanguage); for (MetaLanguage metaLanguage : metaLanguages) { clearCacheForLanguage(metaLanguage); } @@ -148,12 +142,12 @@ public class LanguageExtension extends KeyedExtensionCollector { @NotNull @Override protected List buildExtensions(@NotNull String stringKey, @NotNull Language key) { - Collection metaLanguages = matchingMetaLanguages(key); + Collection metaLanguages = LanguageUtil.matchingMetaLanguages(key); if (metaLanguages.isEmpty()) { return super.buildExtensions(stringKey, key); } - Set allKeys = new THashSet<>(); + Set allKeys = new HashSet<>(); allKeys.add(stringKey); for (MetaLanguage language : metaLanguages) { allKeys.add(keyToString(language)); diff --git a/platform/indexing-impl/src/com/intellij/ide/todo/TodoFilter.java b/platform/indexing-impl/src/com/intellij/ide/todo/TodoFilter.java index c2e8d353d4ff..004010022c77 100644 --- a/platform/indexing-impl/src/com/intellij/ide/todo/TodoFilter.java +++ b/platform/indexing-impl/src/com/intellij/ide/todo/TodoFilter.java @@ -1,18 +1,4 @@ -/* - * 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-2020 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.ide.todo; import com.intellij.openapi.diagnostic.Logger; @@ -21,7 +7,6 @@ import com.intellij.psi.PsiFile; import com.intellij.psi.search.PsiTodoSearchHelper; import com.intellij.psi.search.TodoPattern; import com.intellij.util.ArrayUtilRt; -import com.intellij.util.containers.SmartHashSet; import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -31,7 +16,7 @@ import java.util.Iterator; import java.util.List; import java.util.Set; -public class TodoFilter implements Cloneable { +public final class TodoFilter implements Cloneable { private static final Logger LOG = Logger.getInstance(TodoFilter.class); private static final @NonNls String ATTRIBUTE_NAME = "name"; @@ -43,12 +28,12 @@ public class TodoFilter implements Cloneable { public TodoFilter() { setName(""); - myTodoPatterns = new SmartHashSet<>(); + myTodoPatterns = new HashSet<>(); } - public TodoFilter(@NotNull Element element, @NotNull List patterns) { + public TodoFilter(@NotNull Element element, @NotNull List patterns) { setName(""); - myTodoPatterns = new SmartHashSet<>(); + myTodoPatterns = new HashSet<>(); readExternal(element, patterns); } @@ -116,7 +101,7 @@ public class TodoFilter implements Cloneable { return myTodoPatterns.isEmpty(); } - private void readExternal(@NotNull Element element, @NotNull List patterns) { + private void readExternal(@NotNull Element element, @NotNull List patterns) { myName = element.getAttributeValue(ATTRIBUTE_NAME); if (myName == null) { throw new IllegalArgumentException(); diff --git a/platform/indexing-impl/src/com/intellij/psi/impl/cache/impl/BaseFilterLexerUtil.java b/platform/indexing-impl/src/com/intellij/psi/impl/cache/impl/BaseFilterLexerUtil.java index 8d5f5f1c1782..078626045a13 100644 --- a/platform/indexing-impl/src/com/intellij/psi/impl/cache/impl/BaseFilterLexerUtil.java +++ b/platform/indexing-impl/src/com/intellij/psi/impl/cache/impl/BaseFilterLexerUtil.java @@ -12,10 +12,10 @@ import com.intellij.psi.impl.cache.impl.todo.TodoIndexers; import com.intellij.psi.search.IndexPattern; import com.intellij.testFramework.LightVirtualFile; import com.intellij.util.indexing.FileContent; -import gnu.trove.THashMap; import org.jetbrains.annotations.NotNull; import java.util.Collections; +import java.util.HashMap; import java.util.Map; public final class BaseFilterLexerUtil { @@ -57,7 +57,9 @@ public final class BaseFilterLexerUtil { for (IndexPattern indexPattern : todoPatterns) { final int count = todoOccurrenceConsumer.getOccurrenceCount(indexPattern); if (count > 0) { - if (todoMap == null) todoMap = new THashMap<>(); + if (todoMap == null) { + todoMap = new HashMap<>(); + } todoMap.put(new TodoIndexEntry(indexPattern.getPatternString(), indexPattern.isCaseSensitive()), count); } } @@ -69,7 +71,7 @@ public final class BaseFilterLexerUtil { ); } - public static class ScanContent { + public static final class ScanContent { public final Map idMap; public final Map todoMap; diff --git a/platform/indexing-impl/src/com/intellij/psi/impl/cache/impl/OccurrenceConsumer.java b/platform/indexing-impl/src/com/intellij/psi/impl/cache/impl/OccurrenceConsumer.java index b3dd02244572..c13ed38c382c 100644 --- a/platform/indexing-impl/src/com/intellij/psi/impl/cache/impl/OccurrenceConsumer.java +++ b/platform/indexing-impl/src/com/intellij/psi/impl/cache/impl/OccurrenceConsumer.java @@ -1,36 +1,25 @@ -/* - * Copyright 2000-2011 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-2020 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.psi.impl.cache.impl; import com.intellij.psi.impl.cache.impl.id.IdDataConsumer; import com.intellij.psi.search.IndexPattern; -import gnu.trove.TObjectIntHashMap; +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; public final class OccurrenceConsumer { private final IdDataConsumer myIndexDataConsumer; - private TObjectIntHashMap myTodoOccurrences; + private Object2IntOpenHashMap myTodoOccurrences; private final boolean myNeedToDo; - public OccurrenceConsumer(final IdDataConsumer indexDataConsumer, boolean needToDo) { + public OccurrenceConsumer(IdDataConsumer indexDataConsumer, boolean needToDo) { myIndexDataConsumer = indexDataConsumer; myNeedToDo = needToDo; } public void addOccurrence(final CharSequence charSequence, char[] charArray, final int start, final int end, final int occurrenceMask) { - if (myIndexDataConsumer == null) return; + if (myIndexDataConsumer == null) { + return; + } + if (charArray != null) { myIndexDataConsumer.addOccurrence(charArray, start, end, occurrenceMask); } @@ -40,15 +29,14 @@ public final class OccurrenceConsumer { } public void incTodoOccurrence(final IndexPattern pattern) { - if (myTodoOccurrences == null) myTodoOccurrences = new TObjectIntHashMap<>(); - if (!myTodoOccurrences.increment(pattern)) { - myTodoOccurrences.put(pattern, 1); + if (myTodoOccurrences == null) { + myTodoOccurrences = new Object2IntOpenHashMap<>(); } + myTodoOccurrences.addTo(pattern, 1); } public int getOccurrenceCount(IndexPattern pattern) { - if (myTodoOccurrences == null) return 0; - return myTodoOccurrences.get(pattern); + return myTodoOccurrences == null ? 0 : myTodoOccurrences.getInt(pattern); } public boolean isNeedToDo() { diff --git a/platform/indexing-impl/src/com/intellij/psi/impl/search/PsiSearchHelperImpl.java b/platform/indexing-impl/src/com/intellij/psi/impl/search/PsiSearchHelperImpl.java index 822eb0abb6e5..603b99070046 100644 --- a/platform/indexing-impl/src/com/intellij/psi/impl/search/PsiSearchHelperImpl.java +++ b/platform/indexing-impl/src/com/intellij/psi/impl/search/PsiSearchHelperImpl.java @@ -41,14 +41,13 @@ import com.intellij.util.SmartList; import com.intellij.util.codeInsight.CommentUtilCore; import com.intellij.util.containers.CollectionFactory; import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.containers.ObjectIntHashMap; import com.intellij.util.indexing.DumbModeAccessType; import com.intellij.util.indexing.FileBasedIndex; import com.intellij.util.indexing.IndexingBundle; import com.intellij.util.text.StringSearcher; -import gnu.trove.THashMap; -import gnu.trove.THashSet; import it.unimi.dsi.fastutil.ints.IntOpenHashSet; +import it.unimi.dsi.fastutil.objects.Object2IntMap; +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -227,7 +226,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper { StringSearcher searcher = new StringSearcher(text, options.contains(Options.CASE_SENSITIVE_SEARCH), true, searchContext == UsageSearchContext.IN_STRINGS, options.contains(Options.PROCESS_ONLY_JAVA_IDENTIFIERS_IF_POSSIBLE)); - ReadActionProcessor localProcessor = new ReadActionProcessor() { + ReadActionProcessor localProcessor = new ReadActionProcessor<>() { @Override public boolean processInReadAction(PsiElement scopeElement) { if (!scopeElement.isValid()) return true; @@ -268,7 +267,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper { @NotNull static Processor localProcessor(@NotNull StringSearcher searcher, @NotNull BulkOccurrenceProcessor processor) { - return new ReadActionProcessor() { + return new ReadActionProcessor<>() { @Override public boolean processInReadAction(PsiElement scopeElement) { if (scopeElement instanceof PsiCompiledElement) { @@ -327,7 +326,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper { @Nullable String containerName, @NotNull SearchSession session) { String text = searcher.getPattern(); - Set allFiles = new THashSet<>(); + Set allFiles = new HashSet<>(); getFilesWithText(scope, searchContext, caseSensitively, text, allFiles); List> priorities = new ArrayList<>(); @@ -359,7 +358,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper { directories = Collections.emptyList(); } if (containerName != null) { - Set intersectionWithContainerFiles = new THashSet<>(); + Set intersectionWithContainerFiles = new HashSet<>(); // intersectionWithContainerFiles holds files containing words from both `text` and `containerName` getFilesWithText(scope, searchContext, caseSensitively, text+" "+containerName, intersectionWithContainerFiles); intersectionWithContainerFiles.removeAll(targets); @@ -508,7 +507,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper { // we failed to run read action in job launcher thread // run read action in our thread instead to wait for a write action to complete and resume parallel processing DumbService.getInstance(project).runReadActionInSmartMode(EmptyRunnable.getInstance()); - Set t = new THashSet<>(files); + Set t = new HashSet<>(files); synchronized (processedFiles) { t.removeAll(processedFiles); } @@ -530,7 +529,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper { } List psiRoots = file.getViewProvider().getAllFiles(); - Set processed = new THashSet<>(psiRoots.size() * 2, (float)0.5); + Set processed = new HashSet<>(psiRoots.size() * 2, (float)0.5); for (PsiFile psiRoot : psiRoots) { ProgressManager.checkCanceled(); assert psiRoot != null : "One of the roots of file " + file + " is null. All roots: " + psiRoots + "; ViewProvider: " + @@ -756,7 +755,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper { Map> globals = new HashMap<>(); List> customs = new ArrayList<>(); Set locals = new LinkedHashSet<>(); - Map> localProcessors = new THashMap<>(); + Map> localProcessors = new HashMap<>(); distributePrimitives(collectors, locals, globals, customs, localProcessors); if (!processGlobalRequestsOptimized(globals, progress, localProcessors)) { return false; @@ -978,7 +977,8 @@ public class PsiSearchHelperImpl implements PsiSearchHelper { Set intersectionWithContainerNameFiles = intersectionWithContainerNameFiles(commonScope, processors, key); List allFilesForKeys = new ArrayList<>(); processFilesContainingAllKeys(myManager.getProject(), commonScope, Processors.cancelableCollectProcessor(allFilesForKeys), key); - ObjectIntHashMap file2Mask = new ObjectIntHashMap<>(); + Object2IntOpenHashMap file2Mask = new Object2IntOpenHashMap<>(); + file2Mask.defaultReturnValue(-1); IntRef maskRef = new IntRef(); for (VirtualFile file : allFilesForKeys) { ProgressManager.checkCanceled(); @@ -990,11 +990,14 @@ public class PsiSearchHelperImpl implements PsiSearchHelper { maskRef.set(value); return true; }, commonScope)); - int oldMask = file2Mask.get(file, UsageSearchContext.ANY); + int oldMask = file2Mask.getOrDefault(file, UsageSearchContext.ANY); file2Mask.put(file, oldMask & maskRef.get()); } } - file2Mask.forEachEntry((file, mask)->{ + + for (Object2IntMap.Entry fileEntry : file2Mask.object2IntEntrySet()) { + VirtualFile file = fileEntry.getKey(); + int mask = fileEntry.getIntValue(); myDumbService.runReadActionInSmartMode(() -> { Map> result = thisTargetFiles.contains(file) @@ -1011,8 +1014,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper { } } }); - return true; - }); + } totalSize += allFilesForKeys.size(); } return totalSize; @@ -1047,7 +1049,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper { TextIndexQuery commonNameQuery = TextIndexQuery.fromWord(commonName, caseSensitive, searchContext); - Set containerFiles = new THashSet<>(); + Set containerFiles = new HashSet<>(); Processor processor = Processors.cancelableCollectProcessor(containerFiles); processFilesContainingAllKeys(myManager.getProject(), commonScope, processor, query, commonNameQuery); @@ -1141,7 +1143,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper { AtomicInteger filesCount = new AtomicInteger(); AtomicLong filesSizeToProcess = new AtomicLong(); - Processor processor = new Processor() { + Processor processor = new Processor<>() { private final VirtualFile virtualFileToIgnoreOccurrencesIn = fileToIgnoreOccurrencesIn == null ? null : fileToIgnoreOccurrencesIn.getVirtualFile(); private final int maxFilesToProcess = Registry.intValue("ide.unused.symbol.calculation.maxFilesToSearchUsagesIn", 10); diff --git a/platform/indexing-impl/src/com/intellij/psi/stubs/ByteArrayInterner.java b/platform/indexing-impl/src/com/intellij/psi/stubs/ByteArrayInterner.java index 10bb873cb323..436a1e4ba3a3 100644 --- a/platform/indexing-impl/src/com/intellij/psi/stubs/ByteArrayInterner.java +++ b/platform/indexing-impl/src/com/intellij/psi/stubs/ByteArrayInterner.java @@ -2,8 +2,8 @@ package com.intellij.psi.stubs; import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream; -import gnu.trove.TObjectHashingStrategy; -import gnu.trove.TObjectIntHashMap; +import it.unimi.dsi.fastutil.Hash; +import it.unimi.dsi.fastutil.objects.Object2IntOpenCustomHashMap; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; @@ -11,9 +11,9 @@ import java.util.Arrays; @ApiStatus.Internal final class ByteArrayInterner { - private static final TObjectHashingStrategy BYTE_ARRAY_STRATEGY = new TObjectHashingStrategy() { + private static final Hash.Strategy BYTE_ARRAY_STRATEGY = new Hash.Strategy<>() { @Override - public int computeHashCode(byte[] object) { + public int hashCode(byte[] object) { return Arrays.hashCode(object); } @@ -22,13 +22,13 @@ final class ByteArrayInterner { return Arrays.equals(o1, o2); } }; - private final TObjectIntHashMap arrayToStart = new TObjectIntHashMap<>(BYTE_ARRAY_STRATEGY); + private final Object2IntOpenCustomHashMap arrayToStart = new Object2IntOpenCustomHashMap<>(BYTE_ARRAY_STRATEGY); final BufferExposingByteArrayOutputStream joinedBuffer = new BufferExposingByteArrayOutputStream(); int internBytes(byte @NotNull [] bytes) { if (bytes.length == 0) return 0; - int start = arrayToStart.get(bytes); + int start = arrayToStart.getInt(bytes); if (start == 0) { start = joinedBuffer.size() + 1; // should be positive arrayToStart.put(bytes, start); diff --git a/platform/indexing-impl/src/com/intellij/psi/stubs/FileLocalStringEnumerator.java b/platform/indexing-impl/src/com/intellij/psi/stubs/FileLocalStringEnumerator.java index 2b79f6d885e8..63307fed8cce 100644 --- a/platform/indexing-impl/src/com/intellij/psi/stubs/FileLocalStringEnumerator.java +++ b/platform/indexing-impl/src/com/intellij/psi/stubs/FileLocalStringEnumerator.java @@ -4,7 +4,7 @@ package com.intellij.psi.stubs; import com.intellij.util.io.AbstractStringEnumerator; import com.intellij.util.io.DataInputOutputUtil; import com.intellij.util.io.IOUtil; -import gnu.trove.TObjectIntHashMap; +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -17,18 +17,20 @@ import java.util.function.UnaryOperator; @ApiStatus.Internal final class FileLocalStringEnumerator implements AbstractStringEnumerator { - private final TObjectIntHashMap myEnumerates; + private final Object2IntOpenHashMap myEnumerates; private final ArrayList myStrings = new ArrayList<>(); FileLocalStringEnumerator(boolean forSavingStub) { - myEnumerates = forSavingStub ? new TObjectIntHashMap<>() : null; + myEnumerates = forSavingStub ? new Object2IntOpenHashMap<>() : null; } @Override public int enumerate(@Nullable String value) { - if (value == null) return 0; + if (value == null) { + return 0; + } assert myEnumerates != null; // enumerate possible only when writing stub - int i = myEnumerates.get(value); + int i = myEnumerates.getInt(value); if (i == 0) { myEnumerates.put(value, i = myStrings.size() + 1); myStrings.add(value); diff --git a/platform/indexing-impl/src/com/intellij/psi/stubs/StubForwardIndexExternalizer.java b/platform/indexing-impl/src/com/intellij/psi/stubs/StubForwardIndexExternalizer.java index 296fefa34eb2..7ca9c27104f3 100644 --- a/platform/indexing-impl/src/com/intellij/psi/stubs/StubForwardIndexExternalizer.java +++ b/platform/indexing-impl/src/com/intellij/psi/stubs/StubForwardIndexExternalizer.java @@ -5,7 +5,6 @@ import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream; import com.intellij.util.SystemProperties; import com.intellij.util.indexing.ID; import com.intellij.util.io.*; -import gnu.trove.THashMap; import it.unimi.dsi.fastutil.Hash; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap; import org.jetbrains.annotations.ApiStatus; @@ -17,6 +16,7 @@ import java.io.DataInputStream; import java.io.DataOutput; import java.io.IOException; import java.util.Collections; +import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.function.UnaryOperator; @@ -70,7 +70,7 @@ public abstract class StubForwardIndexExternalizer im Map, Map> doRead(@NotNull DataInput in, @Nullable StubIndexKey requestedIndex, @Nullable K requestedKey) throws IOException { int stubIndicesValueMapSize = DataInputOutputUtil.readINT(in); if (stubIndicesValueMapSize > 0) { - THashMap, Map> stubIndicesValueMap = requestedIndex != null ? null : new THashMap<>(stubIndicesValueMapSize); + Map, Map> stubIndicesValueMap = requestedIndex != null ? null : new HashMap<>(stubIndicesValueMapSize); StubKeySerializationState stubKeySerializationState = createStubIndexKeySerializationState(in, stubIndicesValueMapSize); for (int i = 0; i < stubIndicesValueMapSize; ++i) { ID indexKey = (ID)readStubIndexKey(in, stubKeySerializationState); @@ -83,10 +83,12 @@ public abstract class StubForwardIndexExternalizer im return Collections.singletonMap(requestedIndex, value); } stubIndicesValueMap.put(stubIndexKey, value); - } else { + } + else { skipIndexValue(in); } - } else { + } + else { // key is deleted, just properly skip bytes (used while index update) assert indexKey == null : "indexKey '" + indexKey + "' is not a StubIndexKey"; skipIndexValue(in); diff --git a/platform/indexing-impl/src/com/intellij/util/indexing/AdditionalIndexableFileSet.java b/platform/indexing-impl/src/com/intellij/util/indexing/AdditionalIndexableFileSet.java index 614671f10c60..67b25555a6a9 100644 --- a/platform/indexing-impl/src/com/intellij/util/indexing/AdditionalIndexableFileSet.java +++ b/platform/indexing-impl/src/com/intellij/util/indexing/AdditionalIndexableFileSet.java @@ -8,14 +8,14 @@ import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.psi.util.CachedValue; import com.intellij.psi.util.CachedValueProvider; import com.intellij.util.CachedValueImpl; -import gnu.trove.THashSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.HashSet; import java.util.Set; import java.util.function.Supplier; -public class AdditionalIndexableFileSet implements IndexableFileSet { +public final class AdditionalIndexableFileSet implements IndexableFileSet { @Nullable private final Project myProject; private final Supplier myExtensions; @@ -39,8 +39,8 @@ public class AdditionalIndexableFileSet implements IndexableFileSet { @NotNull private AdditionalIndexableFileSet.AdditionalIndexableRoots collectFilesAndDirectories() { - Set files = new THashSet<>(); - Set directories = new THashSet<>(); + Set files = new HashSet<>(); + Set directories = new HashSet<>(); for (IndexableSetContributor contributor : myExtensions.get()) { for (VirtualFile root : IndexableSetContributor.getRootsToIndex(contributor)) { (root.isDirectory() ? directories : files).add(root); diff --git a/platform/lang-api/testSources/com/intellij/psi/codeStyle/arrangement/ArrangementSettingsSerializationTest.java b/platform/lang-api/testSources/com/intellij/psi/codeStyle/arrangement/ArrangementSettingsSerializationTest.java index cdb65120abc5..f2c7aceae469 100644 --- a/platform/lang-api/testSources/com/intellij/psi/codeStyle/arrangement/ArrangementSettingsSerializationTest.java +++ b/platform/lang-api/testSources/com/intellij/psi/codeStyle/arrangement/ArrangementSettingsSerializationTest.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2012 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-2020 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.psi.codeStyle.arrangement; import com.intellij.psi.codeStyle.arrangement.group.ArrangementGroupingRule; @@ -47,9 +33,6 @@ import static com.intellij.psi.codeStyle.arrangement.std.StdArrangementTokens.Mo import static com.intellij.psi.codeStyle.arrangement.std.StdArrangementTokens.Order.BY_NAME; import static org.junit.Assert.*; -/** - * @author Denis Zhdanov - */ public class ArrangementSettingsSerializationTest { private static final String VISIBILITY = "visibility"; private static final String MODIFIERS = "modifiers"; @@ -85,12 +68,12 @@ public class ArrangementSettingsSerializationTest { } private static StdArrangementSettings settings(@NotNull List groupings, - @NotNull List sections) { + @NotNull List sections) { return new StdArrangementSettings(groupings, sections); } private static StdArrangementExtendableSettings extendableSettings(@NotNull List groupings, - @NotNull List sections, + @NotNull List sections, @NotNull Collection tokens) { return new StdArrangementExtendableSettings(groupings, sections, tokens); } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogJoiner.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogJoiner.java index b994e2230ab8..bd0e68d6ab9c 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogJoiner.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogJoiner.java @@ -4,22 +4,18 @@ package com.intellij.vcs.log.data; import com.intellij.openapi.util.Pair; import com.intellij.util.containers.ContainerUtil; import com.intellij.vcs.log.graph.GraphCommit; -import gnu.trove.THashSet; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import java.util.*; -import static com.intellij.util.containers.ContainerUtil.getFirstItem; - /** * Attaches the block of latest commits, which was read from the VCS, to the existing log structure. * * @author Stanislav Erokhin * @author Kirill Likhodedov */ -public class VcsLogJoiner> { - +public final class VcsLogJoiner> { @NonNls public final static String ILLEGAL_DATA_RELOAD_ALL = "All data is illegal - request reload all"; /** @@ -63,7 +59,7 @@ public class VcsLogJoiner> { @NotNull Collection previousRefs, @NotNull List firstBlock, @NotNull Collection newRefs) { - Set allUnresolvedLinkedHashes = new THashSet<>(newRefs); + Set allUnresolvedLinkedHashes = new HashSet<>(newRefs); allUnresolvedLinkedHashes.removeAll(previousRefs); // at this moment allUnresolvedLinkedHashes contains only NEW refs for (Commit commit : firstBlock) { @@ -115,9 +111,9 @@ public class VcsLogJoiner> { @NotNull Collection previousRefs, @NotNull List firstBlock, @NotNull Collection newRefs) { - Set startRedCommits = new THashSet<>(previousRefs); + Set startRedCommits = new HashSet<>(previousRefs); startRedCommits.removeAll(newRefs); - Set startGreenNodes = new THashSet<>(newRefs); + Set startGreenNodes = new HashSet<>(newRefs); for (Commit commit : firstBlock) { startGreenNodes.add(commit.getId()); startGreenNodes.addAll(commit.getParents()); @@ -131,7 +127,7 @@ public class VcsLogJoiner> { private static final class RedGreenSorter> { private final Set currentRed; private final Set currentGreen; - private final Set allRedCommit = new THashSet<>(); + private final Set allRedCommit = new HashSet<>(); private final List savedLog; @@ -191,7 +187,7 @@ public class VcsLogJoiner> { private void insertAllUseStack() { while (!newCommitsMap.isEmpty()) { - visitCommit(Objects.requireNonNull(getFirstItem(newCommitsMap.values()))); + visitCommit(Objects.requireNonNull(ContainerUtil.getFirstItem(newCommitsMap.values()))); while (!commitsStack.isEmpty()) { Commit currentCommit = commitsStack.peek(); boolean allParentsWereAdded = true; @@ -209,7 +205,7 @@ public class VcsLogJoiner> { } int insertIndex; - Set parents = new THashSet<>(currentCommit.getParents()); + Set parents = new HashSet<>(currentCommit.getParents()); for (insertIndex = 0; insertIndex < list.size(); insertIndex++) { Commit someCommit = list.get(insertIndex); if (parents.contains(someCommit.getId())) { diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogUserIndex.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogUserIndex.java index 838f3344eb7f..fd3e6580e184 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogUserIndex.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogUserIndex.java @@ -11,14 +11,17 @@ import com.intellij.util.indexing.impl.forward.ForwardIndex; import com.intellij.util.indexing.impl.forward.ForwardIndexAccessor; import com.intellij.util.indexing.impl.forward.KeyCollectionForwardIndexAccessor; import com.intellij.util.indexing.impl.forward.PersistentMapBasedForwardIndex; -import com.intellij.util.io.*; +import com.intellij.util.io.IntCollectionDataExternalizer; +import com.intellij.util.io.Page; +import com.intellij.util.io.PersistentEnumerator; +import com.intellij.util.io.VoidDataExternalizer; import com.intellij.vcs.log.VcsShortCommitDetails; import com.intellij.vcs.log.VcsUser; import com.intellij.vcs.log.VcsUserRegistry; import com.intellij.vcs.log.data.VcsUserKeyDescriptor; import com.intellij.vcs.log.impl.FatalErrorHandler; import com.intellij.vcs.log.util.StorageId; -import gnu.trove.THashMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.IntOpenHashSet; import it.unimi.dsi.fastutil.ints.IntSet; import org.jetbrains.annotations.NonNls; @@ -34,7 +37,7 @@ import java.util.Set; import static com.intellij.util.containers.ContainerUtil.getFirstItem; -public class VcsLogUserIndex extends VcsLogFullDetailsIndex { +public final class VcsLogUserIndex extends VcsLogFullDetailsIndex { private static final Logger LOG = Logger.getInstance(VcsLogUserIndex.class); @NonNls private static final String USERS = "users"; @NonNls private static final String USERS_IDS = "users-ids"; @@ -50,10 +53,9 @@ public class VcsLogUserIndex extends VcsLogFullDetailsIndex consumer.consume(this, e)); } - @Nullable @Override - protected Pair> createdForwardIndex() throws IOException { - return Pair.create(new PersistentMapBasedForwardIndex(myStorageId.getStorageFile(myName + ".idx"), false), + protected @NotNull Pair> createdForwardIndex() throws IOException { + return new Pair<>(new PersistentMapBasedForwardIndex(myStorageId.getStorageFile(myName + ".idx"), false), new KeyCollectionForwardIndexAccessor<>(new IntCollectionDataExternalizer())); } @@ -107,7 +109,7 @@ public class VcsLogUserIndex extends VcsLogFullDetailsIndex { + private static final class UserIndexer implements DataIndexer { @NotNull private final PersistentEnumerator myUserEnumerator; @NotNull private Consumer myFatalErrorConsumer = LOG::error; @@ -118,15 +120,13 @@ public class VcsLogUserIndex extends VcsLogFullDetailsIndex map(@NotNull VcsShortCommitDetails inputData) { - Map result = new THashMap<>(); - + Int2ObjectOpenHashMap result = new Int2ObjectOpenHashMap<>(); try { result.put(myUserEnumerator.enumerate(inputData.getAuthor()), null); } catch (IOException e) { myFatalErrorConsumer.consume(e); } - return result; } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/history/FileHistoryRefiner.kt b/platform/vcs-log/impl/src/com/intellij/vcs/log/history/FileHistoryRefiner.kt index 40c669ce204f..00cd8674b94c 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/history/FileHistoryRefiner.kt +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/history/FileHistoryRefiner.kt @@ -10,8 +10,6 @@ import com.intellij.vcs.log.graph.utils.Dfs import com.intellij.vcs.log.graph.utils.LinearGraphUtils import com.intellij.vcs.log.graph.utils.getCorrespondingParent import com.intellij.vcs.log.graph.utils.impl.BitSetFlags -import gnu.trove.THashSet -import java.util.* internal class FileHistoryRefiner(private val visibleLinearGraph: LinearGraph, permanentGraphInfo: PermanentGraphInfo, @@ -25,7 +23,7 @@ internal class FileHistoryRefiner(private val visibleLinearGraph: LinearGraph, fun refine(row: Int, startPath: MaybeDeletedFilePath): Pair, Set> { walk(LinearGraphUtils.asLiteLinearGraph(visibleLinearGraph), row, startPath) - val excluded = THashSet() + val excluded = HashSet() for ((commit, path) in pathsForCommits) { if (!historyData.affects(commit, path, true)) { excluded.add(commit) @@ -44,10 +42,12 @@ internal class FileHistoryRefiner(private val visibleLinearGraph: LinearGraph, * Then goes to the other down-siblings. */ private fun walk(graph: LiteLinearGraph, startNode: Int, startPath: MaybeDeletedFilePath) { - if (startNode < 0 || startNode >= graph.nodesCount()) return + if (startNode < 0 || startNode >= graph.nodesCount()) { + return + } val visited = BitSetFlags(graph.nodesCount(), false) - val stack = Stack>(Pair(startNode, startPath)) + val stack = Stack(Pair(startNode, startPath)) outer@ while (!stack.empty()) { val (currentNode, currentPath) = stack.peek()