Skip to content

Commit

Permalink
cleanup - get rid of trove
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 923a8456bc512ebee88b89f271ff254060001052
  • Loading branch information
develar authored and intellij-monorepo-bot committed Dec 16, 2021
1 parent efdfc0a commit 28f6f64
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 62 deletions.
Original file line number Diff line number Diff line change
@@ -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.java.codeInsight;

import com.intellij.codeInsight.BaseExternalAnnotationsManager;
Expand Down Expand Up @@ -44,7 +44,7 @@
import java.util.stream.Collectors;

public class ExternalAnnotationsManagerTest extends LightPlatformTestCase {
private static final Set<String> KNOWN_EXCEPTIONS = ContainerUtil.immutableSet(
private static final Set<String> KNOWN_EXCEPTIONS = Set.of(
"java.util.stream.Stream<T> generate(java.util.function.Supplier<T>)" // replaced with Supplier<? extends T> in JDK11
);

Expand Down
Original file line number Diff line number Diff line change
@@ -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 org.jetbrains.jps.cmdline;

import com.google.gson.Gson;
Expand All @@ -8,15 +8,14 @@
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.SystemInfoRt;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.tracing.Tracer;
import com.intellij.uiDesigner.compiler.AlienFormFileException;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.util.PathUtilRt;
import com.intellij.util.SystemProperties;
import com.jgoodies.forms.layout.CellConstraints;
import com.thoughtworks.qdox.JavaProjectBuilder;
import gnu.trove.THashSet;
import io.netty.buffer.ByteBufAllocator;
import io.netty.channel.EventLoopGroup;
import io.netty.handler.codec.protobuf.ProtobufDecoder;
Expand Down Expand Up @@ -116,6 +115,9 @@ private static void addToClassPath(Set<String> cp, @NotNull Class<?> @NotNull []

// intellij.platform.util
addToClassPath(cp, ClassPathUtil.getUtilClasses());
//noinspection UnnecessaryFullyQualifiedName,deprecation
addToClassPath(gnu.trove.THashSet.class, cp);

ClassPathUtil.addKotlinStdlib(cp);
addToClassPath(cp, COMMON_REQUIRED_CLASSES);

Expand Down Expand Up @@ -161,7 +163,8 @@ public static List<File> getExternalJavacProcessClasspath(String sdkHome, JavaCo
cp.add(getResourceFile(JavacReferenceCollector.class)); // jps-javac-extension library
cp.add(getResourceFile(Appender.class)); // log4j
cp.add(getResourceFile(SystemInfoRt.class)); // util_rt
cp.add(getResourceFile(THashSet.class)); // Trove
//noinspection deprecation,UnnecessaryFullyQualifiedName
cp.add(getResourceFile(gnu.trove.THashSet.class)); // Trove

for (Class<?> aClass : COMMON_REQUIRED_CLASSES) {
cp.add(getResourceFile(aClass));
Expand All @@ -177,7 +180,7 @@ public static List<File> getExternalJavacProcessClasspath(String sdkHome, JavaCo
}

try {
final String localJavaHome = FileUtil.toSystemIndependentName(SystemProperties.getJavaHome());
final String localJavaHome = FileUtilRt.toSystemIndependentName(SystemProperties.getJavaHome());
// sdkHome is not the same as the sdk used to run this process
final File candidate = new File(sdkHome, "lib/tools.jar");
if (candidate.exists()) {
Expand All @@ -195,11 +198,11 @@ public static List<File> getExternalJavacProcessClasspath(String sdkHome, JavaCo
}
final File resourceFile = getResourceFile(compilerClass);
if (resourceFile != null) {
String localJarPath = FileUtil.toSystemIndependentName(resourceFile.getPath());
String relPath = FileUtil.getRelativePath(localJavaHome, localJarPath, '/');
String localJarPath = FileUtilRt.toSystemIndependentName(resourceFile.getPath());
String relPath = FileUtilRt.getRelativePath(localJavaHome, localJarPath, '/');
if (relPath != null) {
if (relPath.contains("..")) {
relPath = FileUtil.getRelativePath(FileUtil.toSystemIndependentName(new File(localJavaHome).getParent()), localJarPath, '/');
relPath = FileUtilRt.getRelativePath(FileUtilRt.toSystemIndependentName(new File(localJavaHome).getParent()), localJarPath, '/');
}
if (relPath != null) {
final File targetFile = new File(sdkHome, relPath);
Expand Down Expand Up @@ -237,7 +240,8 @@ private static void addExternalJavacRpcClasspath(@NotNull Collection<File> cp) {
// take the library from the local maven repository
File localRepositoryDir = getMavenLocalRepositoryDir();
File protobufJava6File = new File(
FileUtil.join(localRepositoryDir.getAbsolutePath(), "com", "google", "protobuf", "protobuf-java", PROTOBUF_JAVA6_VERSION, PROTOBUF_JAVA6_JAR_NAME)
String.join(File.separator, localRepositoryDir.getAbsolutePath(), "com", "google", "protobuf", "protobuf-java",
PROTOBUF_JAVA6_VERSION, PROTOBUF_JAVA6_JAR_NAME)
);
cp.add(protobufJava6File);
}
Expand Down
5 changes: 4 additions & 1 deletion lib/annotations/trove4j/gnu/trove/annotations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@
<item name='gnu.trove.THashSet boolean add(E) 0'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='gnu.trove.TIntFunction'>
<item name='gnu.trove.TIntArrayList'>
<annotation name='java.lang.Deprecated'/>
</item>
<item name='gnu.trove.TIntFunction'>
<annotation name='java.lang.FunctionalInterface'/>
</item>
<item name='gnu.trove.TIntHashSet'>
Expand Down
2 changes: 0 additions & 2 deletions platform/indexing-impl/intellij.platform.indexing.impl.iml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
<orderEntry type="library" name="NanoXML" level="project" />
<orderEntry type="library" name="kotlin-stdlib-jdk8" level="project" />
<orderEntry type="library" name="kotlinx-coroutines-jdk8" level="project" />
<orderEntry type="library" name="Guava" level="project" />
<orderEntry type="library" name="StreamEx" level="project" />
<orderEntry type="library" name="Trove4j" level="project" />
<orderEntry type="library" name="fastutil-min" level="project" />
</component>
</module>
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2013 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.psi.impl.cache.impl;

Expand All @@ -24,7 +10,8 @@
import com.intellij.psi.search.IndexPattern;
import com.intellij.psi.search.UsageSearchContext;
import com.intellij.util.text.CharArrayUtil;
import gnu.trove.TIntArrayList;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -61,15 +48,15 @@ protected final void advanceTodoItemCountsInToken() {
myTodoScannedBound = end;
}

public static class TodoScanningState {
public static final class TodoScanningState {
final IndexPattern[] myPatterns;
final Matcher[] myMatchers;
final TIntArrayList myOccurrences;
final IntList myOccurrences;

public TodoScanningState(IndexPattern[] patterns, Matcher[] matchers) {
myPatterns = patterns;
myMatchers = matchers;
myOccurrences = new TIntArrayList(1);
myOccurrences = new IntArrayList(1);
}
}

Expand All @@ -89,7 +76,7 @@ public static TodoScanningState createTodoScanningState(IndexPattern[] patterns)
}

public static void advanceTodoItemsCount(CharSequence input, OccurrenceConsumer consumer, TodoScanningState todoScanningState) {
todoScanningState.myOccurrences.resetQuick();
todoScanningState.myOccurrences.clear();

for (int i = todoScanningState.myMatchers.length - 1; i >= 0; --i) {
Matcher matcher = todoScanningState.myMatchers[i];
Expand Down
Original file line number Diff line number Diff line change
@@ -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.psi.impl.search;

import com.intellij.lang.ASTNode;
Expand All @@ -21,10 +21,8 @@
import com.intellij.util.containers.CollectionFactory;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.text.StringSearcher;
import gnu.trove.TIntProcedure;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import org.jetbrains.annotations.ApiStatus.ScheduledForRemoval;
import org.jetbrains.annotations.NotNull;

import java.util.List;
Expand Down Expand Up @@ -237,24 +235,6 @@ private static void diagnoseInvalidRange(@NotNull PsiElement scope,
// occurrences found is an int array of (startOffset used, endOffset used, occurrence 1 offset, occurrence 2 offset,...)
private static final ConcurrentMap<CharSequence, Map<StringSearcher, int[]>> cache = CollectionFactory.createConcurrentWeakIdentityMap();

/**
* @deprecated Use {@link #processTexts(CharSequence, int, int, StringSearcher, IntPredicate)}
*/
@Deprecated
@ScheduledForRemoval(inVersion = "2021.2")
public static boolean processTextOccurrences(@NotNull CharSequence text,
int startOffset,
int endOffset,
@NotNull StringSearcher searcher,
@NotNull TIntProcedure processor) {
for (int offset : getTextOccurrences(text, startOffset, endOffset, searcher)) {
if (!processor.execute(offset)) {
return false;
}
}
return true;
}

public static boolean processTexts(@NotNull CharSequence text,
int startOffset,
int endOffset,
Expand Down
1 change: 0 additions & 1 deletion platform/lang-impl/intellij.platform.lang.impl.iml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
<orderEntry type="module" module-name="intellij.platform.statistics" />
<orderEntry type="library" name="kotlinx-coroutines-jdk8" level="project" />
<orderEntry type="library" name="fastutil-min" level="project" />
<orderEntry type="library" name="Trove4j" level="project" />
<orderEntry type="library" name="Log4J" level="project" />
<orderEntry type="library" name="pty4j" level="project" />
<orderEntry type="module" module-name="intellij.platform.core.ui" />
Expand Down
Original file line number Diff line number Diff line change
@@ -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.psi.impl.search;

import com.intellij.openapi.util.text.StringUtil;
Expand All @@ -7,7 +7,6 @@
import gnu.trove.TIntArrayList;
import junit.framework.TestCase;


public class LowLevelSearchUtilTest extends TestCase {
public void testBackslashBeforeSequence() {
assertEquals(-1, doTest("n", "\\n"));
Expand All @@ -32,7 +31,7 @@ public void testBackslashBeforeSequenceNotBeginning() {
private static int doTest(String pattern, String text) {
StringSearcher searcher = new StringSearcher(pattern, true, true, true);
final int[] index = {-1};
LowLevelSearchUtil.processTextOccurrences(text, 0, text.length(), searcher, value -> {
LowLevelSearchUtil.processTexts(text, 0, text.length(), searcher, value -> {
index[0] = value;
return false;
});
Expand All @@ -49,7 +48,7 @@ public void testProcessTextOccurrencesNeverScansBeyondStartEndOffsetIfNeverAsked
found.remove(0);
int startOffset = text.length() / 2 + i % 20;
int endOffset = startOffset + 8;
boolean success = LowLevelSearchUtil.processTextOccurrences(text, startOffset, endOffset, searcher, offset -> {
boolean success = LowLevelSearchUtil.processTexts(text, startOffset, endOffset, searcher, offset -> {
found.add(offset);
return true;
});
Expand Down
Original file line number Diff line number Diff line change
@@ -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.openapi.application;

import com.intellij.openapi.util.text.Strings;
Expand Down Expand Up @@ -50,7 +50,6 @@ public static void addKotlinStdlib(@NotNull Collection<String> classPath) {
org.jdom.Document.class, // jDOM
org.apache.log4j.Appender.class, // Log4J
it.unimi.dsi.fastutil.objects.Object2IntMap.class, // fastutil
gnu.trove.THashSet.class, // Trove,
com.sun.jna.TypeMapper.class, // JNA
com.sun.jna.platform.FileUtils.class, // JNA (jna-platform)
org.apache.oro.text.regex.PatternMatcher.class, // OROMatcher
Expand Down

0 comments on commit 28f6f64

Please sign in to comment.