cleanup - get rid of trove

GitOrigin-RevId: 05a2fe2d9e28fa9ca1f9c053136d1aecb9a4060b
This commit is contained in:
Vladimir Krivosheev
2021-12-16 10:48:01 +00:00
committed by intellij-monorepo-bot
parent 890f04e881
commit ad4bef7c37
21 changed files with 141 additions and 181 deletions
-1
View File
@@ -21,7 +21,6 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="intellij.platform.util" />
<orderEntry type="module" module-name="intellij.java" />
<orderEntry type="library" name="Trove4j" level="project" />
<orderEntry type="library" name="OroMatcher" level="project" />
<orderEntry type="module" module-name="intellij.xml.impl" />
<orderEntry type="module" module-name="intellij.java.rt" />
@@ -1,4 +1,4 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.codeInsight.completion;
import com.intellij.application.options.CodeStyle;
@@ -59,26 +59,28 @@ import com.intellij.psi.scope.ElementClassFilter;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.ProjectScope;
import com.intellij.psi.util.*;
import com.intellij.util.Consumer;
import com.intellij.util.DocumentUtil;
import com.intellij.util.ProcessingContext;
import com.intellij.util.SmartList;
import com.intellij.util.*;
import com.intellij.util.containers.ContainerUtil;
import com.siyeh.ig.psiutils.TypeUtils;
import gnu.trove.THashSet;
import it.unimi.dsi.fastutil.objects.ObjectOpenCustomHashSet;
import one.util.streamex.EntryStream;
import one.util.streamex.StreamEx;
import org.jetbrains.annotations.*;
import java.util.*;
import static com.intellij.codeInsight.completion.ReferenceExpressionCompletionContributor.getSpace;
import static com.intellij.patterns.PsiJavaPatterns.*;
import static com.intellij.util.ObjectUtils.tryCast;
import static com.intellij.patterns.PsiJavaPatterns.elementType;
import static com.intellij.patterns.PsiJavaPatterns.or;
import static com.intellij.patterns.PsiJavaPatterns.psiAnnotation;
import static com.intellij.patterns.PsiJavaPatterns.psiClass;
import static com.intellij.patterns.PsiJavaPatterns.psiElement;
import static com.intellij.patterns.PsiJavaPatterns.psiExpressionStatement;
import static com.intellij.patterns.PsiJavaPatterns.psiMethod;
import static com.intellij.patterns.PsiJavaPatterns.psiNameValuePair;
import static com.intellij.patterns.PsiJavaPatterns.psiParameter;
import static com.intellij.patterns.PsiJavaPatterns.psiReferenceExpression;
import static com.intellij.patterns.PsiJavaPatterns.string;
/**
* @author peter
*/
public final class JavaCompletionContributor extends CompletionContributor implements DumbAware {
private static final ElementPattern<PsiElement> UNEXPECTED_REFERENCE_AFTER_DOT = or(
// dot at the statement beginning
@@ -533,7 +535,7 @@ public final class JavaCompletionContributor extends CompletionContributor imple
}
boolean[] hadItems = new boolean[1];
for (ExpectedTypeInfo info : new THashSet<>(infos, JavaSmartCompletionContributor.EXPECTED_TYPE_INFO_STRATEGY)) {
for (ExpectedTypeInfo info : new ObjectOpenCustomHashSet<>(infos, JavaSmartCompletionContributor.EXPECTED_TYPE_INFO_STRATEGY)) {
BasicExpressionCompletionContributor.fillCompletionVariants(new JavaSmartCompletionParameters(parameters, info), lookupElement -> {
final PsiType psiType = JavaCompletionUtil.getLookupElementType(lookupElement);
if (psiType != null && info.getType().isAssignableFrom(psiType)) {
@@ -706,7 +708,7 @@ public final class JavaCompletionContributor extends CompletionContributor imple
filter = new AndFilter(filter, new ElementFilter() {
@Override
public boolean isAcceptable(Object element, @Nullable PsiElement context) {
return !JavaPsiClassReferenceElement.isInaccessibleConstructorSuggestion(position, tryCast(element, PsiClass.class));
return !JavaPsiClassReferenceElement.isInaccessibleConstructorSuggestion(position, ObjectUtils.tryCast(element, PsiClass.class));
}
@Override
@@ -856,7 +858,7 @@ public final class JavaCompletionContributor extends CompletionContributor imple
@NotNull PsiJavaCodeReferenceElement referenceElement,
@NotNull PrefixMatcher prefixMatcher) {
List<LookupElement> lookupElements = new SmartList<>();
PsiJavaFile psiJavaFile = tryCast(referenceElement.getContainingFile(), PsiJavaFile.class);
PsiJavaFile psiJavaFile = ObjectUtils.tryCast(referenceElement.getContainingFile(), PsiJavaFile.class);
if (psiJavaFile == null) return lookupElements;
PsiJavaModule javaModule = JavaModuleGraphUtil.findDescriptorByElement(psiJavaFile.getOriginalElement());
if (javaModule == null) {
@@ -958,7 +960,7 @@ public final class JavaCompletionContributor extends CompletionContributor imple
@NotNull
private static LookupElementBuilder createAnnotationAttributeElement(PsiMethod annoMethod, @Nullable String value) {
String space = getSpace(CodeStyle.getLanguageSettings(annoMethod.getContainingFile()).SPACE_AROUND_ASSIGNMENT_OPERATORS);
String space = ReferenceExpressionCompletionContributor.getSpace(CodeStyle.getLanguageSettings(annoMethod.getContainingFile()).SPACE_AROUND_ASSIGNMENT_OPERATORS);
String lookupString = annoMethod.getName() + (value == null ? "" : space + "=" + space + value);
return LookupElementBuilder.create(annoMethod, lookupString).withIcon(annoMethod.getIcon(0))
.withStrikeoutness(PsiImplUtil.isDeprecated(annoMethod))
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.codeInsight.completion;
import com.intellij.codeInsight.ExpectedTypeInfo;
@@ -12,6 +12,7 @@ import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.patterns.PsiJavaPatterns;
import com.intellij.psi.*;
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
import com.intellij.psi.codeStyle.NameUtil;
@@ -25,20 +26,13 @@ import com.intellij.util.ObjectUtils;
import com.intellij.util.SmartList;
import com.intellij.util.containers.ContainerUtil;
import com.siyeh.ig.psiutils.ExpressionUtils;
import gnu.trove.THashSet;
import gnu.trove.TObjectIntHashMap;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
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.*;
import static com.intellij.patterns.PsiJavaPatterns.psiElement;
/**
* @author peter
*/
public final class JavaCompletionSorting {
private JavaCompletionSorting() {
}
@@ -126,7 +120,7 @@ public final class JavaCompletionSorting {
@Nullable
private static LookupElementWeigher dispreferPreviousChainCalls(PsiElement position) {
TObjectIntHashMap<PsiMethod> previousChainCalls = new TObjectIntHashMap<>();
Object2IntMap<PsiMethod> previousChainCalls = new Object2IntOpenHashMap<>();
if (position.getParent() instanceof PsiReferenceExpression) {
PsiReferenceExpression ref = (PsiReferenceExpression)position.getParent();
PsiMethodCallExpression qualifier = getCallQualifier(ref);
@@ -139,7 +133,7 @@ public final class JavaCompletionSorting {
boolean seemsLikeExpectsMultipleCalls =
name.startsWith("put") || name.startsWith("add") || name.startsWith("append") || name.startsWith("get");
if (!seemsLikeExpectsMultipleCalls && qualifierClass == method.getContainingClass()) {
previousChainCalls.put(method, previousChainCalls.get(method) + 1);
previousChainCalls.put(method, previousChainCalls.getInt(method) + 1);
}
}
qualifier = getCallQualifier(qualifier.getMethodExpression());
@@ -150,7 +144,7 @@ public final class JavaCompletionSorting {
@Override
public Boolean weigh(@NotNull LookupElement element, @NotNull WeighingContext context) {
PsiElement psi = element.getPsiElement();
return psi instanceof PsiMethod && previousChainCalls.get((PsiMethod)psi) == 1;
return psi instanceof PsiMethod && previousChainCalls.getInt((PsiMethod)psi) == 1;
}
};
}
@@ -161,7 +155,7 @@ public final class JavaCompletionSorting {
}
private static ExpectedTypeInfo @NotNull [] getExpectedTypesWithDfa(CompletionParameters parameters, PsiElement position) {
if (psiElement().beforeLeaf(psiElement().withText(".")).accepts(position)) {
if (PsiJavaPatterns.psiElement().beforeLeaf(PsiJavaPatterns.psiElement().withText(".")).accepts(position)) {
return ExpectedTypeInfo.EMPTY_ARRAY;
}
@@ -627,7 +621,7 @@ public final class JavaCompletionSorting {
SUBTYPE, CONVERTIBLE, HAS_NESTED, UNKNOWN, SUPERTYPE, NON_CONVERTIBLE
}
private static class PreferExpected extends LookupElementWeigher {
private static final class PreferExpected extends LookupElementWeigher {
private final boolean myConstructorPossible;
private final ExpectedTypeInfo[] myExpectedTypes;
private final PsiElement myPosition;
@@ -733,7 +727,7 @@ public final class JavaCompletionSorting {
for (ExpectedTypeInfo myExpectedInfo : myExpectedTypes) {
String expectedName = ((ExpectedTypeInfoImpl)myExpectedInfo).getExpectedName();
if (expectedName != null) {
final THashSet<String> set = new THashSet<>(NameUtil.nameToWordsLowerCase(truncDigits(expectedName)));
final Set<String> set = new HashSet<>(NameUtil.nameToWordsLowerCase(truncDigits(expectedName)));
set.retainAll(wordsNoDigits);
max = Math.max(max, set.size());
}
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.codeInsight.completion;
import com.intellij.codeInsight.*;
@@ -19,7 +19,7 @@ import com.intellij.psi.util.proximity.ReferenceListWeigher;
import com.intellij.util.ReflectionUtil;
import com.intellij.util.SmartList;
import com.intellij.util.containers.ContainerUtil;
import gnu.trove.TObjectHashingStrategy;
import it.unimi.dsi.fastutil.Hash;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -31,18 +31,21 @@ import java.util.Set;
import static com.intellij.patterns.PlatformPatterns.psiElement;
import static com.intellij.patterns.StandardPatterns.or;
/**
* @author peter
*/
public final class JavaSmartCompletionContributor {
static final TObjectHashingStrategy<ExpectedTypeInfo> EXPECTED_TYPE_INFO_STRATEGY = new TObjectHashingStrategy<>() {
static final Hash.Strategy<ExpectedTypeInfo> EXPECTED_TYPE_INFO_STRATEGY = new Hash.Strategy<>() {
@Override
public int computeHashCode(ExpectedTypeInfo object) {
return object.getType().hashCode();
public int hashCode(ExpectedTypeInfo object) {
return object == null ? 0 : object.getType().hashCode();
}
@Override
public boolean equals(ExpectedTypeInfo o1, ExpectedTypeInfo o2) {
if (o1 == o2) {
return true;
}
if (o1 == null || o2 == null) {
return false;
}
return o1.getType().equals(o2.getType());
}
};
@@ -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-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.codeInsight.daemon.impl.quickfix;
import com.intellij.codeInsight.daemon.QuickFixBundle;
@@ -32,7 +18,8 @@ import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.ContainerUtil;
import com.siyeh.ig.psiutils.TypeUtils;
import gnu.trove.TObjectIntHashMap;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
@@ -84,9 +71,9 @@ public final class AddMissingRequiredAnnotationParametersFix implements Intentio
public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException {
final PsiNameValuePair[] addedParameters = myAnnotation.getParameterList().getAttributes();
final TObjectIntHashMap<String> annotationsOrderMap = getAnnotationsOrderMap();
final Object2IntMap<String> annotationsOrderMap = getAnnotationsOrderMap();
final SortedSet<Pair<String, PsiAnnotationMemberValue>> newParameters =
new TreeSet<>(Comparator.comparingInt(o -> annotationsOrderMap.get(o.getFirst())));
new TreeSet<>(Comparator.comparingInt(o -> annotationsOrderMap.getInt(o.getFirst())));
final boolean order = isAlreadyAddedOrdered(annotationsOrderMap, addedParameters);
if (order) {
@@ -154,21 +141,21 @@ public final class AddMissingRequiredAnnotationParametersFix implements Intentio
return true;
}
private TObjectIntHashMap<String> getAnnotationsOrderMap() {
final TObjectIntHashMap<String> map = new TObjectIntHashMap<>();
private Object2IntMap<String> getAnnotationsOrderMap() {
final Object2IntMap<String> map = new Object2IntOpenHashMap<>();
for (int i = 0; i < myAnnotationMethods.length; i++) {
map.put(myAnnotationMethods[i].getName(), i);
}
return map;
}
private static boolean isAlreadyAddedOrdered(final TObjectIntHashMap<String> orderMap, final PsiNameValuePair[] addedParameters) {
private static boolean isAlreadyAddedOrdered(final Object2IntMap<String> orderMap, final PsiNameValuePair[] addedParameters) {
if (addedParameters.length <= 1) {
return true;
}
int previousOrder = orderMap.get(addedParameters[0].getName());
int previousOrder = orderMap.getInt(addedParameters[0].getName());
for (int i = 1; i < addedParameters.length; i++) {
final int currentOrder = orderMap.get(addedParameters[i].getName());
final int currentOrder = orderMap.getInt(addedParameters[i].getName());
if (currentOrder < previousOrder) {
return false;
}
@@ -1,4 +1,4 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.refactoring.introduceParameter;
import com.intellij.codeInsight.hint.EditorCodePreview;
@@ -33,7 +33,7 @@ import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
import com.intellij.ui.JBColor;
import com.intellij.ui.components.labels.LinkLabel;
import com.intellij.util.ui.JBUI;
import gnu.trove.TIntArrayList;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import kotlin.ranges.IntRange;
import org.jetbrains.annotations.NonNls;
@@ -45,7 +45,7 @@ import java.awt.*;
import java.util.ArrayList;
import java.util.List;
public class InplaceIntroduceParameterPopup extends AbstractJavaInplaceIntroducer {
public final class InplaceIntroduceParameterPopup extends AbstractJavaInplaceIntroducer {
private final PsiMethod myMethod;
private final PsiMethod myMethodToSearchFor;
private final boolean myMustBeFinal;
@@ -88,8 +88,8 @@ public class InplaceIntroduceParameterPopup extends AbstractJavaInplaceIntroduce
}
@Override
protected TIntArrayList getParametersToRemove() {
TIntArrayList parameters = new TIntArrayList();
protected IntList getParametersToRemove() {
IntList parameters = new IntArrayList();
if (myCbReplaceAllOccurences == null || myCbReplaceAllOccurences.isSelected()) {
for (int i = 0; i < myParametersToRemove.length; i++) {
if (myParametersToRemove[i] != null) {
@@ -258,7 +258,7 @@ public class InplaceIntroduceParameterPopup extends AbstractJavaInplaceIntroduce
isDeleteLocalVariable = myPanel.isDeleteLocalVariable();
}
final TIntArrayList parametersToRemove = myPanel.getParametersToRemove();
final IntList parametersToRemove = myPanel.getParametersToRemove();
final IntroduceParameterProcessor processor =
new IntroduceParameterProcessor(myProject, myMethod,
@@ -313,12 +313,11 @@ public class InplaceIntroduceParameterPopup extends AbstractJavaInplaceIntroduce
return "IntroduceParameter";
}
private void normalizeParameterIdxAccordingToRemovedParams(TIntArrayList parametersToRemove) {
private void normalizeParameterIdxAccordingToRemovedParams(IntList parametersToRemove) {
parametersToRemove.forEach(value -> {
if (myParameterIndex >= value) {
myParameterIndex--;
}
return true;
});
}
@@ -1,20 +1,16 @@
// 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.
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.refactoring.introduceParameter;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiType;
import gnu.trove.TIntArrayList;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import com.intellij.refactoring.IntroduceParameterRefactoring;
import it.unimi.dsi.fastutil.ints.IntList;
import org.intellij.lang.annotations.MagicConstant;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import static com.intellij.refactoring.IntroduceParameterRefactoring.*;
public interface IntroduceParameterData {
@NotNull
Project getProject();
@@ -29,7 +25,8 @@ public interface IntroduceParameterData {
@NotNull
String getParameterName();
@MagicConstant(intValues = {REPLACE_FIELDS_WITH_GETTERS_ALL, REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, REPLACE_FIELDS_WITH_GETTERS_NONE})
@MagicConstant(intValues = {
IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE})
int getReplaceFieldsWithGetters();
boolean isDeclareFinal();
@@ -39,19 +36,7 @@ public interface IntroduceParameterData {
@NotNull
PsiType getForcedType();
/**
* @deprecated Implement {@link #getParameterListToRemove()}
*/
@NotNull
@ApiStatus.ScheduledForRemoval(inVersion = "2022.1")
@Deprecated
default TIntArrayList getParametersToRemove() {
throw new AbstractMethodError("Implement getParameterListToRemove");
}
default IntList getParameterListToRemove() {
return new IntArrayList(getParametersToRemove().toNativeArray());
}
IntList getParameterListToRemove();
interface ExpressionWrapper<RealExpression extends PsiElement> {
@NotNull
@@ -1,4 +1,4 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.refactoring.introduceParameter;
import com.intellij.analysis.AnalysisScope;
@@ -37,8 +37,6 @@ import com.intellij.usageView.UsageViewDescriptor;
import com.intellij.usageView.UsageViewUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.MultiMap;
import gnu.trove.TIntArrayList;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
@@ -118,25 +116,25 @@ public class IntroduceParameterProcessor extends BaseRefactoringProcessor implem
/**
* if expressionToSearch is null, search for localVariable
*/
public IntroduceParameterProcessor(@NotNull Project project,
PsiMethod methodToReplaceIn,
@NotNull PsiMethod methodToSearchFor,
PsiExpression parameterInitializer,
PsiExpression expressionToSearch,
PsiLocalVariable localVariable,
boolean removeLocalVariable,
String parameterName,
IntroduceVariableBase.JavaReplaceChoice replaceOccurrencesChoice,
int replaceFieldsWithGetters,
boolean declareFinal,
boolean generateDelegate,
boolean replaceWithLambda,
PsiType forcedType,
@NotNull TIntArrayList parametersToRemove) {
this(project, methodToReplaceIn, methodToSearchFor, parameterInitializer, expressionToSearch, localVariable, removeLocalVariable, parameterName,
replaceOccurrencesChoice,
replaceFieldsWithGetters, declareFinal, generateDelegate, replaceWithLambda, forcedType, new IntArrayList(parametersToRemove.toNativeArray()));
}
//public IntroduceParameterProcessor(@NotNull Project project,
// PsiMethod methodToReplaceIn,
// @NotNull PsiMethod methodToSearchFor,
// PsiExpression parameterInitializer,
// PsiExpression expressionToSearch,
// PsiLocalVariable localVariable,
// boolean removeLocalVariable,
// String parameterName,
// IntroduceVariableBase.JavaReplaceChoice replaceOccurrencesChoice,
// int replaceFieldsWithGetters,
// boolean declareFinal,
// boolean generateDelegate,
// boolean replaceWithLambda,
// PsiType forcedType,
// @NotNull IntList parametersToRemove) {
// this(project, methodToReplaceIn, methodToSearchFor, parameterInitializer, expressionToSearch, localVariable, removeLocalVariable, parameterName,
// replaceOccurrencesChoice,
// replaceFieldsWithGetters, declareFinal, generateDelegate, replaceWithLambda, forcedType, parametersToRemove);
//}
public void setParameterInitializer(PsiExpression parameterInitializer) {
myParameterInitializer = parameterInitializer;
@@ -1,4 +1,4 @@
// Copyright 2000-2021 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-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.refactoring.introduceParameter;
import com.intellij.java.refactoring.JavaRefactoringBundle;
@@ -14,7 +14,7 @@ import com.intellij.ui.NonFocusableCheckBox;
import com.intellij.ui.StateRestoringCheckBox;
import com.intellij.util.ui.JBInsets;
import com.intellij.util.ui.JBUI;
import gnu.trove.TIntArrayList;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import it.unimi.dsi.fastutil.ints.IntListIterator;
@@ -153,8 +153,8 @@ public abstract class IntroduceParameterSettingsUI {
}
}
protected TIntArrayList getParametersToRemove() {
TIntArrayList parameters = new TIntArrayList();
protected IntList getParametersToRemove() {
IntList parameters = new IntArrayList();
for (int i = 0; i < myParametersToRemoveChecked.length; i++) {
if (myParametersToRemoveChecked[i]) {
parameters.add(i);
@@ -48,7 +48,6 @@
<orderEntry type="module" module-name="intellij.platform.statistics" scope="TEST" />
<orderEntry type="library" scope="TEST" name="kotlinx-coroutines-jdk8" level="project" />
<orderEntry type="library" name="fastutil-min" level="project" />
<orderEntry type="library" name="Trove4j" level="project" />
<orderEntry type="library" scope="TEST" name="jcef" level="project" />
<orderEntry type="module" module-name="intellij.platform.util.classLoader" scope="TEST" />
<orderEntry type="library" scope="TEST" name="netty-buffer" level="project" />
@@ -1,18 +1,19 @@
// 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-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
@file:Suppress("DEPRECATION")
package com.intellij.internal.statistics
import com.intellij.internal.statistic.beans.*
import com.intellij.internal.statistic.beans.MetricEvent
import com.intellij.internal.statistic.beans.newBooleanMetric
import com.intellij.internal.statistic.beans.newCounterMetric
import com.intellij.internal.statistic.beans.newMetric
import com.intellij.internal.statistic.eventLog.FeatureUsageData
import com.intellij.testFramework.HeavyPlatformTestCase
import com.intellij.util.containers.ContainerUtil.newArrayList
import gnu.trove.THashSet
import org.junit.Assert
import org.junit.Test
class MetricEventUnitTest : HeavyPlatformTestCase() {
@Test
fun `test compare metric events`() {
Assert.assertEquals(newMetric("abcd"), newMetric("abcd"))
@@ -74,7 +75,7 @@ class MetricEventUnitTest : HeavyPlatformTestCase() {
}
private fun doTestUniqueFilter(expectedSize: Int, all: List<MetricEvent>) {
val unique = THashSet<MetricEvent>(all)
val unique = HashSet<MetricEvent>(all)
Assert.assertTrue(unique.size == expectedSize)
for (descriptor in all) {
Assert.assertTrue(unique.contains(descriptor))
@@ -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-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.internal.statistics
import com.intellij.internal.statistic.beans.MetricEvent
@@ -7,7 +7,6 @@ import com.intellij.internal.statistic.beans.newMetric
import com.intellij.internal.statistic.eventLog.FeatureUsageData
import com.intellij.testFramework.HeavyPlatformTestCase
import com.intellij.util.containers.ContainerUtil.newArrayList
import gnu.trove.THashSet
import org.junit.Assert
import org.junit.Test
@@ -34,7 +33,7 @@ class UsageDescriptorUnitTest : HeavyPlatformTestCase() {
}
private fun doTestUniqueFilter(expectedSize: Int, all: List<MetricEvent>) {
val unique = THashSet(all)
val unique = HashSet(all)
Assert.assertTrue(unique.size == expectedSize)
for (descriptor in all) {
Assert.assertTrue(unique.contains(descriptor))
@@ -1,14 +1,15 @@
// 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.
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.util.text;
import com.intellij.openapi.util.Ref;
import gnu.trove.TIntArrayList;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import junit.framework.TestCase;
public class TrigramBuilderTest extends TestCase {
public void testBuilder() {
final Ref<Integer> trigramCountRef = new Ref<>();
final TIntArrayList list = new TIntArrayList();
final IntList list = new IntArrayList();
TrigramBuilder.processTrigrams("String$CharData", new TrigramBuilder.TrigramProcessor() {
@Override
@@ -24,7 +25,7 @@ public class TrigramBuilderTest extends TestCase {
}
});
list.sort();
list.sort(null);
Integer trigramCount = trigramCountRef.get();
assertNotNull(trigramCount);
@@ -33,7 +34,9 @@ public class TrigramBuilderTest extends TestCase {
assertEquals(expectedTrigramCount, list.size());
int[] expected = {buildTrigram("$Ch"), buildTrigram("arD"), buildTrigram("ata"), 6514785, 6578548, 6759523, 6840690, 6909543, 7235364, 7496801, 7498094, 7566450, 7631465, };
for(int i = 0; i < expectedTrigramCount; ++i) assertEquals(expected[i], list.getQuick(i));
for (int i = 0; i < expectedTrigramCount; ++i) {
assertEquals(expected[i], list.getInt(i));
}
}
private static int buildTrigram(String s) {
@@ -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-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.vfs.newvfs.impl;
import com.intellij.openapi.application.ApplicationManager;
@@ -6,8 +6,9 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.testFramework.LightProjectDescriptor;
import com.intellij.testFramework.fixtures.IdeaTestFixture;
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory;
import gnu.trove.TIntObjectHashMap;
import gnu.trove.TLongArrayList;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.longs.LongArrayList;
import org.jetbrains.annotations.NotNull;
import org.junit.Assert;
@@ -115,8 +116,8 @@ public class FileNameCacheMicroBenchmark {
private static void runTest(int nameCount, String name) throws InterruptedException, ExecutionException {
System.out.println("----- " + name + " ------ name count: "+nameCount);
TIntObjectHashMap<CharSequence> map = generateNames(nameCount);
final int[] ids = map.keys();
Int2ObjectMap<CharSequence> map = generateNames(nameCount);
final int[] ids = map.keySet().toIntArray();
checkNames(map, ids);
warmUp(ids);
@@ -155,15 +156,15 @@ public class FileNameCacheMicroBenchmark {
private static void measureAverageTime(int[] ids, int threadCount, TestIteration iteration) throws InterruptedException, ExecutionException {
System.out.println("Running "+threadCount+" threads, using "+iteration);
TLongArrayList times = new TLongArrayList();
LongArrayList times = new LongArrayList();
for (int i = 0; i < 10; i++) {
long time = runThreads(ids, threadCount, 2000000/*0*/, iteration);
System.out.println(time);
times.add(time);
}
times.sort();
long median = times.get(times.size() / 2);
times.sort(null);
long median = times.getLong(times.size() / 2);
System.out.println("Median for " + threadCount + " threads: " + median+"ms");
System.out.println();
}
@@ -192,16 +193,16 @@ public class FileNameCacheMicroBenchmark {
return System.currentTimeMillis() - start;
}
private static void checkNames(TIntObjectHashMap<CharSequence> map, int[] ids) {
private static void checkNames(Int2ObjectMap<CharSequence> map, int[] ids) {
for (int id : ids) {
Assert.assertEquals(map.get(id), FileNameCache.getVFileName(id).toString());
}
}
@NotNull
private static TIntObjectHashMap<CharSequence> generateNames(int nameCount) {
private static Int2ObjectMap<CharSequence> generateNames(int nameCount) {
Random random = new Random();
TIntObjectHashMap<CharSequence> map = new TIntObjectHashMap<>();
Int2ObjectMap<CharSequence> map = new Int2ObjectOpenHashMap<>();
for (int i = 0; i < nameCount; i++) {
String name = "some_name_" + random.nextInt() + StringUtil.repeat("a", random.nextInt(10));
int id = FileNameCache.storeName(name);
@@ -4,7 +4,8 @@ package com.intellij.psi.impl.search;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.util.text.StringSearcher;
import gnu.trove.TIntArrayList;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import junit.framework.TestCase;
public class LowLevelSearchUtilTest extends TestCase {
@@ -40,12 +41,12 @@ public class LowLevelSearchUtilTest extends TestCase {
public void testProcessTextOccurrencesNeverScansBeyondStartEndOffsetIfNeverAskedTo() {
StringSearcher searcher = new StringSearcher("xxx", true, true);
TIntArrayList found = new TIntArrayList(new int[]{-1});
IntList found = new IntArrayList(new int[]{-1});
CharSequence text = StringUtil.repeat("xxx z ", 1000000);
PlatformTestUtil.startPerformanceTest("processTextOccurrences", 100, ()-> {
for (int i=0; i<10000; i++) {
found.remove(0);
found.removeInt(0);
int startOffset = text.length() / 2 + i % 20;
int endOffset = startOffset + 8;
boolean success = LowLevelSearchUtil.processTexts(text, startOffset, endOffset, searcher, offset -> {
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.structureView;
import com.intellij.ide.util.treeView.AbstractTreeNode;
@@ -8,12 +8,11 @@ import com.intellij.ide.util.treeView.smartTree.Grouper;
import com.intellij.ide.util.treeView.smartTree.TreeElement;
import com.intellij.navigation.ItemPresentation;
import com.intellij.util.containers.ContainerUtil;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import java.util.*;
public class TestGrouper implements Grouper {
public final class TestGrouper implements Grouper {
private final String[] mySubStrings;
public TestGrouper(String[] subString) {
@@ -91,7 +90,7 @@ public class TestGrouper implements Grouper {
Collection<TreeElement> elements = new LinkedHashSet<>(children);
for (String subString : mySubStrings) {
if (parentGroupUsedStrings.contains(subString)) continue;
Set<String> childrenStrings = new THashSet<>(parentGroupUsedStrings);
Set<String> childrenStrings = new HashSet<>(parentGroupUsedStrings);
ContainerUtil.addAll(childrenStrings, mySubStrings);
StringGroup group = new StringGroup(subString, elements, childrenStrings);
Collection<TreeElement> groupChildren = group.getChildren();
@@ -1,23 +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-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ui;
import com.intellij.util.Assertion;
import com.intellij.util.containers.ContainerUtil;
import gnu.trove.TIntArrayList;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import junit.framework.TestCase;
import javax.swing.event.ListDataEvent;
@@ -46,7 +33,7 @@ public class SortedListModelTest extends TestCase {
public void testRemoveViaIterator() {
myModel.setAll(new String[]{"1", "2", "3", "4"});
Iterator iterator = myModel.iterator();
final TIntArrayList removed = new TIntArrayList();
final IntList removed = new IntArrayList();
myModel.addListDataListener(new ListDataListener() {
@Override
public void contentsChanged(ListDataEvent e) {
@@ -67,12 +54,12 @@ public class SortedListModelTest extends TestCase {
iterator.next();
iterator.remove();
assertEquals(1, removed.size());
assertEquals(0, removed.get(0));
assertEquals(0, removed.getInt(0));
while (iterator.hasNext()) iterator.next();
assertFalse(iterator.hasNext());
iterator.remove();
assertEquals(2, removed.size());
assertEquals(2, removed.get(1));
assertEquals(2, removed.getInt(1));
CHECK.compareAll(new String[]{"2", "3"}, myModel.getItems());
}
@@ -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-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.util.containers;
import com.intellij.openapi.util.Comparing;
@@ -10,7 +10,8 @@ import com.intellij.util.Function;
import com.intellij.util.Functions;
import com.intellij.util.PairFunction;
import com.intellij.util.Processor;
import gnu.trove.TIntHashSet;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;
import junit.framework.TestCase;
import org.jetbrains.annotations.NotNull;
@@ -370,11 +371,13 @@ public class TreeTraverserTest extends TestCase {
public void testStatefulFilterWithSet() {
Integer base = 5;
JBIterable<Integer> it = JBIterable.generate(1, INCREMENT).take(10).filter(new JBIterable.SCond<>() {
TIntHashSet visited; // MUST NOT be initialized here
IntSet visited; // MUST NOT be initialized here
@Override
public boolean value(Integer integer) {
if (visited == null) visited = new TIntHashSet();
if (visited == null) {
visited = new IntOpenHashSet();
}
return visited.add(integer % base);
}
});
@@ -1,4 +1,4 @@
// Copyright 2000-2021 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-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.util.io;
import com.intellij.openapi.diagnostic.Logger;
@@ -8,7 +8,8 @@ import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.testFramework.rules.TempDirectory;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.IntObjectCache;
import gnu.trove.TIntArrayList;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
@@ -229,7 +230,7 @@ public class PersistentBTreeEnumeratorTest {
System.setProperty(PersistentBTreeEnumerator.DO_SELF_HEAL_PROP, Boolean.toString(true));
try {
List<String> values = new ArrayList<>();
TIntArrayList ids = new TIntArrayList();
IntList ids = new IntArrayList();
for (int i = 0; i < 1_000_000; i++) {
String value = String.valueOf(i);
values.add(value);
@@ -239,7 +240,7 @@ public class PersistentBTreeEnumeratorTest {
for (int i = 0; i < values.size(); i += 50_000) {
String value = values.get(i);
System.out.println("checked " + i);
assertEquals(ids.get(i), myEnumerator.catchCorruption(new CorruptAndEnumerateAfter(value)).intValue());
assertEquals(ids.getInt(i), myEnumerator.catchCorruption(new CorruptAndEnumerateAfter(value)).intValue());
}
}
finally {
@@ -1,4 +1,4 @@
// Copyright 2000-2021 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-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.util.containers;
import com.intellij.util.ArrayUtil;
@@ -11,7 +11,7 @@ import java.util.function.Consumer;
import java.util.stream.Stream;
/**
* Hash set which is fast when contains one or zero elements (avoids to calculate hash codes and call equals whenever possible).
* Hash set which is fast when contains one or zero elements (avoids calculating hash codes and call equals whenever possible).
* For other sizes it delegates to THashSet.
* Null keys are NOT PERMITTED.
*/
-1
View File
@@ -96,7 +96,6 @@
<orderEntry type="library" name="fastutil-min" level="project" />
<orderEntry type="library" name="kotlinx-coroutines-jdk8" level="project" />
<orderEntry type="module" module-name="intellij.platform.ide.util.io" />
<orderEntry type="library" name="Trove4j" level="project" />
<orderEntry type="library" name="Velocity" level="project" />
</component>
<component name="copyright">