prefer jdk and fastutil collections

GitOrigin-RevId: 91f15eef29d9ea8f6790ee4442d2c9bdb7bff9a9
This commit is contained in:
Vladimir Krivosheev
2020-06-16 12:39:11 +03:00
committed by intellij-monorepo-bot
parent 8ed4edc262
commit 18b42837f5
46 changed files with 347 additions and 443 deletions
@@ -47,7 +47,7 @@ import com.intellij.testFramework.InspectionsKt;
import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.xml.XmlSchemaProvider;
import gnu.trove.TIntArrayList;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -278,7 +278,7 @@ public abstract class DaemonAnalyzerTestCase extends JavaCodeInsightTestCase {
protected List<HighlightInfo> doHighlighting() {
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
TIntArrayList toIgnore = new TIntArrayList();
IntArrayList toIgnore = new IntArrayList();
if (!doTestLineMarkers()) {
toIgnore.add(Pass.LINE_MARKERS);
}
@@ -295,7 +295,7 @@ public abstract class DaemonAnalyzerTestCase extends JavaCodeInsightTestCase {
}
boolean canChange = canChangeDocumentDuringHighlighting();
List<HighlightInfo> infos = CodeInsightTestFixtureImpl.instantiateAndRun(getFile(), getEditor(), toIgnore.toNativeArray(), canChange);
List<HighlightInfo> infos = CodeInsightTestFixtureImpl.instantiateAndRun(getFile(), getEditor(), toIgnore.toIntArray(), canChange);
if (!canChange) {
Document document = getDocument(getFile());
@@ -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.codeInsight.daemon;
import com.intellij.codeHighlighting.Pass;
@@ -19,7 +19,7 @@ import com.intellij.testFramework.HighlightTestInfo;
import com.intellij.testFramework.LightJavaCodeInsightTestCase;
import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl;
import com.intellij.util.ArrayUtilRt;
import gnu.trove.TIntArrayList;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -144,7 +144,7 @@ public abstract class LightDaemonAnalyzerTestCase extends LightJavaCodeInsightTe
protected List<HighlightInfo> doHighlighting() {
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
TIntArrayList toIgnoreList = new TIntArrayList();
IntArrayList toIgnoreList = new IntArrayList();
if (!doFolding()) {
toIgnoreList.add(Pass.UPDATE_FOLDING);
}
@@ -152,7 +152,7 @@ public abstract class LightDaemonAnalyzerTestCase extends LightJavaCodeInsightTe
toIgnoreList.add(Pass.LOCAL_INSPECTIONS);
toIgnoreList.add(Pass.WHOLE_FILE_LOCAL_INSPECTIONS);
}
int[] toIgnore = toIgnoreList.isEmpty() ? ArrayUtilRt.EMPTY_INT_ARRAY : toIgnoreList.toNativeArray();
int[] toIgnore = toIgnoreList.isEmpty() ? ArrayUtilRt.EMPTY_INT_ARRAY : toIgnoreList.toIntArray();
Editor editor = getEditor();
PsiFile file = getFile();
if (editor instanceof EditorWindow) {
@@ -74,7 +74,7 @@ import static com.intellij.openapi.util.Pair.pair;
/**
* @author Eugene Zhuravlev
*/
public class JavaBuilder extends ModuleLevelBuilder {
public final class JavaBuilder extends ModuleLevelBuilder {
private static final Logger LOG = Logger.getInstance(JavaBuilder.class);
private static final String JAVA_EXTENSION = "java";
@@ -1121,7 +1121,7 @@ public class JavaBuilder extends ModuleLevelBuilder {
return map;
}
private static class DiagnosticSink implements DiagnosticOutputConsumer {
private static final class DiagnosticSink implements DiagnosticOutputConsumer {
private final CompileContext myContext;
private final AtomicInteger myErrorCount = new AtomicInteger(0);
private final AtomicInteger myWarningCount = new AtomicInteger(0);
@@ -1281,7 +1281,7 @@ public class JavaBuilder extends ModuleLevelBuilder {
}
}
private class ClassProcessingConsumer implements OutputFileConsumer {
private final class ClassProcessingConsumer implements OutputFileConsumer {
private final CompileContext myContext;
private final OutputFileConsumer myDelegateOutputFileSink;
@@ -8,8 +8,9 @@ import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.util.ArrayUtilRt;
import com.intellij.util.text.CharSequenceHashingStrategy;
import gnu.trove.THashMap;
import com.intellij.util.containers.CollectionFactory;
import it.unimi.dsi.fastutil.objects.Object2ObjectMaps;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -17,7 +18,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.*;
import java.util.stream.Collectors;
public class FileTypeAssocTable<T> {
public final class FileTypeAssocTable<T> {
private final Map<CharSequence, T> myExtensionMappings;
private final Map<CharSequence, T> myExactFileNameMappings;
private final Map<CharSequence, T> myExactFileNameAnyCaseMappings;
@@ -29,13 +30,13 @@ public class FileTypeAssocTable<T> {
@NotNull Map<? extends CharSequence, ? extends T> exactFileNameAnyCaseMappings,
@NotNull Map<String, ? extends T> hashBangMap,
@NotNull List<? extends Pair<FileNameMatcher, T>> matchingMappings) {
myExtensionMappings = new THashMap<>(Math.max(10, extensionMappings.size()), 0.5f, CharSequenceHashingStrategy.CASE_INSENSITIVE);
myExtensionMappings = CollectionFactory.createCharSequenceMap(false, Math.max(10, extensionMappings.size()), 0.5f);
myExtensionMappings.putAll(extensionMappings);
myExactFileNameMappings = new THashMap<>(Math.max(10, exactFileNameMappings.size()), 0.5f, CharSequenceHashingStrategy.CASE_SENSITIVE);
myExactFileNameMappings = CollectionFactory.createCharSequenceMap(true, Math.max(10, exactFileNameMappings.size()), 0.5f);
myExactFileNameMappings.putAll(exactFileNameMappings);
myExactFileNameAnyCaseMappings = new THashMap<>(Math.max(10, exactFileNameAnyCaseMappings.size()), 0.5f, CharSequenceHashingStrategy.CASE_INSENSITIVE);
myExactFileNameAnyCaseMappings = CollectionFactory.createCharSequenceMap(false, Math.max(10, exactFileNameAnyCaseMappings.size()), 0.5f);
myExactFileNameAnyCaseMappings.putAll(exactFileNameAnyCaseMappings);
myHashBangMap = new THashMap<>(Math.max(10, hashBangMap.size()), 0.5f);
myHashBangMap = new Object2ObjectOpenHashMap<>(Math.max(10, hashBangMap.size()), 0.5f);
myHashBangMap.putAll(hashBangMap);
myMatchingMappings = new ArrayList<>(matchingMappings);
}
@@ -275,8 +276,7 @@ public class FileTypeAssocTable<T> {
return result;
}
@NotNull
Map<String, T> getAllHashBangPatterns() {
return Collections.unmodifiableMap(new THashMap<>(myHashBangMap));
@NotNull Map<String, T> getAllHashBangPatterns() {
return Object2ObjectMaps.unmodifiable(new Object2ObjectOpenHashMap<>(myHashBangMap));
}
}
@@ -1,21 +1,7 @@
/*
* 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 org.jetbrains.jps.model.ex;
import gnu.trove.THashMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.*;
@@ -27,7 +13,7 @@ import java.util.function.Supplier;
public class JpsElementContainerImpl extends JpsElementContainerEx implements JpsElementContainer {
private final Object myDataLock = new Object();
private final Map<JpsElementChildRole<?>, JpsElement> myElements = new THashMap<>(1);
private final Map<JpsElementChildRole<?>, JpsElement> myElements = new Object2ObjectOpenHashMap<>(1);
private final @NotNull JpsCompositeElementBase<?> myParent;
public JpsElementContainerImpl(@NotNull JpsCompositeElementBase<?> parent) {
@@ -161,7 +147,7 @@ public class JpsElementContainerImpl extends JpsElementContainerEx implements Jp
@Override
public void applyChanges(@NotNull JpsElementContainerEx modified) {
final Collection<JpsElementChildRole<?>> roles = new ArrayList<>();
synchronized (myDataLock) {
roles.addAll(myElements.keySet());
}
@@ -3,12 +3,11 @@ package org.jetbrains.jps.model.java.impl;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileFilters;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.util.ArrayUtilRt;
import com.intellij.util.containers.CollectionFactory;
import com.intellij.util.containers.ContainerUtil;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -53,7 +52,7 @@ public final class JavaSdkUtil {
}
FileFilter jarFileFilter = FileFilters.filesWithExtension("jar");
Set<String> pathFilter = new THashSet<>(FileUtil.PATH_HASHING_STRATEGY);
Set<String> pathFilter = CollectionFactory.createFilePathSet();
List<File> rootFiles = new ArrayList<>();
if (Registry.is("project.structure.add.tools.jar.to.new.jdk", false)) {
File toolsJar = new File(home, "lib/tools.jar");
@@ -1,22 +1,6 @@
/*
* 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 org.jetbrains.jps.model.java.impl.compiler;
import gnu.trove.THashMap;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.java.compiler.ProcessorConfigProfile;
@@ -27,19 +11,18 @@ import java.util.*;
* @author Eugene Zhuravlev
*/
public final class ProcessorConfigProfileImpl implements ProcessorConfigProfile {
private String myName = "";
private boolean myEnabled = false;
private boolean myObtainProcessorsFromClasspath = true;
private String myProcessorPath = "";
private boolean myUseProcessorModulePath = false;
private final Set<String> myProcessors = new LinkedHashSet<>(1); // empty list means all discovered
private final Map<String, String> myProcessorOptions = new THashMap<>(1); // key=value map of options
private final Map<String, String> myProcessorOptions = new HashMap<>(1); // key=value map of options
private String myGeneratedProductionDirectoryName = DEFAULT_PRODUCTION_DIR_NAME;
private String myGeneratedTestsDirectoryName = DEFAULT_TESTS_DIR_NAME;
private boolean myOutputRelativeToContentRoot = false;
private final Set<String> myModuleNames = new THashSet<>(1);
private final Set<String> myModuleNames = new HashSet<>(1);
public ProcessorConfigProfileImpl(String name) {
myName = name;
@@ -1,9 +1,8 @@
// 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 org.jetbrains.jps.model.library.impl;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import gnu.trove.THashSet;
import com.intellij.util.containers.CollectionFactory;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.*;
@@ -18,7 +17,7 @@ import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
public class JpsLibraryImpl<P extends JpsElement> extends JpsNamedCompositeElementBase<JpsLibraryImpl<P>> implements JpsTypedLibrary<P> {
public final class JpsLibraryImpl<P extends JpsElement> extends JpsNamedCompositeElementBase<JpsLibraryImpl<P>> implements JpsTypedLibrary<P> {
private static final ConcurrentMap<JpsOrderRootType, JpsElementCollectionRole<JpsLibraryRoot>> ourRootRoles = new ConcurrentHashMap<>();
private final JpsLibraryType<P> myLibraryType;
@@ -148,8 +147,7 @@ public class JpsLibraryImpl<P extends JpsElement> extends JpsNamedCompositeEleme
return urls;
}
private static final Set<String> AR_EXTENSIONS =
new THashSet<>(Arrays.asList("jar", "zip", "swc", "ane"), FileUtil.PATH_HASHING_STRATEGY);
private static final Set<String> AR_EXTENSIONS = CollectionFactory.createFilePathSet(Arrays.asList("jar", "zip", "swc", "ane"));
private static void collectArchives(File file, boolean recursively, List<? super String> result) {
final File[] children = file.listFiles();
@@ -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 org.jetbrains.jps.model.module.impl;
import com.intellij.openapi.util.Condition;
@@ -20,7 +6,7 @@ import com.intellij.util.CollectConsumer;
import com.intellij.util.Consumer;
import com.intellij.util.EmptyConsumer;
import com.intellij.util.Processor;
import gnu.trove.THashSet;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.library.JpsLibrary;
@@ -33,10 +19,10 @@ import java.util.Set;
public abstract class JpsDependenciesEnumeratorBase<Self extends JpsDependenciesEnumerator> implements JpsDependenciesEnumerator {
private boolean myWithoutSdk;
private boolean myWithoutLibraries;
protected boolean myWithoutDepModules;
private boolean myWithoutDepModules;
private boolean myWithoutModuleSourceEntries;
protected boolean myRecursively;
protected final Collection<JpsModule> myRootModules;
private final Collection<JpsModule> myRootModules;
private Condition<? super JpsDependencyElement> myCondition;
protected JpsDependenciesEnumeratorBase(Collection<JpsModule> rootModules) {
@@ -105,7 +91,7 @@ public abstract class JpsDependenciesEnumeratorBase<Self extends JpsDependencies
}
public boolean processDependencies(Processor<? super JpsDependencyElement> processor) {
THashSet<JpsModule> processed = new THashSet<>();
Set<JpsModule> processed = new ObjectOpenHashSet<>();
for (JpsModule module : myRootModules) {
if (!doProcessDependencies(module, processor, processed)) {
return false;
@@ -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 org.jetbrains.builtInWebServer
import com.intellij.openapi.project.Project
@@ -58,7 +58,7 @@ private class StaticFileHandler : WebServerFileHandler() {
private fun processSsi(file: Path, path: String, project: Project, request: FullHttpRequest, channel: Channel, extraHeaders: HttpHeaders) {
if (ssiProcessor == null) {
ssiProcessor = SsiProcessor(false)
ssiProcessor = SsiProcessor()
}
val buffer = channel.alloc().ioBuffer()
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2015 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 org.jetbrains.builtInWebServer.ssi
import com.intellij.openapi.project.Project
@@ -20,7 +6,6 @@ import com.intellij.openapi.util.io.FileUtil
import com.intellij.util.io.exists
import com.intellij.util.io.lastModified
import com.intellij.util.io.size
import gnu.trove.THashMap
import io.netty.handler.codec.http.HttpRequest
import org.jetbrains.builtInWebServer.WebServerPathToFileManager
import java.nio.file.Path
@@ -31,11 +16,11 @@ private val VARIABLE_NAMES = arrayOf("AUTH_TYPE", "CONTENT_LENGTH", "CONTENT_TYP
"PATH_TRANSLATED", "QUERY_STRING", "QUERY_STRING_UNESCAPED", "REMOTE_ADDR", "REMOTE_HOST", "REMOTE_PORT", "REMOTE_USER", "REQUEST_METHOD",
"REQUEST_URI", "SCRIPT_FILENAME", "SCRIPT_NAME", "SERVER_ADDR", "SERVER_NAME", "SERVER_PORT", "SERVER_PROTOCOL", "SERVER_SOFTWARE", "UNIQUE_ID")
class SsiExternalResolver(private val project: Project,
internal class SsiExternalResolver(private val project: Project,
private val request: HttpRequest,
private val parentPath: String,
private val parentFile: Path) {
private val variables = THashMap<String, String>()
private val variables = HashMap<String, String>()
fun addVariableNames(variableNames: MutableCollection<String>) {
for (variableName in VARIABLE_NAMES) {
@@ -61,7 +46,7 @@ class SsiExternalResolver(private val project: Project,
return parentFile.resolve(path)
}
path = if (path[0] == '/') path else parentPath + '/' + path
path = if (path[0] == '/') path else "$parentPath/$path"
val pathInfo = WebServerPathToFileManager.getInstance(project).getPathInfo(path, true) ?: return null
if (pathInfo.ioFile == null) {
return Paths.get(pathInfo.file!!.path)
@@ -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 org.jetbrains.builtInWebServer.ssi
import com.intellij.openapi.diagnostic.Logger
@@ -8,7 +8,6 @@ import com.intellij.util.io.lastModified
import com.intellij.util.io.readChars
import com.intellij.util.io.size
import com.intellij.util.text.CharArrayUtil
import gnu.trove.THashMap
import io.netty.buffer.ByteBufUtf8Writer
import java.io.IOException
import java.nio.file.Path
@@ -19,10 +18,10 @@ internal val LOG = Logger.getInstance(SsiProcessor::class.java)
internal const val COMMAND_START = "<!--#"
internal const val COMMAND_END = "-->"
class SsiStopProcessingException : RuntimeException()
internal class SsiStopProcessingException : RuntimeException()
class SsiProcessor(allowExec: Boolean) {
private val commands: MutableMap<String, SsiCommand> = THashMap()
internal open class SsiProcessor {
private val commands: MutableMap<String, SsiCommand> = HashMap()
init {
commands.put("config", SsiCommand { state, _, paramNames, paramValues, writer ->
@@ -71,11 +70,7 @@ class SsiProcessor(allowExec: Boolean) {
writer.write(variableValue ?: "(none)")
System.currentTimeMillis()
})
//noinspection StatementWithEmptyBody
if (allowExec) {
// commands.put("exec", new SsiExec());
}
commands.put("include", SsiCommand { state, commandName, paramNames, paramValues, writer ->
commands.put("include", SsiCommand { state, _, paramNames, paramValues, writer ->
var lastModified: Long = 0
val configErrorMessage = state.configErrorMessage
for (i in paramNames.indices) {
@@ -268,7 +263,7 @@ class SsiProcessor(allowExec: Boolean) {
return lastModifiedDate
}
protected fun parseParamNames(command: StringBuilder, start: Int): List<String> {
private fun parseParamNames(command: StringBuilder, start: Int): List<String> {
var bIdx = start
val values = SmartList<String>()
var inside = false
@@ -314,7 +309,7 @@ class SsiProcessor(allowExec: Boolean) {
}
@SuppressWarnings("AssignmentToForLoopParameter")
protected fun parseParamValues(command: StringBuilder, start: Int, count: Int): Array<String>? {
private fun parseParamValues(command: StringBuilder, start: Int, count: Int): Array<String>? {
var valueIndex = 0
var inside = false
val values = arrayOfNulls<String>(count)
@@ -374,7 +369,7 @@ class SsiProcessor(allowExec: Boolean) {
private fun parseCommand(instruction: StringBuilder): String {
var firstLetter = -1
var lastLetter = -1
for (i in 0..instruction.length - 1) {
for (i in instruction.indices) {
val c = instruction[i]
if (Character.isLetter(c)) {
if (firstLetter == -1) {
@@ -394,9 +389,9 @@ class SsiProcessor(allowExec: Boolean) {
return if (firstLetter == -1) "" else instruction.substring(firstLetter, lastLetter + 1)
}
protected fun charCmp(buf: CharSequence, index: Int, command: String): Boolean = CharArrayUtil.regionMatches(buf, index, index + command.length, command)
private fun charCmp(buf: CharSequence, index: Int, command: String): Boolean = CharArrayUtil.regionMatches(buf, index, index + command.length, command)
protected fun isSpace(c: Char): Boolean = c == ' ' || c == '\n' || c == '\t' || c == '\r'
private fun isSpace(c: Char): Boolean = c == ' ' || c == '\n' || c == '\t' || c == '\r'
protected fun isQuote(c: Char): Boolean = c == '\'' || c == '\"' || c == '`'
private fun isQuote(c: Char): Boolean = c == '\'' || c == '\"' || c == '`'
}
@@ -16,13 +16,8 @@
*/
package org.jetbrains.builtInWebServer.ssi;
import gnu.trove.THashMap;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import java.util.*;
/**
* Converts dates to strings using the same format specifiers as strftime
@@ -43,9 +38,9 @@ import java.util.TimeZone;
* @author Dan Sandberg
*/
@SuppressWarnings("SpellCheckingInspection")
public class Strftime {
protected static final Map<String, String> translate = new THashMap<>();
protected final SimpleDateFormat simpleDateFormat;
public final class Strftime {
private static final Map<String, String> translate = new HashMap<>();
private final SimpleDateFormat simpleDateFormat;
static {
translate.put("a", "EEE");
@@ -150,7 +145,7 @@ public class Strftime {
* @param pattern The pattern to search
* @return The modified pattern
*/
protected String convertDateFormat(String pattern) {
private static String convertDateFormat(String pattern) {
boolean inside = false;
boolean mark = false;
boolean modifiedCommand = false;
@@ -203,7 +198,7 @@ public class Strftime {
return buf.toString();
}
protected String quote(String str, boolean insideQuotes) {
private static String quote(String str, boolean insideQuotes) {
String retVal = str;
if (!insideQuotes) {
retVal = '\'' + retVal + '\'';
@@ -221,7 +216,7 @@ public class Strftime {
* @param oldInside Flag value
* @return True if new is inside buffer
*/
protected boolean translateCommand(StringBuilder buf, String pattern, int index, boolean oldInside) {
private static boolean translateCommand(StringBuilder buf, String pattern, int index, boolean oldInside) {
char firstChar = pattern.charAt(index);
boolean newInside = oldInside;
@@ -1,12 +1,12 @@
// 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 org.jetbrains.io.fastCgi
import com.intellij.util.Consumer
import gnu.trove.TIntObjectHashMap
import io.netty.buffer.ByteBuf
import io.netty.buffer.CompositeByteBuf
import io.netty.channel.ChannelHandlerContext
import io.netty.util.CharsetUtil
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
import org.jetbrains.io.Decoder
internal const val HEADER_LENGTH = 8
@@ -37,7 +37,7 @@ internal class FastCgiDecoder(private val errorOutputConsumer: Consumer<String>,
private var contentLength: Int = 0
private var paddingLength: Int = 0
private val dataBuffers = TIntObjectHashMap<ByteBuf>()
private val dataBuffers = Int2ObjectOpenHashMap<ByteBuf>()
override fun messageReceived(context: ChannelHandlerContext, input: ByteBuf) {
while (true) {
@@ -79,15 +79,14 @@ internal class FastCgiDecoder(private val errorOutputConsumer: Consumer<String>,
override fun channelInactive(context: ChannelHandlerContext) {
try {
if (!dataBuffers.isEmpty) {
dataBuffers.forEachEntry { _, buffer ->
if (!dataBuffers.isEmpty()) {
for (buffer in dataBuffers.values) {
try {
buffer.release()
}
catch (e: Throwable) {
LOG.error(e)
}
true
}
dataBuffers.clear()
}
@@ -1,29 +1,29 @@
// 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 org.jetbrains.io.jsonRpc
import com.intellij.openapi.Disposable
import com.intellij.openapi.util.SimpleTimer
import gnu.trove.THashSet
import gnu.trove.TObjectProcedure
import io.netty.buffer.ByteBuf
import io.netty.channel.Channel
import io.netty.util.AttributeKey
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
import org.jetbrains.concurrency.Promise
import org.jetbrains.io.webSocket.WebSocketServerOptions
import java.util.function.Consumer
import java.util.function.Predicate
internal val CLIENT = AttributeKey.valueOf<Client>("SocketHandler.client")
class ClientManager(private val listener: ClientListener?, val exceptionHandler: ExceptionHandler, options: WebSocketServerOptions? = null) : Disposable {
private val heartbeatTimer = SimpleTimer.getInstance().setUp({
forEachClient(TObjectProcedure {
if (it.channel.isActive) {
it.sendHeartbeat()
}
true
})
forEachClient(Consumer {
if (it.channel.isActive) {
it.sendHeartbeat()
}
})
}, (options ?: WebSocketServerOptions()).heartbeatDelay.toLong())
private val clients = THashSet<Client>()
private val clients = ObjectOpenHashSet<Client>()
fun addClient(client: Client) {
synchronized (clients) {
@@ -48,10 +48,10 @@ class ClientManager(private val listener: ClientListener?, val exceptionHandler:
}
fun <T> send(messageId: Int, message: ByteBuf, results: MutableList<Promise<Pair<Client, T>>>? = null) {
forEachClient(object : TObjectProcedure<Client> {
forEachClient(object : Consumer<Client> {
private var first: Boolean = false
override fun execute(client: Client): Boolean {
override fun accept(client: Client) {
try {
val result = client.send<Pair<Client, T>>(messageId, if (first) message else message.duplicate())
first = false
@@ -60,7 +60,6 @@ class ClientManager(private val listener: ClientListener?, val exceptionHandler:
catch (e: Throwable) {
exceptionHandler.exceptionCaught(e)
}
return true
}
})
}
@@ -87,9 +86,17 @@ class ClientManager(private val listener: ClientListener?, val exceptionHandler:
return true
}
fun forEachClient(procedure: TObjectProcedure<Client>) {
private fun forEachClient(procedure: Consumer<Client>) {
synchronized (clients) {
clients.forEach(procedure)
for (client in clients) {
procedure.accept(client)
}
}
}
fun findClient(predicate: Predicate<Client>): Client? {
synchronized (clients) {
return clients.firstOrNull { predicate.test(it) }
}
}
}
@@ -17,8 +17,8 @@ import com.intellij.util.Consumer
import com.intellij.util.SmartList
import com.intellij.util.io.releaseIfError
import com.intellij.util.io.writeUtf8
import gnu.trove.TIntArrayList
import io.netty.buffer.*
import it.unimi.dsi.fastutil.ints.IntArrayList
import org.jetbrains.annotations.TestOnly
import org.jetbrains.concurrency.Promise
import org.jetbrains.io.JsonReaderEx
@@ -30,10 +30,10 @@ import java.util.concurrent.atomic.AtomicInteger
private val LOG = Logger.getInstance(JsonRpcServer::class.java)
private val INT_LIST_TYPE_ADAPTER_FACTORY = object : TypeAdapterFactory {
private var typeAdapter: IntArrayListTypeAdapter<TIntArrayList>? = null
private var typeAdapter: IntArrayListTypeAdapter<IntArrayList>? = null
override fun <T> create(gson: Gson, type: TypeToken<T>): TypeAdapter<T>? {
if (type.type !== TIntArrayList::class.java) {
if (type.type !== IntArrayList::class.java) {
return null
}
@@ -264,51 +264,55 @@ class JsonRpcServer(private val clientManager: ClientManager) : MessageServer {
}
// gson - SOE if param has type class com.intellij.openapi.editor.impl.DocumentImpl$MyCharArray, so, use hack
if (param is CharSequence) {
JsonUtil.escape(param, buffer)
}
else if (param == null) {
buffer.writeAscii("null")
}
else if (param is Boolean) {
buffer.writeAscii(param.toString())
}
else if (param is Number) {
if (sb == null) {
sb = StringBuilder()
when (param) {
is CharSequence -> {
JsonUtil.escape(param, buffer)
}
if (param is Int) {
sb.append(param.toInt())
null -> {
buffer.writeAscii("null")
}
else if (param is Long) {
sb.append(param.toLong())
is Boolean -> {
buffer.writeAscii(param.toString())
}
else if (param is Float) {
sb.append(param.toFloat())
is Number -> {
if (sb == null) {
sb = StringBuilder()
}
when (param) {
is Int -> {
sb.append(param.toInt())
}
is Long -> {
sb.append(param.toLong())
}
is Float -> {
sb.append(param.toFloat())
}
is Double -> {
sb.append(param.toDouble())
}
else -> {
sb.append(param.toString())
}
}
buffer.writeAscii(sb)
sb.setLength(0)
}
else if (param is Double) {
sb.append(param.toDouble())
is Consumer<*> -> {
if (sb == null) {
sb = StringBuilder()
}
@Suppress("UNCHECKED_CAST")
(param as Consumer<StringBuilder>).consume(sb)
buffer.writeUtf8(sb)
sb.setLength(0)
}
else {
sb.append(param.toString())
else -> {
if (writer == null) {
writer = JsonWriter(ByteBufUtf8Writer(buffer))
}
(gson.getAdapter(param.javaClass) as TypeAdapter<Any>).write(writer, param)
}
buffer.writeAscii(sb)
sb.setLength(0)
}
else if (param is Consumer<*>) {
if (sb == null) {
sb = StringBuilder()
}
@Suppress("UNCHECKED_CAST")
(param as Consumer<StringBuilder>).consume(sb)
buffer.writeUtf8(sb)
sb.setLength(0)
}
else {
if (writer == null) {
writer = JsonWriter(ByteBufUtf8Writer(buffer))
}
(gson.getAdapter(param.javaClass) as TypeAdapter<Any>).write(writer, param)
}
}
}
@@ -325,15 +329,14 @@ private class IntArrayListTypeAdapter<T> : TypeAdapter<T>() {
override fun write(out: JsonWriter, value: T) {
var error: IOException? = null
out.beginArray()
(value as TIntArrayList).forEach { intValue ->
val iterator = (value as IntArrayList).iterator()
while (iterator.hasNext()) {
try {
out.value(intValue.toLong())
out.value(iterator.nextInt().toLong())
}
catch (e: IOException) {
error = e
}
error == null
}
error?.let { throw it }
@@ -1,28 +1,13 @@
/*
* Copyright 2000-2015 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.core;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeRegistry;
import com.intellij.openapi.fileTypes.UnknownFileType;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.testFramework.LightVirtualFile;
import gnu.trove.THashMap;
import com.intellij.util.containers.CollectionFactory;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -34,8 +19,8 @@ import java.util.Map;
/**
* @author yole
*/
public class CoreFileTypeRegistry extends FileTypeRegistry {
private final Map<String, FileType> myExtensionsMap = new THashMap<>(FileUtil.PATH_HASHING_STRATEGY);
public final class CoreFileTypeRegistry extends FileTypeRegistry {
private final Map<String, FileType> myExtensionsMap = CollectionFactory.createFilePathMap();
private final List<FileType> myAllFileTypes = new ArrayList<>();
public CoreFileTypeRegistry() {
@@ -67,8 +52,7 @@ public class CoreFileTypeRegistry extends FileTypeRegistry {
@NotNull
@Override
public FileType getFileTypeByFileName(@NotNull @NonNls String fileName) {
final String extension = FileUtilRt.getExtension(fileName);
return getFileTypeByExtension(extension);
return getFileTypeByExtension(FileUtilRt.getExtension(fileName));
}
@NotNull
@@ -2,20 +2,22 @@ package com.intellij.dupLocator.index;
import com.intellij.dupLocator.util.PsiFragment;
import com.intellij.openapi.util.ShutDownTracker;
import com.intellij.util.CommonProcessors;
import com.intellij.util.ConcurrencyUtil;
import com.intellij.util.io.EnumeratorIntegerDescriptor;
import com.intellij.util.io.PersistentHashMap;
import gnu.trove.TIntIntHashMap;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntListIterator;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.nio.file.Paths;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
public class TracingData {
public final class TracingData {
private static final String tracingDataLocation = "E:\\ultimate\\system\\occurrences";
private final PersistentHashMap<Integer, Integer> keys;
private final ScheduledThreadPoolExecutor pool = ConcurrencyUtil.newSingleScheduledThreadExecutor("My flushing thread");
@@ -37,14 +39,15 @@ public class TracingData {
}
}, 5, 5, TimeUnit.SECONDS);
ShutDownTracker.getInstance().registerShutdownTask(() -> flushingFuture.cancel(false));
} catch (IOException ex) {
}
catch (IOException ex) {
ex.printStackTrace();
}
keys = lkeys;
}
private static PersistentHashMap<Integer, Integer> createOrOpenMap() throws IOException {
return new PersistentHashMap<>(new File(tracingDataLocation).toPath(), EnumeratorIntegerDescriptor.INSTANCE,
return new PersistentHashMap<>(Paths.get(tracingDataLocation), EnumeratorIntegerDescriptor.INSTANCE,
EnumeratorIntegerDescriptor.INSTANCE);
}
@@ -65,25 +68,30 @@ public class TracingData {
}
currentMaxValue = maxValue.get();
}
} catch (IOException ex) {
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}
public static void main(String[] args) throws IOException {
PersistentHashMap<Integer, Integer> lkeys = createOrOpenMap();
List<Integer> mapping = (List<Integer>)lkeys.getAllKeysWithExistingMapping();
PersistentHashMap<Integer, Integer> lKeys = createOrOpenMap();
IntArrayList mapping = new IntArrayList();
lKeys.processKeysWithExistingMapping(new CommonProcessors.CollectProcessor<>(mapping));
System.out.println(mapping.size());
final TIntIntHashMap map = new TIntIntHashMap(mapping.size());
for(Integer i:mapping) map.put(i, lkeys.get(i));
Int2IntOpenHashMap map = new Int2IntOpenHashMap(mapping.size());
for (IntListIterator iterator = mapping.iterator(); iterator.hasNext(); ) {
int i = iterator.nextInt();
map.put(i, lKeys.get(i).intValue());
}
mapping.sort((o1, o2) -> map.get(o2) - map.get(o1));
for(int i = 0; i < 500; ++i) {
//System.out.println(mapping.get(i) + ",");
System.out.println(mapping.get(i) + ":" + map.get(mapping.get(i)));
System.out.println(mapping.getInt(i) + ":" + map.get(mapping.getInt(i)));
}
lkeys.close();
lKeys.close();
}
}
@@ -1,6 +1,9 @@
package com.intellij.dupLocator.treeHash;
import com.intellij.dupLocator.*;
import com.intellij.dupLocator.DupInfo;
import com.intellij.dupLocator.DuplicatesProfile;
import com.intellij.dupLocator.DuplocatorState;
import com.intellij.dupLocator.NodeSpecificHasher;
import com.intellij.dupLocator.util.DuplocatorUtil;
import com.intellij.dupLocator.util.PsiFragment;
import com.intellij.openapi.components.PathMacroManager;
@@ -13,11 +16,13 @@ import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.usageView.UsageInfo;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.io.xml.PrettyPrintWriter;
import gnu.trove.TIntObjectHashMap;
import gnu.trove.TIntObjectProcedure;
import gnu.trove.TObjectIntHashMap;
import gnu.trove.TObjectIntIterator;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectIterator;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -27,7 +32,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
public class DuplocatorHashCallback implements FragmentsCollector {
public final class DuplocatorHashCallback implements FragmentsCollector {
private static final Logger LOG = Logger.getInstance(DuplocatorHashCallback.class);
private TIntObjectHashMap<List<List<PsiFragment>>> myDuplicates;
@@ -41,7 +46,7 @@ public class DuplocatorHashCallback implements FragmentsCollector {
myDiscardCost = discardCost;
}
@SuppressWarnings({"UnusedDeclaration"})
@SuppressWarnings("UnusedDeclaration")
public DuplocatorHashCallback(final int bound, final int discardCost, final boolean readOnly) {
this(bound, discardCost);
myReadOnly = readOnly;
@@ -51,7 +56,7 @@ public class DuplocatorHashCallback implements FragmentsCollector {
this(lowerBound, 0);
}
@SuppressWarnings({"UnusedDeclaration"})
@SuppressWarnings("UnusedDeclaration")
public void setReadOnly(final boolean readOnly) {
myReadOnly = readOnly;
}
@@ -156,8 +161,7 @@ public class DuplocatorHashCallback implements FragmentsCollector {
}
public DupInfo getInfo() {
final TObjectIntHashMap<PsiFragment[]> duplicateList = new TObjectIntHashMap<>();
Object2IntOpenHashMap<PsiFragment[]> duplicateList = new Object2IntOpenHashMap<>();
myDuplicates.forEachEntry(new TIntObjectProcedure<List<List<PsiFragment>>>() {
@Override
public boolean execute(final int hash, final List<List<PsiFragment>> listList) {
@@ -180,9 +184,9 @@ public class DuplocatorHashCallback implements FragmentsCollector {
myDuplicates = null;
for (TObjectIntIterator<PsiFragment[]> dups = duplicateList.iterator(); dups.hasNext(); ) {
dups.advance();
PsiFragment[] fragments = dups.key();
for (ObjectIterator<Object2IntMap.Entry<PsiFragment[]>> iterator = duplicateList.object2IntEntrySet().fastIterator(); iterator.hasNext(); ) {
Object2IntMap.Entry<PsiFragment[]> entry = iterator.next();
PsiFragment[] fragments = entry.getKey();
LOG.assertTrue(fragments.length > 1);
boolean nested = false;
for (PsiFragment fragment : fragments) {
@@ -193,13 +197,12 @@ public class DuplocatorHashCallback implements FragmentsCollector {
}
if (nested) {
dups.remove();
iterator.remove();
}
}
final Object[] duplicates = duplicateList.keys();
Arrays.sort(duplicates, (x, y) -> ((PsiFragment[])y)[0].getCost() - ((PsiFragment[])x)[0].getCost());
PsiFragment[][] duplicates = duplicateList.keySet().toArray(new PsiFragment[][]{});
Arrays.sort(duplicates, (x, y) -> y[0].getCost() - x[0].getCost());
return new DupInfo() {
private final TIntObjectHashMap<GroupNodeDescription> myPattern2Description = new TIntObjectHashMap<>();
@@ -216,12 +219,12 @@ public class DuplocatorHashCallback implements FragmentsCollector {
@Override
public int getPatternDensity(int number) {
return ((PsiFragment[])duplicates[number]).length;
return duplicates[number].length;
}
@Override
public PsiFragment[] getFragmentOccurences(int pattern) {
return (PsiFragment[])duplicates[pattern];
return duplicates[pattern];
}
@Override
@@ -274,7 +277,6 @@ public class DuplocatorHashCallback implements FragmentsCollector {
return null;
}
@Override
@Nullable
public String getComment(int pattern) {
@@ -289,7 +291,7 @@ public class DuplocatorHashCallback implements FragmentsCollector {
@Override
public int getHash(final int i) {
return duplicateList.get((PsiFragment[])duplicates[i]);
return duplicateList.getInt(duplicates[i]);
}
};
}
@@ -298,7 +300,7 @@ public class DuplocatorHashCallback implements FragmentsCollector {
int[] hashCodes = myDuplicates.keys();
//fragments
try (BufferedWriter fileWriter = Files.newBufferedWriter(dir.resolve("fragments.xml"))) {
PrettyPrintWriter writer = new PrettyPrintWriter(fileWriter);
HierarchicalStreamWriter writer = new PrettyPrintWriter(fileWriter);
writer.startNode("root");
for (int hash : hashCodes) {
List<List<PsiFragment>> dupList = myDuplicates.get(hash);
@@ -319,7 +321,7 @@ public class DuplocatorHashCallback implements FragmentsCollector {
//duplicates
public static void writeDuplicates(@NotNull Path dir, @NotNull Project project, DupInfo info) throws IOException {
try (BufferedWriter fileWriter = Files.newBufferedWriter(dir.resolve("duplicates.xml"))) {
PrettyPrintWriter writer = new PrettyPrintWriter(fileWriter);
HierarchicalStreamWriter writer = new PrettyPrintWriter(fileWriter);
writer.startNode("root");
final int patterns = info.getPatterns();
for (int i = 0; i < patterns; i++) {
@@ -335,7 +337,7 @@ public class DuplocatorHashCallback implements FragmentsCollector {
}
private static void writeFragments(List<? extends PsiFragment> psiFragments,
PrettyPrintWriter writer,
HierarchicalStreamWriter writer,
@NotNull Project project,
boolean shouldWriteOffsets) {
final PathMacroManager macroManager = PathMacroManager.getInstance(project);
@@ -1,11 +1,12 @@
// 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.openapi.editor.colors.impl;
import com.intellij.application.options.EditorFontsConstants;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.colors.FontPreferences;
import com.intellij.openapi.editor.colors.ModifiableFontPreferences;
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;
@@ -22,8 +23,7 @@ import java.util.List;
* @author Denis Zhdanov
*/
public class FontPreferencesImpl extends ModifiableFontPreferences {
@NotNull private final TObjectIntHashMap<String> myFontSizes = new TObjectIntHashMap<>();
@NotNull private final Object2IntMap<String> myFontSizes = new Object2IntOpenHashMap<>();
@NotNull private final List<String> myEffectiveFontFamilies = new ArrayList<>();
@NotNull private final List<String> myRealFontFamilies = new ArrayList<>();
@@ -79,7 +79,7 @@ public class FontPreferencesImpl extends ModifiableFontPreferences {
@Override
public int getSize(@NotNull String fontFamily) {
int result = myFontSizes.get(fontFamily);
int result = myFontSizes.getInt(fontFamily);
if (result <= 0) {
result = myTemplateFontSize;
}
@@ -168,7 +168,7 @@ public class FontPreferencesImpl extends ModifiableFontPreferences {
modifiablePreferences.resetFontSizes();
for (String fontFamily : myRealFontFamilies) {
if (myFontSizes.containsKey(fontFamily)) {
modifiablePreferences.setFontSize(fontFamily, myFontSizes.get(fontFamily));
modifiablePreferences.setFontSize(fontFamily, myFontSizes.getInt(fontFamily));
}
}
modifiablePreferences.setUseLigatures(myUseLigatures);
@@ -217,7 +217,7 @@ public class FontPreferencesImpl extends ModifiableFontPreferences {
if (!myRealFontFamilies.equals(that.myRealFontFamilies)) return false;
for (String fontFamily : myRealFontFamilies) {
if (myFontSizes.get(fontFamily) != that.myFontSizes.get(fontFamily)) {
if (myFontSizes.getInt(fontFamily) != that.myFontSizes.getInt(fontFamily)) {
return false;
}
}
@@ -1,5 +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.psi.impl.search;
import com.intellij.lang.Language;
@@ -28,7 +27,7 @@ import com.intellij.util.Processor;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.text.CharArrayUtil;
import com.intellij.util.text.CharSequenceSubSequence;
import gnu.trove.TIntArrayList;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import org.jetbrains.annotations.NotNull;
import java.util.*;
@@ -70,12 +69,12 @@ public class IndexPatternSearcher extends QueryExecutorBase<IndexPatternOccurren
final CharSequence chars = file.getViewProvider().getContents();
boolean multiLine = queryParameters.isMultiLine();
List<CommentRange> commentRanges = findCommentTokenRanges(file, chars, queryParameters.getRange(), multiLine);
TIntArrayList occurrences = new TIntArrayList(1);
IntArrayList occurrences = new IntArrayList(1);
IndexPattern[] patterns = patternProvider != null ? patternProvider.getIndexPatterns()
: new IndexPattern[] {queryParameters.getPattern()};
for (int i = 0; i < commentRanges.size(); i++) {
occurrences.resetQuick();
occurrences.clear();
for (int j = patterns.length - 1; j >=0; --j) {
if (!collectPatternMatches(patterns, patterns[j], chars, commentRanges, i, file, queryParameters.getRange(), consumer,
@@ -198,12 +197,12 @@ public class IndexPatternSearcher extends QueryExecutorBase<IndexPatternOccurren
private static boolean collectPatternMatches(IndexPattern[] allIndexPatterns,
IndexPattern indexPattern,
CharSequence chars,
List<? extends CommentRange> commentRanges,
List<CommentRange> commentRanges,
int commentNum,
PsiFile file,
TextRange range,
Processor<? super IndexPatternOccurrence> consumer,
TIntArrayList matches,
IntArrayList matches,
boolean multiLine
) {
CommentRange commentRange = commentRanges.get(commentNum);
@@ -229,7 +228,7 @@ public class IndexPatternSearcher extends QueryExecutorBase<IndexPatternOccurren
int start = fitToRange(matcher.start(), commentPrefixLength, suffixStartOffset) + commentStart - commentPrefixLength;
int end = fitToRange(matcher.end(), commentPrefixLength, suffixStartOffset) + commentStart - commentPrefixLength;
if (start != end) {
if ((range == null || range.getStartOffset() <= start && end <= range.getEndOffset()) && matches.indexOf(start) == -1) {
if ((range == null || range.getStartOffset() <= start && end <= range.getEndOffset()) && !matches.contains(start)) {
List<TextRange> additionalRanges = multiLine ? findContinuation(start, chars, allIndexPatterns, commentRanges, commentNum)
: Collections.emptyList();
if (range != null && !additionalRanges.isEmpty() &&
@@ -255,7 +254,7 @@ public class IndexPatternSearcher extends QueryExecutorBase<IndexPatternOccurren
}
private static List<TextRange> findContinuation(int mainRangeStartOffset, CharSequence text, IndexPattern[] allIndexPatterns,
List<? extends CommentRange> commentRanges, int commentNum) {
List<CommentRange> commentRanges, int commentNum) {
CommentRange commentRange = commentRanges.get(commentNum);
int lineStartOffset = CharArrayUtil.shiftBackwardUntil(text, mainRangeStartOffset - 1, "\n") + 1;
int lineEndOffset = CharArrayUtil.shiftForwardUntil(text, mainRangeStartOffset, "\n");
@@ -292,7 +291,7 @@ public class IndexPatternSearcher extends QueryExecutorBase<IndexPatternOccurren
return result.isEmpty() ? Collections.emptyList() : result;
}
private static class CommentRange {
private static final class CommentRange {
private static final Comparator<CommentRange> BY_START_OFFSET_THEN_BY_END_OFFSET =
Comparator.comparingInt((CommentRange o) -> o.startOffset).thenComparingInt((CommentRange o) -> o.endOffset);
@@ -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.execution.impl
import com.intellij.execution.ExecutionBundle
@@ -12,7 +12,6 @@ import com.intellij.ui.*
import com.intellij.ui.components.JBList
import com.intellij.ui.speedSearch.SpeedSearchUtil
import com.intellij.util.containers.ContainerUtil
import gnu.trove.THashSet
import org.jetbrains.annotations.NonNls
import java.awt.BorderLayout
import java.util.function.Consumer
@@ -34,7 +33,7 @@ private val IGNORE_CASE_DISPLAY_NAME_COMPARATOR = Comparator<ConfigurationType>
*/
internal class RunDashboardTypesPanel(private val myProject: Project) : JPanel(BorderLayout()) {
private val listModel = CollectionListModel<ConfigurationType>()
private val list = JBList<ConfigurationType>(listModel)
private val list = JBList(listModel)
init {
val search = ListSpeedSearch(list) { it.displayName }
@@ -116,7 +115,7 @@ internal class RunDashboardTypesPanel(private val myProject: Project) : JPanel(B
})
}
fun isModified() = listModel.items.mapTo(THashSet()) { it.id } != RunDashboardManager.getInstance(myProject).types
fun isModified() = listModel.items.mapTo(HashSet()) { it.id } != RunDashboardManager.getInstance(myProject).types
fun reset() {
listModel.removeAll()
@@ -127,7 +126,7 @@ internal class RunDashboardTypesPanel(private val myProject: Project) : JPanel(B
fun apply() {
val dashboardManager = RunDashboardManager.getInstance(myProject)
val types = listModel.items.mapTo(THashSet()) { it.id }
val types = listModel.items.mapTo(HashSet()) { it.id }
if (types != dashboardManager.types) {
dashboardManager.types = types
}
@@ -36,7 +36,6 @@ import com.intellij.util.ObjectUtils
import com.intellij.util.SmartList
import com.intellij.util.ui.EmptyIcon
import com.intellij.util.ui.UIUtil
import gnu.trove.THashMap
import org.jetbrains.annotations.ApiStatus
import java.util.concurrent.ConcurrentLinkedDeque
import java.util.function.Predicate
@@ -46,7 +45,7 @@ private val EXECUTOR_KEY: Key<Executor> = Key.create("Executor")
private val CLOSE_LISTENER_KEY: Key<ContentManagerListener> = Key.create("CloseListener")
class RunContentManagerImpl(private val project: Project) : RunContentManager {
private val toolWindowIdToBaseIcon: MutableMap<String, Icon> = THashMap()
private val toolWindowIdToBaseIcon: MutableMap<String, Icon> = HashMap()
private val toolWindowIdZBuffer = ConcurrentLinkedDeque<String>()
init {
@@ -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.openapi.externalSystem.model.execution;
import com.intellij.execution.configurations.ParametersList;
@@ -7,7 +7,6 @@ import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.xmlb.annotations.Tag;
import gnu.trove.THashMap;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -20,7 +19,6 @@ import java.util.*;
*/
@Tag("ExternalSystemSettings")
public class ExternalSystemTaskExecutionSettings implements Cloneable {
@NotNull @NonNls public static final String TAG_NAME = "ExternalSystemSettings";
@NotNull @NonNls public static final Key<ParametersList> JVM_AGENT_SETUP_KEY = Key.create("jvmAgentSetup");
@@ -55,7 +53,7 @@ public class ExternalSystemTaskExecutionSettings implements Cloneable {
myTaskNames = ContainerUtil.copyList(source.myTaskNames);
myTaskDescriptions = ContainerUtil.copyList(source.myTaskDescriptions);
myEnv = source.myEnv.isEmpty() ? Collections.emptyMap() : new THashMap<>(source.myEnv);
myEnv = source.myEnv.isEmpty() ? Collections.emptyMap() : new HashMap<>(source.myEnv);
myPassParentEnvs = source.myPassParentEnvs;
}
@@ -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.openapi.externalSystem.settings;
import com.intellij.openapi.components.StoragePathMacros;
@@ -13,7 +13,7 @@ import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project;
import com.intellij.util.SmartList;
import com.intellij.util.containers.ContainerUtil;
import gnu.trove.THashMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -188,10 +188,10 @@ public abstract class AbstractExternalSystemLocalSettings<S extends AbstractExte
public static class State {
public final List<ExternalTaskExecutionInfo> recentTasks = new SmartList<>();
public Map<ExternalProjectPojo, Collection<ExternalProjectPojo>> availableProjects = new THashMap<>();
public Map<String/* linked project path */, Long/* last config modification stamp */> modificationStamps = new THashMap<>();
public Map<String/* linked project path */, ExternalProjectBuildClasspathPojo> projectBuildClasspath = new THashMap<>();
public Map<String/* linked project path */, SyncType> projectSyncType = new THashMap<>();
public Map<ExternalProjectPojo, Collection<ExternalProjectPojo>> availableProjects = new Object2ObjectOpenHashMap<>();
public Map<String/* linked project path */, Long/* last config modification stamp */> modificationStamps = new Object2ObjectOpenHashMap<>();
public Map<String/* linked project path */, ExternalProjectBuildClasspathPojo> projectBuildClasspath = new Object2ObjectOpenHashMap<>();
public Map<String/* linked project path */, SyncType> projectSyncType = new Object2ObjectOpenHashMap<>();
}
public enum SyncType {
@@ -1,20 +1,18 @@
// 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.openapi.externalSystem.autoimport
import com.intellij.openapi.Disposable
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.runInEdt
import com.intellij.openapi.components.ServiceManager
import com.intellij.openapi.components.service
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.externalSystem.model.ProjectSystemId
import com.intellij.openapi.project.Project
import gnu.trove.THashSet
import org.jetbrains.annotations.TestOnly
class ProjectNotificationAware : Disposable {
private var isHidden = false
private val projectsWithNotification = THashSet<ExternalSystemProjectId>()
private val projectsWithNotification = HashSet<ExternalSystemProjectId>()
fun notificationNotify(projectAware: ExternalSystemProjectAware) = runInEdt {
val projectId = projectAware.projectId
@@ -70,8 +68,6 @@ class ProjectNotificationAware : Disposable {
private val LOG = Logger.getInstance("#com.intellij.openapi.externalSystem.autoimport")
@JvmStatic
fun getInstance(project: Project): ProjectNotificationAware {
return ServiceManager.getService(project, ProjectNotificationAware::class.java)
}
fun getInstance(project: Project) = project.service<ProjectNotificationAware>()
}
}
@@ -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.openapi.externalSystem.configurationStore
import com.intellij.ProjectTopics
@@ -14,7 +14,6 @@ import com.intellij.openapi.project.isExternalStorageEnabled
import com.intellij.openapi.roots.ProjectModelElement
import com.intellij.openapi.startup.StartupManager
import com.intellij.util.Function
import gnu.trove.THashMap
import org.jdom.Element
import java.util.*
import java.util.concurrent.atomic.AtomicBoolean
@@ -30,7 +29,7 @@ internal class ExternalSystemStreamProviderFactory(private val project: Project)
private val isReimportOnMissedExternalStorageScheduled = AtomicBoolean(false)
private val storageSpecLock = ReentrantReadWriteLock()
private val storages = THashMap<String, Storage>()
private val storages = HashMap<String, Storage>()
init {
project.messageBus.connect().subscribe(ProjectTopics.MODULES, object : ModuleListener {
@@ -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.openapi.externalSystem.service.project.manage;
import com.intellij.ide.projectView.ProjectView;
@@ -34,9 +34,11 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.containers.CollectionFactory;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
import gnu.trove.THashSet;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes;
@@ -56,7 +58,7 @@ import static com.intellij.openapi.vfs.VfsUtilCore.pathToUrl;
* @author Denis Zhdanov
*/
@Order(ExternalSystemConstants.BUILTIN_SERVICE_ORDER)
public class ContentRootDataService extends AbstractProjectDataService<ContentRootData, ContentEntry> {
public final class ContentRootDataService extends AbstractProjectDataService<ContentRootData, ContentEntry> {
public static final com.intellij.openapi.util.Key<Boolean> CREATE_EMPTY_DIRECTORIES =
com.intellij.openapi.util.Key.create("createEmptyDirectories");
@@ -87,7 +89,7 @@ public class ContentRootDataService extends AbstractProjectDataService<ContentRo
forceDirectoriesCreation = projectDataNode.getUserData(CREATE_EMPTY_DIRECTORIES) == Boolean.TRUE;
}
Set<Module> modulesToExpand = new THashSet<>();
Set<Module> modulesToExpand = new ObjectOpenHashSet<>();
MultiMap<DataNode<ModuleData>, DataNode<ContentRootData>> byModule = ExternalSystemApiUtil.groupBy(toImport, ModuleData.class);
filterAndReportDuplicatingContentRoots(byModule, project);
@@ -143,7 +145,7 @@ public class ContentRootDataService extends AbstractProjectDataService<ContentRo
sourceFolderManager.removeSourceFolders(module);
final Set<ContentEntry> importedContentEntries = ContainerUtil.newIdentityTroveSet();
final Set<ContentEntry> importedContentEntries = new ReferenceOpenHashSet<>();
for (final DataNode<ContentRootData> node : data) {
final ContentRootData contentRoot = node.getData();
@@ -221,7 +223,7 @@ public class ContentRootDataService extends AbstractProjectDataService<ContentRo
}
private static Set<String> getSourceRoots(@NotNull ContentRootData contentRoot) {
Set<String> sourceRoots = new THashSet<>(FileUtil.PATH_HASHING_STRATEGY);
Set<String> sourceRoots = CollectionFactory.createFilePathSet();
for (ExternalSystemSourceType externalSrcType : ExternalSystemSourceType.values()) {
final JpsModuleSourceRootType<?> type = getJavaSourceRootType(externalSrcType);
if (type == null) continue;
@@ -432,11 +434,11 @@ public class ContentRootDataService extends AbstractProjectDataService<ContentRo
}
private static class DuplicateModuleReport {
private static final class DuplicateModuleReport {
private final ModuleData myOriginal;
private final List<ModuleData> myDuplicates = new ArrayList<>();
public DuplicateModuleReport(@NotNull ModuleData original) {
private DuplicateModuleReport(@NotNull ModuleData original) {
myOriginal = original;
}
@@ -17,16 +17,15 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.ModuleRootModificationUtil
import com.intellij.openapi.roots.SourceFolder
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.vfs.VfsUtilCore
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.openapi.vfs.newvfs.BulkFileListener
import com.intellij.openapi.vfs.newvfs.events.VFileCreateEvent
import com.intellij.openapi.vfs.newvfs.events.VFileEvent
import com.intellij.util.containers.CollectionFactory
import com.intellij.util.containers.MultiMap
import gnu.trove.THashMap
import gnu.trove.THashSet
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
import org.jetbrains.annotations.TestOnly
import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes
import org.jetbrains.jps.model.java.JavaResourceRootType
@@ -39,7 +38,7 @@ class SourceFolderManagerImpl(private val project: Project) : SourceFolderManage
private var isDisposed = false
private val mutex = Any()
private var sourceFolders = PathPrefixTreeMap<SourceFolderModel>()
private var sourceFoldersByModule = THashMap<String, ModuleModel>()
private var sourceFoldersByModule = Object2ObjectOpenHashMap<String, ModuleModel>()
override fun addSourceFolder(module: Module, url: String, type: JpsModuleSourceRootType<*>) {
synchronized(mutex) {
@@ -108,7 +107,7 @@ class SourceFolderManagerImpl(private val project: Project) : SourceFolderManage
private data class ModuleModel(
val module: Module,
val sourceFolders: MutableSet<String> = THashSet(FileUtil.PATH_HASHING_STRATEGY)
val sourceFolders: MutableSet<String> = CollectionFactory.createFilePathSet()
)
init {
@@ -144,7 +143,7 @@ class SourceFolderManagerImpl(private val project: Project) : SourceFolderManage
moduleNamesToSourceFolderState.remove(module.name)
}
}
});
})
}
fun rescanAndUpdateSourceFolders() {
@@ -206,7 +205,7 @@ class SourceFolderManagerImpl(private val project: Project) : SourceFolderManage
return
}
sourceFolders = PathPrefixTreeMap()
sourceFoldersByModule = THashMap()
sourceFoldersByModule = Object2ObjectOpenHashMap()
val moduleManager = ModuleManager.getInstance(project)
@@ -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.openapi.externalSystem.service.task.ui;
import com.intellij.icons.AllIcons;
@@ -40,6 +40,7 @@ import com.intellij.util.ObjectUtils;
import com.intellij.util.SmartList;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.SwingHelper;
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -317,7 +318,7 @@ public class ConfigureTasksActivationDialog extends DialogWrapper {
}
private void updateTree(@Nullable CachingSimpleNode nodeToUpdate) {
Set<CachingSimpleNode> toUpdate = ContainerUtil.newIdentityTroveSet();
Set<CachingSimpleNode> toUpdate = new ReferenceOpenHashSet<>();
if (nodeToUpdate == null) {
for (DefaultMutableTreeNode node : myTree.getSelectedNodes(DefaultMutableTreeNode.class, null)) {
final Object userObject = node.getUserObject();
@@ -512,8 +513,7 @@ public class ConfigureTasksActivationDialog extends DialogWrapper {
@Override
public MyNode[] buildChildren() {
return ContainerUtil.map2Array(myTaskActivationState.getTasks(myPhase), MyNode.class,
taskName -> new TaskNode(taskName, this));
return ContainerUtil.map2Array(myTaskActivationState.getTasks(myPhase), MyNode.class, taskName -> new TaskNode(taskName, this));
}
@Override
@@ -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.openapi.externalSystem.test;
import com.intellij.compiler.artifacts.ArtifactsTestUtil;
@@ -39,9 +39,9 @@ import com.intellij.util.ArrayUtilRt;
import com.intellij.util.ExceptionUtil;
import com.intellij.util.PathUtil;
import com.intellij.util.SmartList;
import com.intellij.util.containers.CollectionFactory;
import com.intellij.util.io.PathKt;
import com.intellij.util.io.TestFileSystemItem;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.SystemIndependent;
@@ -541,8 +541,8 @@ public abstract class ExternalSystemTestCase extends UsefulTestCase {
}
protected static void assertUnorderedPathsAreEqual(Collection<String> actual, Collection<String> expected) {
assertEquals(new SetWithToString<>(new THashSet<>(expected, FileUtil.PATH_HASHING_STRATEGY)),
new SetWithToString<>(new THashSet<>(actual, FileUtil.PATH_HASHING_STRATEGY)));
assertEquals(new SetWithToString<>(CollectionFactory.createFilePathSet(expected)),
new SetWithToString<>(CollectionFactory.createFilePathSet(actual)));
}
protected static <T> void assertUnorderedElementsAreEqual(T[] actual, T... expected) {
@@ -15,7 +15,7 @@ import com.intellij.util.SmartList;
import com.intellij.util.indexing.FileBasedIndex;
import com.intellij.util.indexing.ID;
import com.intellij.util.indexing.IdFilter;
import gnu.trove.THashSet;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -27,13 +27,12 @@ import java.util.*;
* @author yole
*/
public final class FilenameIndex {
@ApiStatus.Internal
@NonNls
public static final ID<String, Void> NAME = ID.create("FilenameIndex");
public static String @NotNull [] getAllFilenames(@Nullable Project project) {
Set<String> names = new THashSet<>();
Set<String> names = new HashSet<>();
processAllFileNames((String s) -> {
names.add(s);
return true;
@@ -115,7 +114,7 @@ public final class FilenameIndex {
private static Set<VirtualFile> getVirtualFilesByNameIgnoringCase(@NotNull final String name,
@NotNull final GlobalSearchScope scope,
@Nullable final IdFilter idFilter) {
final Set<String> keys = new THashSet<>();
Set<String> keys = new ObjectOpenHashSet<>();
processAllFileNames(value -> {
if (name.equalsIgnoreCase(value)) {
keys.add(value);
@@ -124,7 +123,7 @@ public final class FilenameIndex {
}, scope, idFilter);
// values accessed outside of processAllKeys
final Set<VirtualFile> files = new THashSet<>();
Set<VirtualFile> files = new ObjectOpenHashSet<>();
for (String each : keys) {
files.addAll(getVirtualFilesByName(each, scope, idFilter));
}
@@ -182,7 +181,7 @@ public final class FilenameIndex {
private static Collection<VirtualFile> getVirtualFilesByName(@NotNull String name,
@NotNull GlobalSearchScope scope,
IdFilter filter) {
Set<VirtualFile> files = new THashSet<>();
Set<VirtualFile> files = new ObjectOpenHashSet<>();
FileBasedIndex.getInstance().processValues(NAME, name, null, (file, value) -> {
files.add(file);
return true;
@@ -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.search.searches;
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.NotNull;
* have been searched and class inheritors for the class.
*
*/
public class DefinitionsScopedSearch extends ExtensibleQueryFactory<PsiElement, DefinitionsScopedSearch.SearchParameters> {
public final class DefinitionsScopedSearch extends ExtensibleQueryFactory<PsiElement, DefinitionsScopedSearch.SearchParameters> {
public static final ExtensionPointName<QueryExecutor<PsiElement, DefinitionsScopedSearch.SearchParameters>> EP_NAME = ExtensionPointName.create("com.intellij.definitionsScopedSearch");
public static final DefinitionsScopedSearch INSTANCE = new DefinitionsScopedSearch();
@@ -2,37 +2,40 @@
package com.intellij.codeInsight.hints
import com.intellij.openapi.editor.Inlay
import gnu.trove.TIntHashSet
import gnu.trove.TIntObjectHashMap
import it.unimi.dsi.fastutil.ints.Int2ObjectMap
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
import it.unimi.dsi.fastutil.ints.IntSet
/**
* Utility class to accumulate hints. Non thread-safe.
*/
class HintsBuffer {
val inlineHints = TIntObjectHashMap<MutableList<ConstrainedPresentation<*, HorizontalConstraints>>>()
val blockBelowHints = TIntObjectHashMap<MutableList<ConstrainedPresentation<*, BlockConstraints>>>()
val blockAboveHints = TIntObjectHashMap<MutableList<ConstrainedPresentation<*, BlockConstraints>>>()
val inlineHints = Int2ObjectOpenHashMap<MutableList<ConstrainedPresentation<*, HorizontalConstraints>>>()
internal val blockBelowHints = Int2ObjectOpenHashMap<MutableList<ConstrainedPresentation<*, BlockConstraints>>>()
internal val blockAboveHints = Int2ObjectOpenHashMap<MutableList<ConstrainedPresentation<*, BlockConstraints>>>()
fun mergeIntoThis(another: HintsBuffer) {
inlineHints.mergeIntoThis(another.inlineHints)
blockBelowHints.mergeIntoThis(another.blockBelowHints)
blockAboveHints.mergeIntoThis(another.blockAboveHints)
internal fun mergeIntoThis(another: HintsBuffer) {
mergeIntoThis(inlineHints, another.inlineHints)
mergeIntoThis(blockBelowHints, another.blockBelowHints)
mergeIntoThis(blockAboveHints, another.blockAboveHints)
}
/**
* Counts all offsets of given [placement] which are not inside [other]
*/
fun countDisjointElements(other: TIntHashSet, placement: Inlay.Placement): Int {
internal fun countDisjointElements(other: IntSet, placement: Inlay.Placement): Int {
val map = getMap(placement)
var count = 0
map.forEachKey {
if (it !in other) count++
true
val iterator = map.keys.iterator()
while (iterator.hasNext()) {
if (!other.contains(iterator.nextInt())) {
count++
}
}
return count
}
fun contains(offset: Int, placement: Inlay.Placement): Boolean {
internal fun contains(offset: Int, placement: Inlay.Placement): Boolean {
return getMap(placement).contains(offset)
}
@@ -41,24 +44,27 @@ class HintsBuffer {
}
@Suppress("UNCHECKED_CAST")
private fun getMap(placement: Inlay.Placement) : TIntObjectHashMap<MutableList<ConstrainedPresentation<*, *>>> {
private fun getMap(placement: Inlay.Placement) : Int2ObjectMap<MutableList<ConstrainedPresentation<*, *>>> {
return when (placement) {
Inlay.Placement.INLINE -> inlineHints
Inlay.Placement.ABOVE_LINE -> blockAboveHints
Inlay.Placement.BELOW_LINE -> blockBelowHints
Inlay.Placement.AFTER_LINE_END -> TODO()
} as TIntObjectHashMap<MutableList<ConstrainedPresentation<*, *>>>
} as Int2ObjectOpenHashMap<MutableList<ConstrainedPresentation<*, *>>>
}
}
fun <V>TIntObjectHashMap<MutableList<V>>.mergeIntoThis(another: TIntObjectHashMap<MutableList<V>>) {
another.forEachEntry { otherOffset, otherList ->
val current = this[otherOffset]
private fun <V> mergeIntoThis(one: Int2ObjectOpenHashMap<MutableList<V>>, another: Int2ObjectOpenHashMap<MutableList<V>>) {
val bIterator = another.int2ObjectEntrySet().fastIterator()
while (bIterator.hasNext()) {
val otherEntry = bIterator.next()
val otherOffset = otherEntry.intKey
val current = one.get(otherOffset)
if (current == null) {
put(otherOffset, otherList)
} else {
current.addAll(otherList)
one.put(otherOffset, otherEntry.value)
}
else {
current.addAll(otherEntry.value)
}
true
}
}
@@ -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.codeInsight.hints
import com.intellij.codeHighlighting.EditorBoundHighlightingPass
@@ -16,12 +16,12 @@ import com.intellij.openapi.util.Key
import com.intellij.psi.PsiElement
import com.intellij.psi.SyntaxTraverser
import com.intellij.util.Processor
import gnu.trove.TIntHashSet
import gnu.trove.TIntObjectHashMap
import it.unimi.dsi.fastutil.ints.Int2ObjectMap
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps
import it.unimi.dsi.fastutil.ints.IntOpenHashSet
import java.util.concurrent.ConcurrentLinkedQueue
import java.util.stream.IntStream
class InlayHintsPass(
private val rootElement: PsiElement,
private val enabledCollectors: List<CollectorWithSettings<out Any>>,
@@ -113,32 +113,32 @@ class InlayHintsPass(
}
private fun addInlineHints(hints: HintsBuffer,
inlayModel: InlayModel) {
hints.inlineHints.forEachEntry { offset, presentations ->
val renderer = InlineInlayRenderer(presentations)
val inlay = inlayModel.addInlineElement(offset, renderer) ?: return@forEachEntry false
private fun addInlineHints(hints: HintsBuffer, inlayModel: InlayModel) {
for (entry in Int2ObjectMaps.fastIterable(hints.inlineHints)) {
val renderer = InlineInlayRenderer(entry.value)
val inlay = inlayModel.addInlineElement(entry.intKey, renderer) ?: break
postprocessInlay(inlay)
true
}
}
private fun addBlockHints(inlayModel: InlayModel,
map: TIntObjectHashMap<MutableList<ConstrainedPresentation<*, BlockConstraints>>>,
map: Int2ObjectMap<MutableList<ConstrainedPresentation<*, BlockConstraints>>>,
showAbove: Boolean
) {
map.forEachEntry { offset, presentations ->
val renderer = BlockInlayRenderer(presentations)
for (entry in Int2ObjectMaps.fastIterable(map)) {
val presentations = entry.value
val constraints = presentations.first().constraints
val inlay = inlayModel.addBlockElement(
offset,
entry.intKey,
constraints?.relatesToPrecedingText ?: true,
showAbove,
constraints?.priority ?: 0,
renderer
) ?: return@forEachEntry false
BlockInlayRenderer(presentations)
) ?: break
postprocessInlay(inlay)
showAbove
if (!showAbove) {
break
}
}
}
@@ -182,11 +182,9 @@ class InlayHintsPass(
/**
* Estimates count of changes (removal, addition) for inlays
*/
fun estimateChangesCountForPlacement(existingInlayOffsets: IntStream,
collected: HintsBuffer,
placement: Inlay.Placement): Int {
fun estimateChangesCountForPlacement(existingInlayOffsets: IntStream, collected: HintsBuffer, placement: Inlay.Placement): Int {
var count = 0
val offsetsWithExistingHints = TIntHashSet()
val offsetsWithExistingHints = IntOpenHashSet()
for (offset in existingInlayOffsets) {
if (!collected.contains(offset, placement)) {
count++
@@ -7,7 +7,8 @@ import com.intellij.codeInsight.hints.presentation.RootInlayPresentation
import com.intellij.openapi.editor.Document
import com.intellij.openapi.editor.Editor
import com.intellij.util.SmartList
import gnu.trove.TIntObjectHashMap
import it.unimi.dsi.fastutil.ints.Int2ObjectMap
import java.util.function.IntFunction
class InlayHintsSinkImpl(val editor: Editor) : InlayHintsSink {
private val buffer = HintsBuffer()
@@ -18,7 +19,7 @@ class InlayHintsSinkImpl(val editor: Editor) : InlayHintsSink {
}
override fun addInlineElement(offset: Int, presentation: RootInlayPresentation<*>, constraints: HorizontalConstraints?) {
buffer.inlineHints.addCreatingListIfNeeded(offset, HorizontalConstrainedPresentation(presentation, constraints))
addCreatingListIfNeeded(buffer.inlineHints, offset, HorizontalConstrainedPresentation(presentation, constraints))
}
override fun addBlockElement(offset: Int,
@@ -37,24 +38,14 @@ class InlayHintsSinkImpl(val editor: Editor) : InlayHintsSink {
constraints: BlockConstraints?) {
val map = if (showAbove) buffer.blockAboveHints else buffer.blockBelowHints
val offset = document.getLineStartOffset(logicalLine)
map.addCreatingListIfNeeded(offset, BlockConstrainedPresentation(presentation, constraints))
addCreatingListIfNeeded(map, offset, BlockConstrainedPresentation(presentation, constraints))
}
internal fun complete(): HintsBuffer {
return buffer
}
}
companion object {
private fun <T : Any> TIntObjectHashMap<MutableList<ConstrainedPresentation<*, T>>>.addCreatingListIfNeeded(
offset: Int,
value: ConstrainedPresentation<*, T>
) {
var list = this[offset]
if (list == null) {
list = SmartList()
put(offset, list)
}
list.add(value)
}
}
private fun <T : Any> addCreatingListIfNeeded(map: Int2ObjectMap<MutableList<ConstrainedPresentation<*, T>>>, offset: Int, value: ConstrainedPresentation<*, T>) {
map.computeIfAbsent(offset, IntFunction { SmartList<ConstrainedPresentation<*, T>>() }).add(value)
}
@@ -18,7 +18,7 @@ import com.intellij.openapi.extensions.PluginDescriptor;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.containers.Interner;
import com.intellij.util.containers.WeakStringInterner;
import com.intellij.util.containers.WeakInterner;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -33,7 +33,7 @@ public final class IntentionManagerSettings implements PersistentStateComponent<
private static final Logger LOG = Logger.getInstance(IntentionManagerSettings.class);
private static final class MetaDataKey extends Pair<String, String> {
private static final Interner<String> ourInterner = new WeakStringInterner();
private static final Interner<String> ourInterner = WeakInterner.createWeakInterner();
private MetaDataKey(String @NotNull [] categoryNames, @NotNull final String familyName) {
super(StringUtil.join(categoryNames, ":"), ourInterner.intern(familyName));
}
@@ -1,5 +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.
package com.intellij.codeInspection.ui;
import com.intellij.codeHighlighting.HighlightDisplayLevel;
@@ -18,7 +17,6 @@ import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.psi.PsiElement;
import com.intellij.util.ObjectUtils;
import com.intellij.util.containers.Interner;
import com.intellij.util.containers.WeakStringInterner;
import com.intellij.xml.util.XmlStringUtil;
import gnu.trove.TObjectIntHashMap;
import org.jetbrains.annotations.NotNull;
@@ -106,7 +104,7 @@ public class ProblemDescriptionNode extends SuppressableInspectionTreeNode {
}
@NotNull
public InspectionToolWrapper getToolWrapper() {
public InspectionToolWrapper<?, ?> getToolWrapper() {
return getPresentation().getToolWrapper();
}
@@ -161,7 +159,7 @@ public class ProblemDescriptionNode extends SuppressableInspectionTreeNode {
return descriptor != null && getPresentation().isExcluded(descriptor);
}
private static final Interner<String> NAME_INTERNER = new WeakStringInterner();
private static final Interner<String> NAME_INTERNER = Interner.createWeakInterner();
@NotNull
@Override
@@ -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.execution.console
import com.intellij.execution.console.ConsoleHistoryModel.Entry
@@ -9,12 +9,11 @@ import com.intellij.openapi.util.SimpleModificationTracker
import com.intellij.openapi.util.TextRange
import com.intellij.util.containers.ConcurrentFactoryMap
import com.intellij.util.containers.ContainerUtil
import gnu.trove.TIntStack
import it.unimi.dsi.fastutil.ints.IntArrayList
/**
* @author Yuli Fiterman
*/
private val MasterModels = ConcurrentFactoryMap.create<String, MasterModel>(
{
MasterModel()
@@ -22,10 +21,8 @@ private val MasterModels = ConcurrentFactoryMap.create<String, MasterModel>(
ContainerUtil.createConcurrentWeakValueMap()
})
private fun assertWriteThread() = ApplicationManager.getApplication().assertIsWriteThread()
fun createModel(persistenceId: String, console: LanguageConsoleView): ConsoleHistoryModel {
val masterModel: MasterModel = MasterModels[persistenceId]!!
fun getPrefixFromConsole(): String {
@@ -46,7 +43,7 @@ private class PrefixHistoryModel constructor(private val masterModel: MasterMode
private var currentIndex: Int? = null
private var currentEntries: List<String>? = null
private var prevEntries: TIntStack = TIntStack()
private var prevEntries = IntArrayList()
private var historyPrefix: String = ""
init {
@@ -104,8 +101,8 @@ private class PrefixHistoryModel constructor(private val masterModel: MasterMode
override fun getHistoryPrev(): Entry? {
val entries = currentEntries ?: return null
return if (prevEntries.size() > 0) {
val index = prevEntries.pop()
return if (prevEntries.size > 0) {
val index = prevEntries.popInt()
currentIndex = index
createEntry(entries[index])
}
@@ -154,7 +151,7 @@ private class MasterModel(private val modTracker: SimpleModificationTracker = Si
override fun getMaxHistorySize() = UISettings.instance.state.consoleCommandHistoryLimit
override fun isEmpty(): Boolean = entries.isEmpty()
override fun isEmpty() = entries.isEmpty()
override fun getHistorySize(): Int = entries.size
override fun getHistorySize() = entries.size
}
@@ -34,13 +34,14 @@ import com.intellij.project.ProjectKt;
import com.intellij.ui.GuiUtils;
import com.intellij.util.ConcurrencyUtil;
import com.intellij.util.concurrency.AppExecutorUtil;
import com.intellij.util.containers.CollectionFactory;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.indexing.FileBasedIndex;
import com.intellij.util.indexing.FileBasedIndexImpl;
import com.intellij.util.indexing.FileBasedIndexProjectHandler;
import com.intellij.util.indexing.UnindexedFilesUpdater;
import com.intellij.util.messages.MessageBusConnection;
import gnu.trove.THashSet;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import org.jetbrains.annotations.CalledInAwt;
import org.jetbrains.annotations.NotNull;
@@ -70,7 +71,7 @@ public class ProjectRootManagerComponent extends ProjectRootManagerImpl implemen
private boolean myPointerChangesDetected;
private int myInsideRefresh;
private @NotNull Set<LocalFileSystem.WatchRequest> myRootsToWatch = new THashSet<>();
private @NotNull Set<LocalFileSystem.WatchRequest> myRootsToWatch = new ObjectOpenHashSet<>();
private Disposable myRootPointersDisposable = Disposer.newDisposable(); // accessed in EDT
public ProjectRootManagerComponent(@NotNull Project project) {
@@ -213,8 +214,8 @@ public class ProjectRootManagerComponent extends ProjectRootManagerImpl implemen
private @NotNull Pair<Set<String>, Set<String>> collectWatchRoots(@NotNull Disposable disposable) {
ApplicationManager.getApplication().assertReadAccessAllowed();
Set<String> recursivePaths = new THashSet<>(FileUtil.PATH_HASHING_STRATEGY);
Set<String> flatPaths = new THashSet<>(FileUtil.PATH_HASHING_STRATEGY);
Set<String> recursivePaths = CollectionFactory.createFilePathSet();
Set<String> flatPaths = CollectionFactory.createFilePathSet();
String projectFilePath = myProject.getProjectFilePath();
if (projectFilePath != null && !Project.DIRECTORY_STORE_FOLDER.equals(new File(projectFilePath).getParentFile().getName())) {
@@ -240,7 +241,7 @@ public class ProjectRootManagerComponent extends ProjectRootManagerImpl implemen
}
List<String> recursiveUrls = ContainerUtil.map(recursivePaths, VfsUtilCore::pathToUrl);
Set<String> excludedUrls = new THashSet<>();
Set<String> excludedUrls = new ObjectOpenHashSet<>();
// changes in files provided by this method should be watched manually because no-one's bothered to set up correct pointers for them
for (DirectoryIndexExcludePolicy excludePolicy : DirectoryIndexExcludePolicy.EP_NAME.getExtensions(myProject)) {
Collections.addAll(excludedUrls, excludePolicy.getExcludeUrlsForProject());
@@ -265,7 +266,7 @@ public class ProjectRootManagerComponent extends ProjectRootManagerImpl implemen
}
private void collectModuleWatchRoots(@NotNull Set<? super String> recursivePaths, @NotNull Set<? super String> flatPaths) {
Set<String> urls = new THashSet<>(FileUtil.PATH_HASHING_STRATEGY);
Set<String> urls = CollectionFactory.createFilePathSet();
for (Module module : ModuleManager.getInstance(myProject).getModules()) {
ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
@@ -332,7 +333,7 @@ public class ProjectRootManagerComponent extends ProjectRootManagerImpl implemen
@Override
public void markRootsForRefresh() {
Set<String> paths = new THashSet<>(FileUtil.PATH_HASHING_STRATEGY);
Set<String> paths = CollectionFactory.createFilePathSet();
collectModuleWatchRoots(paths, paths);
LocalFileSystem fs = LocalFileSystem.getInstance();
@@ -19,7 +19,6 @@ import com.intellij.util.ExceptionUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.io.BaseDataReader;
import com.intellij.util.io.BaseOutputReader;
import gnu.trove.THashSet;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -27,6 +26,7 @@ import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.HashSet;
import java.util.Set;
public class OSProcessHandler extends BaseOSProcessHandler {
@@ -297,7 +297,7 @@ public class OSProcessHandler extends BaseOSProcessHandler {
public static void deleteFileOnTermination(@NotNull GeneralCommandLine commandLine, @NotNull File fileToDelete) {
Set<File> set = commandLine.getUserData(DELETE_FILES_ON_TERMINATION);
if (set == null) {
set = new THashSet<>();
set = new HashSet<>();
commandLine.putUserData(DELETE_FILES_ON_TERMINATION, set);
}
set.add(fileToDelete);
@@ -15,7 +15,7 @@ import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.NullableFunction;
import com.intellij.util.PathUtil;
import gnu.trove.TIntObjectHashMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -163,7 +163,7 @@ public final class ProcessListUtil {
List<MacProcessInfo> fulls = doParseMacOutput(full);
if (commands == null || fulls == null) return null;
TIntObjectHashMap<String> idToCommand = new TIntObjectHashMap<>();
Int2ObjectOpenHashMap<String> idToCommand = new Int2ObjectOpenHashMap<>();
for (MacProcessInfo each : commands) {
idToCommand.put(each.pid, each.commandLine);
}
@@ -188,7 +188,7 @@ public final class ProcessListUtil {
List<MacProcessInfo> fulls = doParseMacOutput(full);
if (commands == null || fulls == null) return null;
TIntObjectHashMap<String> idToCommand = new TIntObjectHashMap<>();
Int2ObjectOpenHashMap<String> idToCommand = new Int2ObjectOpenHashMap<>();
for (MacProcessInfo each : commands) {
idToCommand.put(each.pid, each.commandLine);
}
@@ -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.util
import com.intellij.openapi.diagnostic.logger
@@ -10,7 +10,6 @@ import com.intellij.openapi.vfs.StandardFileSystems
import com.intellij.openapi.vfs.VfsUtilCore
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.util.io.URLUtil
import gnu.trove.TObjectHashingStrategy
import java.net.MalformedURLException
import java.net.URI
import java.net.URISyntaxException
@@ -20,8 +19,6 @@ import java.util.regex.Pattern
private val URI_PATTERN = Pattern.compile("^([^:/?#]+):(//)?([^/?#]*)([^?#;]*)(.*)")
object Urls {
val caseInsensitiveUrlHashingStrategy: TObjectHashingStrategy<Url> by lazy { CaseInsensitiveUrlHashingStrategy() }
@JvmStatic
fun newUri(scheme: String?, path: String): Url = UrlImpl(scheme, null, path)
@@ -83,8 +80,8 @@ object Urls {
// java.net.URI.create cannot parse "file:///Test Stuff" - but you don't need to worry about it - this method is aware
@JvmStatic
fun parseFromIdea(url: CharSequence): Url? {
for (i in 0 until url.length) {
when (url[i]) {
for (element in url) {
when (element) {
':' -> return parseUrl(url) // file:// or dart:core/foo
'/', '\\' -> return newLocalFileUrl(url.toString())
}
@@ -185,9 +182,4 @@ object Urls {
catch (e: URISyntaxException) {
throw RuntimeException(e)
}
}
private class CaseInsensitiveUrlHashingStrategy : TObjectHashingStrategy<Url> {
override fun computeHashCode(url: Url?) = url?.hashCodeCaseInsensitive() ?: 0
override fun equals(url1: Url, url2: Url) = Urls.equals(url1, url2, caseSensitive = false, ignoreParameters = false)
}
@@ -1,15 +1,15 @@
// 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 org.jetbrains.io
import com.intellij.openapi.diagnostic.logger
import com.intellij.util.PathUtilRt
import gnu.trove.THashMap
import io.netty.channel.Channel
import io.netty.channel.ChannelFutureListener
import io.netty.channel.DefaultFileRegion
import io.netty.handler.codec.http.*
import io.netty.handler.ssl.SslHandler
import io.netty.handler.stream.ChunkedNioFile
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
import java.nio.channels.FileChannel
import java.nio.file.Files
import java.nio.file.NoSuchFileException
@@ -26,7 +26,7 @@ fun flushChunkedResponse(channel: Channel, isKeepAlive: Boolean) {
}
private val fileExtToMimeType by lazy {
val map = THashMap<String, String>(1100)
val map = Object2ObjectOpenHashMap<String, String>(1100)
FileResponses.javaClass.getResourceAsStream("/mime-types.csv").bufferedReader().useLines {
for (line in it) {
if (line.isBlank()) {
@@ -1,5 +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.
package com.intellij.ide.util.treeView.smartTree;
import com.intellij.ide.structureView.impl.StructureViewElementWrapper;
@@ -10,7 +9,7 @@ import com.intellij.openapi.project.IndexNotReadyException;
import com.intellij.openapi.project.Project;
import com.intellij.pom.Navigatable;
import com.intellij.util.containers.JBIterable;
import gnu.trove.THashMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import org.jetbrains.annotations.NotNull;
import java.util.*;
@@ -77,8 +76,10 @@ public abstract class CachingChildrenTreeNode <Value> extends AbstractTreeNode<V
final Object value1 = o1.getValue();
final Object value2 = o2.getValue();
for (Sorter sorter : mySorters) {
final int result = sorter.getComparator().compare(value1, value2);
if (result != 0) return result;
int result = sorter.getComparator().compare(value1, value2);
if (result != 0) {
return result;
}
}
return 0;
}
@@ -123,7 +124,7 @@ public abstract class CachingChildrenTreeNode <Value> extends AbstractTreeNode<V
}
private void groupElements(@NotNull Grouper grouper) {
ArrayList<AbstractTreeNode<TreeElement>> ungrouped = new ArrayList<>();
List<AbstractTreeNode<TreeElement>> ungrouped = new ArrayList<>();
Collection<AbstractTreeNode<?>> children = getChildren();
for (AbstractTreeNode child : children) {
if (child instanceof TreeElementWrapper) {
@@ -189,7 +190,7 @@ public abstract class CachingChildrenTreeNode <Value> extends AbstractTreeNode<V
@NotNull
private Map<Group, GroupWrapper> createGroupNodes(@NotNull Collection<? extends Group> groups) {
Map<Group, GroupWrapper> result = new THashMap<>();
Map<Group, GroupWrapper> result = new Object2ObjectOpenHashMap<>(groups.size());
for (Group group : groups) {
result.put(group, createGroupWrapper(getProject(), group, myTreeModel));
}
@@ -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.util.io;
import com.intellij.openapi.diagnostic.Logger;
@@ -576,7 +576,7 @@ public class PersistentHashMap<Key, Value> implements AppendablePersistentMap<Ke
return values;
}
public final boolean processKeysWithExistingMapping(Processor<? super Key> processor) throws IOException {
public final boolean processKeysWithExistingMapping(@NotNull Processor<? super Key> processor) throws IOException {
synchronized (getDataAccessLock()) {
try {
if (myAppendCache != null) {