mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
cleanup, migrate from trove collections to java/fastutil
GitOrigin-RevId: ead63095fcedcf3699e7df62113982cad6dbe6bc
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f94057479a
commit
94f7837a33
3
.idea/libraries/fastutil_min.xml
generated
3
.idea/libraries/fastutil_min.xml
generated
@@ -1,6 +1,9 @@
|
||||
<component name="libraryTable">
|
||||
<library name="fastutil-min" type="repository">
|
||||
<properties include-transitive-deps="false" maven-id="org.jetbrains.intellij.deps.fastutil:intellij-deps-fastutil:8.3.1-1" />
|
||||
<ANNOTATIONS>
|
||||
<root url="file://$PROJECT_DIR$/lib/annotations/fastutil" />
|
||||
</ANNOTATIONS>
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/intellij/deps/fastutil/intellij-deps-fastutil/8.3.1-1/intellij-deps-fastutil-8.3.1-1.jar!/" />
|
||||
</CLASSES>
|
||||
|
||||
@@ -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.openapi.components;
|
||||
|
||||
import com.intellij.openapi.application.PathMacroFilter;
|
||||
@@ -13,11 +13,9 @@ import org.jetbrains.annotations.Nullable;
|
||||
public abstract class PathMacroMap {
|
||||
private static final Logger LOG = Logger.getInstance(PathMacroMap.class);
|
||||
|
||||
@NotNull
|
||||
public abstract String substitute(@NotNull String text, boolean caseSensitive);
|
||||
public abstract @NotNull String substitute(@NotNull String text, boolean caseSensitive);
|
||||
|
||||
@NotNull
|
||||
public final String substitute(@NotNull String text, boolean caseSensitive, boolean recursively) {
|
||||
public final @NotNull CharSequence substitute(@NotNull String text, boolean caseSensitive, boolean recursively) {
|
||||
return recursively
|
||||
? substituteRecursively(text, caseSensitive)
|
||||
: substitute(text, caseSensitive);
|
||||
@@ -39,7 +37,7 @@ public abstract class PathMacroMap {
|
||||
else if (child instanceof Text) {
|
||||
Text t = (Text)child;
|
||||
String oldText = t.getText();
|
||||
String newText = recursively ? substituteRecursively(oldText, caseSensitive) : substitute(oldText, caseSensitive);
|
||||
String newText = recursively ? substituteRecursively(oldText, caseSensitive).toString() : substitute(oldText, caseSensitive);
|
||||
if (oldText != newText) {
|
||||
// it is faster to call 'setText' right away than perform additional 'equals' check
|
||||
t.setText(newText);
|
||||
@@ -65,23 +63,21 @@ public abstract class PathMacroMap {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getAttributeValue(@NotNull Attribute attribute, @Nullable PathMacroFilter filter, boolean caseSensitive, boolean recursively) {
|
||||
public @NotNull String getAttributeValue(@NotNull Attribute attribute, @Nullable PathMacroFilter filter, boolean caseSensitive, boolean recursively) {
|
||||
String oldValue = attribute.getValue();
|
||||
if (recursively || (filter != null && filter.recursePathMacros(attribute))) {
|
||||
return substituteRecursively(oldValue, caseSensitive);
|
||||
return substituteRecursively(oldValue, caseSensitive).toString();
|
||||
}
|
||||
else {
|
||||
return substitute(oldValue, caseSensitive);
|
||||
}
|
||||
}
|
||||
|
||||
public final void substitute(@NotNull Element e, boolean caseSensitive, final boolean recursively) {
|
||||
public final void substitute(@NotNull Element e, boolean caseSensitive, boolean recursively) {
|
||||
substitute(e, caseSensitive, recursively, null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String substituteRecursively(@NotNull String text, boolean caseSensitive) {
|
||||
public @NotNull CharSequence substituteRecursively(@NotNull String text, boolean caseSensitive) {
|
||||
return substitute(text, caseSensitive);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,20 +2,20 @@
|
||||
package org.jetbrains.jps.model.serialization;
|
||||
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
import com.intellij.openapi.util.text.Strings;
|
||||
import com.intellij.util.PathUtilRt;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.intellij.openapi.util.io.FileUtilRt.toSystemIndependentName;
|
||||
|
||||
public class PathMacroUtil {
|
||||
public final class PathMacroUtil {
|
||||
@NonNls public static final String PROJECT_DIR_MACRO_NAME = "PROJECT_DIR";
|
||||
@NonNls public static final String PROJECT_NAME_MACRO_NAME = "PROJECT_NAME";
|
||||
|
||||
@@ -33,10 +33,9 @@ public class PathMacroUtil {
|
||||
private static volatile Map<String, String> ourGlobalMacrosForIde;
|
||||
private static volatile Map<String, String> ourGlobalMacrosForStandalone;
|
||||
|
||||
@Nullable
|
||||
public static String getModuleDir(@NotNull String moduleFilePath) {
|
||||
public static @Nullable String getModuleDir(@NotNull String moduleFilePath) {
|
||||
String moduleDir = PathUtilRt.getParentPath(moduleFilePath);
|
||||
if (StringUtil.isEmpty(moduleDir)) {
|
||||
if (Strings.isEmpty(moduleDir)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -44,28 +43,25 @@ public class PathMacroUtil {
|
||||
// rather than the .idea directory itself is considered the module root
|
||||
// (so that a Ruby IDE project doesn't break if its directory is moved together with the .idea directory)
|
||||
String moduleDirParent = PathUtilRt.getParentPath(moduleDir);
|
||||
if (!StringUtil.isEmpty(moduleDirParent) && PathUtilRt.getFileName(moduleDir).equals(DIRECTORY_STORE_NAME)) {
|
||||
if (!Strings.isEmpty(moduleDirParent) && PathUtilRt.getFileName(moduleDir).equals(DIRECTORY_STORE_NAME)) {
|
||||
moduleDir = moduleDirParent;
|
||||
}
|
||||
moduleDir = toSystemIndependentName(moduleDir);
|
||||
moduleDir = FileUtilRt.toSystemIndependentName(moduleDir);
|
||||
if (moduleDir.endsWith(":/")) {
|
||||
moduleDir = moduleDir.substring(0, moduleDir.length() - 1);
|
||||
}
|
||||
return moduleDir;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getUserHomePath() {
|
||||
public static @NotNull String getUserHomePath() {
|
||||
return Objects.requireNonNull(getGlobalSystemMacroValue(USER_HOME_NAME));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Map<String, String> getGlobalSystemMacros() {
|
||||
public static @NotNull Map<String, String> getGlobalSystemMacros() {
|
||||
return getGlobalSystemMacros(true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Map<String, String> getGlobalSystemMacros(boolean insideIde) {
|
||||
public static @NotNull Map<String, String> getGlobalSystemMacros(boolean insideIde) {
|
||||
if (insideIde) {
|
||||
if (ourGlobalMacrosForIde == null) {
|
||||
ourGlobalMacrosForIde = computeGlobalPathMacrosInsideIde();
|
||||
@@ -81,37 +77,35 @@ public class PathMacroUtil {
|
||||
}
|
||||
|
||||
private static Map<String, String> computeGlobalPathMacrosForStandaloneCode() {
|
||||
ContainerUtil.ImmutableMapBuilder<String, String> builder = ContainerUtil.immutableMapBuilder();
|
||||
Map<String, String> result = new HashMap<>();
|
||||
String homePath = PathManager.getHomePath(false);
|
||||
if (homePath != null) {
|
||||
builder.put(APPLICATION_HOME_DIR, toSystemIndependentName(homePath))
|
||||
.put(APPLICATION_CONFIG_DIR, toSystemIndependentName(PathManager.getConfigPath()))
|
||||
.put(APPLICATION_PLUGINS_DIR, toSystemIndependentName(PathManager.getPluginsPath()));
|
||||
result.put(APPLICATION_HOME_DIR, FileUtilRt.toSystemIndependentName(homePath));
|
||||
result.put(APPLICATION_CONFIG_DIR, FileUtilRt.toSystemIndependentName(PathManager.getConfigPath()));
|
||||
result.put(APPLICATION_PLUGINS_DIR, FileUtilRt.toSystemIndependentName(PathManager.getPluginsPath()));
|
||||
}
|
||||
builder.put(USER_HOME_NAME, computeUserHomePath());
|
||||
return builder.build();
|
||||
result.put(USER_HOME_NAME, computeUserHomePath());
|
||||
return Collections.unmodifiableMap(result);
|
||||
}
|
||||
|
||||
private static Map<String, String> computeGlobalPathMacrosInsideIde() {
|
||||
return ContainerUtil.<String, String>immutableMapBuilder()
|
||||
.put(APPLICATION_HOME_DIR, toSystemIndependentName(PathManager.getHomePath()))
|
||||
.put(APPLICATION_CONFIG_DIR, toSystemIndependentName(PathManager.getConfigPath()))
|
||||
.put(APPLICATION_PLUGINS_DIR, toSystemIndependentName(PathManager.getPluginsPath()))
|
||||
.put(USER_HOME_NAME, computeUserHomePath()).build();
|
||||
Map<String, String> result = new HashMap<>();
|
||||
result.put(APPLICATION_HOME_DIR, FileUtilRt.toSystemIndependentName(PathManager.getHomePath()));
|
||||
result.put(APPLICATION_CONFIG_DIR, FileUtilRt.toSystemIndependentName(PathManager.getConfigPath()));
|
||||
result.put(APPLICATION_PLUGINS_DIR, FileUtilRt.toSystemIndependentName(PathManager.getPluginsPath()));
|
||||
result.put(USER_HOME_NAME, computeUserHomePath());
|
||||
return Collections.unmodifiableMap(result);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String computeUserHomePath() {
|
||||
return StringUtil.trimEnd(toSystemIndependentName(SystemProperties.getUserHome()), "/");
|
||||
private static @NotNull String computeUserHomePath() {
|
||||
return Strings.trimEnd(FileUtilRt.toSystemIndependentName(SystemProperties.getUserHome()), "/");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getGlobalSystemMacroValue(String name) {
|
||||
public static @Nullable String getGlobalSystemMacroValue(String name) {
|
||||
return getGlobalSystemMacroValue(name, true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getGlobalSystemMacroValue(String name, boolean insideIde) {
|
||||
public static @Nullable String getGlobalSystemMacroValue(String name, boolean insideIde) {
|
||||
return getGlobalSystemMacros(insideIde).get(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<root>
|
||||
<item name='it.unimi.dsi.fastutil.Hash.Strategy boolean equals(K, K) 0'>
|
||||
<annotation name='org.jetbrains.annotations.Nullable'/>
|
||||
</item>
|
||||
<item name='it.unimi.dsi.fastutil.Hash.Strategy boolean equals(K, K) 1'>
|
||||
<annotation name='org.jetbrains.annotations.Nullable'/>
|
||||
</item>
|
||||
<item name='it.unimi.dsi.fastutil.Hash.Strategy int hashCode(K) 0'>
|
||||
<annotation name='org.jetbrains.annotations.Nullable'/>
|
||||
</item>
|
||||
</root>
|
||||
@@ -799,7 +799,7 @@ public final class DocumentImpl extends UserDataHolderBase implements DocumentEx
|
||||
}
|
||||
}
|
||||
|
||||
private class DelayedExceptions {
|
||||
private final class DelayedExceptions {
|
||||
Throwable myException;
|
||||
|
||||
void register(Throwable e) {
|
||||
|
||||
@@ -115,10 +115,9 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiFile getCachedPsiFile(@NotNull Document document) {
|
||||
final VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(document);
|
||||
if (virtualFile == null || !virtualFile.isValid()) return null;
|
||||
return getCachedPsiFile(virtualFile);
|
||||
public final PsiFile getCachedPsiFile(@NotNull Document document) {
|
||||
VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(document);
|
||||
return virtualFile == null || !virtualFile.isValid() ? null : getCachedPsiFile(virtualFile);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -4,7 +4,7 @@ package com.intellij.serialization
|
||||
import com.amazon.ion.IonReader
|
||||
import com.amazon.ion.IonType
|
||||
import com.amazon.ion.system.IonReaderBuilder
|
||||
import com.intellij.util.containers.ObjectIntHashMap
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap
|
||||
import java.lang.reflect.Type
|
||||
import kotlin.reflect.full.primaryConstructor
|
||||
import kotlin.reflect.jvm.isAccessible
|
||||
@@ -18,7 +18,7 @@ private const val ID_FIELD_NAME = "@id"
|
||||
|
||||
internal class BeanBinding(beanClass: Class<*>) : BaseBeanBinding(beanClass), Binding {
|
||||
private lateinit var bindings: Array<Binding>
|
||||
private lateinit var nameToBindingIndex: ObjectIntHashMap<String>
|
||||
private lateinit var nameToBindingIndex: Object2IntOpenHashMap<String>
|
||||
private lateinit var properties: List<MutableAccessor>
|
||||
|
||||
private val propertyMapping: Lazy<NonDefaultConstructorInfo?> = lazy {
|
||||
@@ -31,7 +31,8 @@ internal class BeanBinding(beanClass: Class<*>) : BaseBeanBinding(beanClass), Bi
|
||||
override fun init(originalType: Type, context: BindingInitializationContext) {
|
||||
val list = context.propertyCollector.collect(beanClass)
|
||||
properties = list
|
||||
val nameToBindingIndex = ObjectIntHashMap<String>(list.size)
|
||||
val nameToBindingIndex = Object2IntOpenHashMap<String>(list.size)
|
||||
nameToBindingIndex.defaultReturnValue(-1)
|
||||
bindings = Array(list.size) { index ->
|
||||
val accessor = list.get(index)
|
||||
val binding = context.bindingProducer.getNestedBinding(accessor)
|
||||
@@ -122,13 +123,13 @@ internal class BeanBinding(beanClass: Class<*>) : BaseBeanBinding(beanClass), Bi
|
||||
return@readStruct
|
||||
}
|
||||
|
||||
val bindingIndex = nameToBindingIndex.get(fieldName)
|
||||
val bindingIndex = nameToBindingIndex.getInt(fieldName)
|
||||
if (bindingIndex == -1) {
|
||||
LOG.error("Cannot find binding (fieldName=$fieldName, valueType=${reader.type}, beanClass=${beanClass.name}")
|
||||
return@readStruct
|
||||
}
|
||||
|
||||
val binding = bindings[bindingIndex]
|
||||
val binding = bindings.get(bindingIndex)
|
||||
try {
|
||||
initArgs[argIndex] = binding.deserialize(subReadContext, hostObject)
|
||||
}
|
||||
@@ -239,16 +240,16 @@ internal class BeanBinding(beanClass: Class<*>) : BaseBeanBinding(beanClass), Bi
|
||||
return@readStruct
|
||||
}
|
||||
|
||||
val bindingIndex = nameToBindingIndex.get(fieldName)
|
||||
val bindingIndex = nameToBindingIndex.getInt(fieldName)
|
||||
// ignore unknown field
|
||||
if (bindingIndex == -1) {
|
||||
context.errors.unknownFields.add(ReadError("Unknown field (fieldName=$fieldName, beanClass=${beanClass.name})"))
|
||||
return@readStruct
|
||||
}
|
||||
|
||||
val binding = bindings[bindingIndex]
|
||||
val binding = bindings.get(bindingIndex)
|
||||
try {
|
||||
binding.deserialize(instance, accessors[bindingIndex], context)
|
||||
binding.deserialize(instance, accessors.get(bindingIndex), context)
|
||||
}
|
||||
catch (e: SerializationException) {
|
||||
throw e
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// 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.serialization
|
||||
|
||||
import com.intellij.util.SystemProperties
|
||||
import gnu.trove.THashMap
|
||||
import gnu.trove.TObjectHashingStrategy
|
||||
import it.unimi.dsi.fastutil.Hash
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import java.lang.reflect.ParameterizedType
|
||||
import java.lang.reflect.Type
|
||||
@@ -13,25 +13,25 @@ import kotlin.concurrent.read
|
||||
import kotlin.concurrent.write
|
||||
|
||||
internal abstract class BindingProducer : BindingInitializationContext {
|
||||
private val cache: MutableMap<Type, Binding> = THashMap(object : TObjectHashingStrategy<Type> {
|
||||
override fun equals(o1: Type, o2: Type): Boolean {
|
||||
private val cache: MutableMap<Type, Binding> = Object2ObjectOpenCustomHashMap(object : Hash.Strategy<Type> {
|
||||
override fun equals(o1: Type?, o2: Type?): Boolean {
|
||||
if (o1 is ParameterizedType && o2 is ParameterizedType) {
|
||||
return o1 === o2 || (Arrays.equals(o1.actualTypeArguments, o2.actualTypeArguments) && o1.rawType == o2.rawType)
|
||||
}
|
||||
return o1 == o2
|
||||
}
|
||||
|
||||
override fun computeHashCode(o: Type): Int {
|
||||
override fun hashCode(o: Type?): Int {
|
||||
// ours ParameterizedTypeImpl hash code differs from java impl
|
||||
return when (o) {
|
||||
is ParameterizedType -> 31 * o.rawType.hashCode() + Arrays.hashCode(o.actualTypeArguments)
|
||||
null -> 0
|
||||
else -> o.hashCode()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
private val cacheLock = ReentrantReadWriteLock()
|
||||
|
||||
@get:TestOnly
|
||||
internal val bindingCount: Int
|
||||
get() = cacheLock.read { cache.size }
|
||||
|
||||
@@ -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.serialization
|
||||
|
||||
import com.amazon.ion.IonType
|
||||
@@ -76,7 +76,7 @@ internal class CollectionBinding(type: ParameterizedType, context: BindingInitia
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
var result = property.readUnsafe(hostObject) as MutableCollection<Any?>?
|
||||
var result = property.readUnsafe(hostObject) as? MutableCollection<Any?>?
|
||||
if (result != null && ClassUtil.isMutableCollection(result)) {
|
||||
result.clear()
|
||||
if (emptyResult != null) {
|
||||
@@ -97,16 +97,16 @@ internal class CollectionBinding(type: ParameterizedType, context: BindingInitia
|
||||
private fun createCollection(propertyForDebugPurposes: MutableAccessor? = null): MutableCollection<Any?> {
|
||||
if (collectionClass.isInterface) {
|
||||
when (collectionClass) {
|
||||
Set::class.java -> return THashSet()
|
||||
Set::class.java -> return HashSet()
|
||||
List::class.java, Collection::class.java -> return ArrayList()
|
||||
else -> LOG.warn("Unknown collection type interface: ${collectionClass} (property: $propertyForDebugPurposes)")
|
||||
}
|
||||
}
|
||||
else {
|
||||
return when (collectionClass) {
|
||||
THashSet::class.java -> THashSet()
|
||||
HashSet::class.java -> HashSet()
|
||||
ArrayList::class.java -> ArrayList()
|
||||
THashSet::class.java -> THashSet()
|
||||
SmartList::class.java -> SmartList()
|
||||
else -> {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
|
||||
@@ -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.serialization
|
||||
|
||||
import com.amazon.ion.IonReader
|
||||
@@ -6,9 +6,8 @@ import com.amazon.ion.IonWriter
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream
|
||||
import com.intellij.util.ParameterizedTypeImpl
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
import com.intellij.util.containers.ObjectIntHashMap
|
||||
import gnu.trove.TIntObjectHashMap
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
|
||||
import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap
|
||||
import java.io.InputStream
|
||||
import java.io.OutputStream
|
||||
import java.io.Reader
|
||||
@@ -114,10 +113,14 @@ object SkipNullAndEmptySerializationFilter : SerializationFilter {
|
||||
}
|
||||
|
||||
class ObjectIdWriter {
|
||||
private val map: ObjectIntHashMap<Any> = ObjectIntHashMap(ContainerUtil.identityStrategy())
|
||||
private val map = Reference2IntOpenHashMap<Any>()
|
||||
private var counter = 0
|
||||
|
||||
fun getId(obj: Any) = map.get(obj)
|
||||
init {
|
||||
map.defaultReturnValue(-1)
|
||||
}
|
||||
|
||||
fun getId(obj: Any) = map.getInt(obj)
|
||||
|
||||
fun registerObject(obj: Any): Int {
|
||||
val id = counter++
|
||||
@@ -129,7 +132,7 @@ class ObjectIdWriter {
|
||||
}
|
||||
|
||||
class ObjectIdReader {
|
||||
private val map: TIntObjectHashMap<Any> = TIntObjectHashMap()
|
||||
private val map = Int2ObjectOpenHashMap<Any>()
|
||||
|
||||
fun getObject(id: Int): Any {
|
||||
return map.get(id)
|
||||
|
||||
@@ -4,7 +4,6 @@ package com.intellij.serialization.stateProperties
|
||||
import com.intellij.openapi.components.BaseState
|
||||
import com.intellij.openapi.components.StatePropertyFactory
|
||||
import com.intellij.openapi.components.StoredPropertyBase
|
||||
import gnu.trove.THashSet
|
||||
import java.util.*
|
||||
|
||||
internal class StatePropertyFactoryImpl : StatePropertyFactory {
|
||||
@@ -34,11 +33,11 @@ internal class StatePropertyFactoryImpl : StatePropertyFactory {
|
||||
override fun int(defaultValue: Int) = IntStoredProperty(defaultValue, null)
|
||||
|
||||
override fun stringSet(defaultValue: String?): CollectionStoredProperty<String, MutableSet<String>> {
|
||||
val collection = THashSet<String>()
|
||||
val collection = HashSet<String>()
|
||||
defaultValue?.let {
|
||||
collection.add(defaultValue)
|
||||
}
|
||||
return CollectionStoredProperty<String, MutableSet<String>>(collection, defaultValue)
|
||||
return CollectionStoredProperty(collection, defaultValue)
|
||||
}
|
||||
|
||||
override fun <E> treeSet(): StoredPropertyBase<MutableSet<E>> where E : Comparable<E>, E : BaseState = CollectionStoredProperty(TreeSet(), null)
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.intellij.serialization.SerializationException
|
||||
import com.intellij.serialization.xml.KotlinAwareBeanBinding
|
||||
import com.intellij.util.io.URLUtil
|
||||
import com.intellij.util.xmlb.*
|
||||
import gnu.trove.THashMap
|
||||
import org.jdom.Element
|
||||
import org.jdom.JDOMException
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
@@ -135,11 +134,11 @@ fun deserializeBaseStateWithCustomNameFilter(state: BaseState, excludedPropertyN
|
||||
private val serializer = MyXmlSerializer()
|
||||
|
||||
private abstract class OldBindingProducer<ROOT_BINDING> {
|
||||
private val cache: MutableMap<Type, ROOT_BINDING> = THashMap()
|
||||
private val cache: MutableMap<Type, ROOT_BINDING> = HashMap()
|
||||
private val cacheLock = ReentrantReadWriteLock()
|
||||
|
||||
@get:TestOnly
|
||||
internal val bindingCount: Int
|
||||
val bindingCount: Int
|
||||
get() = cacheLock.read { cache.size }
|
||||
|
||||
fun getRootBinding(aClass: Class<*>, originalType: Type = aClass): ROOT_BINDING {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
// 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.serialization
|
||||
|
||||
import com.intellij.testFramework.assertions.Assertions.assertThat
|
||||
import gnu.trove.THashMap
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TestName
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.util.*
|
||||
import kotlin.collections.HashMap
|
||||
|
||||
class MapTest {
|
||||
@Rule
|
||||
@@ -26,8 +26,8 @@ class MapTest {
|
||||
@Suppress("unused")
|
||||
class TestBean {
|
||||
@JvmField
|
||||
val a: MutableMap<String, String> = THashMap()
|
||||
val b: MutableMap<String, String> = THashMap()
|
||||
val a: MutableMap<String, String> = HashMap()
|
||||
val b: MutableMap<String, String> = HashMap()
|
||||
}
|
||||
|
||||
serializer.write(TestBean(), ByteArrayOutputStream())
|
||||
@@ -59,7 +59,7 @@ class MapTest {
|
||||
fun `parametrized type as map value`() {
|
||||
class TestBean {
|
||||
@JvmField
|
||||
val map: MutableMap<String, Set<String>> = THashMap()
|
||||
val map: MutableMap<String, Set<String>> = HashMap()
|
||||
}
|
||||
|
||||
val bean = TestBean()
|
||||
@@ -72,7 +72,7 @@ class MapTest {
|
||||
fun `empty map`() {
|
||||
class TestBean {
|
||||
@JvmField
|
||||
val map: MutableMap<String, Set<String>> = THashMap()
|
||||
val map: MutableMap<String, Set<String>> = HashMap()
|
||||
}
|
||||
|
||||
val bean = TestBean()
|
||||
@@ -99,8 +99,8 @@ class MapTest {
|
||||
|
||||
private class TestMapBean {
|
||||
@JvmField
|
||||
val map: MutableMap<String, String> = THashMap()
|
||||
val map: MutableMap<String, String> = HashMap()
|
||||
|
||||
@JvmField
|
||||
val beanMap: MutableMap<TestMapBean, TestMapBean> = THashMap()
|
||||
val beanMap: MutableMap<TestMapBean, TestMapBean> = HashMap()
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
// 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.serialization
|
||||
|
||||
import com.intellij.openapi.util.SystemInfo
|
||||
import com.intellij.testFramework.assertions.Assertions.assertThat
|
||||
import gnu.trove.THashMap
|
||||
import org.junit.Assume.assumeTrue
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
@@ -11,6 +10,7 @@ import org.junit.rules.TestName
|
||||
import java.io.File
|
||||
import java.nio.file.Paths
|
||||
import java.util.*
|
||||
import kotlin.collections.HashMap
|
||||
|
||||
class ObjectSerializerTest {
|
||||
@Rule
|
||||
@@ -158,7 +158,7 @@ class ObjectSerializerTest {
|
||||
fun `interface type for map value - allowSubTypes`() {
|
||||
class TestInterfaceBean {
|
||||
@JvmField
|
||||
val shape: MutableMap<String, Shape> = THashMap()
|
||||
val shape: MutableMap<String, Shape> = HashMap()
|
||||
}
|
||||
|
||||
val bean = TestInterfaceBean()
|
||||
|
||||
@@ -109,7 +109,7 @@ public class PathMacroManagerTest {
|
||||
ReplacePathToMacroMap map = new ProjectPathMacroManager(createProject("/home/user/foo")).getReplacePathMap();
|
||||
String src = "-Dfoo=/home/user/foo/bar/home -Dbar=\"/home/user\"";
|
||||
String dst = "-Dfoo=$PROJECT_DIR$/bar/home -Dbar=\"$PROJECT_DIR$/..\"";
|
||||
assertThat(map.substituteRecursively(src, true)).isEqualTo(dst);
|
||||
assertThat(map.substituteRecursively(src, true).toString()).isEqualTo(dst);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -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.google.common.net.InetAddresses
|
||||
@@ -51,9 +51,9 @@ fun serverBootstrap(group: EventLoopGroup): ServerBootstrap {
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
private fun EventLoopGroup.serverSocketChannelClass(): Class<out ServerSocketChannel> {
|
||||
return when {
|
||||
this is NioEventLoopGroup -> NioServerSocketChannel::class.java
|
||||
this is io.netty.channel.oio.OioEventLoopGroup -> io.netty.channel.socket.oio.OioServerSocketChannel::class.java
|
||||
return when (this) {
|
||||
is NioEventLoopGroup -> NioServerSocketChannel::class.java
|
||||
is io.netty.channel.oio.OioEventLoopGroup -> io.netty.channel.socket.oio.OioServerSocketChannel::class.java
|
||||
// SystemInfo.isMacOSSierra && this is KQueueEventLoopGroup -> KQueueServerSocketChannel::class.java
|
||||
else -> throw Exception("Unknown event loop group type: ${this.javaClass.name}")
|
||||
}
|
||||
|
||||
@@ -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.io;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -99,7 +99,7 @@ final class PortUnificationServerHandler extends Decoder {
|
||||
else if (isHttp(magic1, magic2)) {
|
||||
NettyUtil.addHttpServerCodec(pipeline);
|
||||
pipeline.addLast("delegatingHttpHandler", delegatingHttpRequestHandler);
|
||||
final Logger logger = Logger.getInstance(BuiltInServer.class);
|
||||
Logger logger = Logger.getInstance(BuiltInServer.class);
|
||||
if (logger.isDebugEnabled()) {
|
||||
pipeline.addLast(new ChannelOutboundHandlerAdapter() {
|
||||
@Override
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.io
|
||||
|
||||
import com.intellij.util.concurrency.AppExecutorUtil
|
||||
import io.netty.bootstrap.Bootstrap
|
||||
import io.netty.channel.ChannelOption
|
||||
import io.netty.channel.oio.OioEventLoopGroup
|
||||
import io.netty.channel.socket.oio.OioSocketChannel
|
||||
|
||||
// used in Go
|
||||
@Deprecated(level = DeprecationLevel.ERROR, message = "Prefer to use NIO")
|
||||
fun oioClientBootstrap(): Bootstrap {
|
||||
val bootstrap = Bootstrap().group(OioEventLoopGroup(1, AppExecutorUtil.getAppExecutorService())).channel(OioSocketChannel::class.java)
|
||||
bootstrap.option(ChannelOption.TCP_NODELAY, true).option(ChannelOption.SO_KEEPALIVE, true)
|
||||
return bootstrap
|
||||
}
|
||||
@@ -1,20 +1,16 @@
|
||||
// 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.application.options;
|
||||
|
||||
import com.intellij.openapi.application.PathMacroFilter;
|
||||
import com.intellij.openapi.components.CompositePathMacroFilter;
|
||||
import com.intellij.openapi.components.PathMacroMap;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.containers.SmartHashSet;
|
||||
import com.intellij.openapi.util.text.Strings;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -47,7 +43,7 @@ public final class PathMacrosCollector extends PathMacroMap {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
Set<String> result = new SmartHashSet<>(preResult);
|
||||
Set<String> result = new HashSet<>(preResult);
|
||||
result.removeAll(pathMacros.getSystemMacroNames());
|
||||
result.removeAll(pathMacros.getLegacyMacroNames());
|
||||
pathMacros.removeToolMacroNames(result);
|
||||
@@ -57,8 +53,8 @@ public final class PathMacrosCollector extends PathMacroMap {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String substituteRecursively(@NotNull String text, boolean caseSensitive) {
|
||||
if (StringUtil.isEmpty(text)) {
|
||||
public CharSequence substituteRecursively(@NotNull String text, boolean caseSensitive) {
|
||||
if (Strings.isEmpty(text)) {
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -73,7 +69,7 @@ public final class PathMacrosCollector extends PathMacroMap {
|
||||
@NotNull
|
||||
@Override
|
||||
public String substitute(@NotNull String text, boolean caseSensitive) {
|
||||
if (StringUtil.isEmpty(text)) {
|
||||
if (Strings.isEmpty(text)) {
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.intellij.openapi.components.*
|
||||
import com.intellij.openapi.extensions.ExtensionPointName
|
||||
import com.intellij.openapi.util.ModificationTracker
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
import gnu.trove.THashSet
|
||||
import org.jdom.Element
|
||||
import org.jetbrains.jps.model.serialization.JpsGlobalLoader.PathVariablesSerializer
|
||||
import org.jetbrains.jps.model.serialization.PathMacroUtil
|
||||
@@ -33,7 +32,7 @@ open class PathMacrosImpl @JvmOverloads constructor(private val loadContributors
|
||||
|
||||
const val IGNORED_MACRO_ELEMENT = "ignoredMacro"
|
||||
const val MAVEN_REPOSITORY = "MAVEN_REPOSITORY"
|
||||
private val SYSTEM_MACROS: MutableSet<String> = THashSet()
|
||||
private val SYSTEM_MACROS: MutableSet<String> = HashSet()
|
||||
|
||||
@JvmStatic
|
||||
fun getInstanceEx() = getInstance() as PathMacrosImpl
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
// 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.application.options;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.PathMacroMap;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.util.text.StringUtilRt;
|
||||
import com.intellij.openapi.util.text.Strings;
|
||||
import com.intellij.util.ArrayUtilRt;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.hash.LinkedHashMap;
|
||||
import gnu.trove.TObjectIntHashMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.serialization.PathMacroUtil;
|
||||
|
||||
@@ -26,14 +27,13 @@ public final class ReplacePathToMacroMap extends PathMacroMap {
|
||||
private List<String> myPathsIndex = null;
|
||||
private final Map<String, String> myMacroMap = new LinkedHashMap<>();
|
||||
|
||||
@NonNls
|
||||
public static final String[] PROTOCOLS;
|
||||
|
||||
static {
|
||||
List<String> protocols = new ArrayList<>();
|
||||
protocols.add("file");
|
||||
protocols.add("jar");
|
||||
if (Extensions.getRootArea().hasExtensionPoint(PathMacroExpandableProtocolBean.EP_NAME)) {
|
||||
if (ApplicationManager.getApplication().getExtensionArea().hasExtensionPoint(PathMacroExpandableProtocolBean.EP_NAME)) {
|
||||
PathMacroExpandableProtocolBean.EP_NAME.forEachExtensionSafe(bean -> protocols.add(bean.protocol));
|
||||
}
|
||||
PROTOCOLS = ArrayUtilRt.toStringArray(protocols);
|
||||
@@ -48,11 +48,11 @@ public final class ReplacePathToMacroMap extends PathMacroMap {
|
||||
}
|
||||
|
||||
public void addMacroReplacement(String path, String macroName) {
|
||||
addReplacement(FileUtil.toSystemIndependentName(path), "$" + macroName + "$", true);
|
||||
addReplacement(FileUtilRt.toSystemIndependentName(path), "$" + macroName + "$", true);
|
||||
}
|
||||
|
||||
public void addReplacement(String path, String macroExpr, boolean overwrite) {
|
||||
path = StringUtil.trimEnd(path, "/");
|
||||
path = Strings.trimEnd(path, "/");
|
||||
putIfAbsent(path, macroExpr, overwrite);
|
||||
for (String protocol : PROTOCOLS) {
|
||||
putIfAbsent(protocol + ":" + path, protocol + ":" + macroExpr, overwrite);
|
||||
@@ -67,17 +67,15 @@ public final class ReplacePathToMacroMap extends PathMacroMap {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String substitute(@NotNull String text, boolean caseSensitive) {
|
||||
public @NotNull String substitute(@NotNull String text, boolean caseSensitive) {
|
||||
for (final String path : getPathIndex()) {
|
||||
text = replacePathMacro(text, path, caseSensitive);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String replacePathMacro(@NotNull String text, @NotNull final String path, boolean caseSensitive) {
|
||||
private @NotNull String replacePathMacro(@NotNull String text, final @NotNull String path, boolean caseSensitive) {
|
||||
if (text.length() < path.length() || path.isEmpty()) {
|
||||
return text;
|
||||
}
|
||||
@@ -106,26 +104,25 @@ public final class ReplacePathToMacroMap extends PathMacroMap {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String substituteRecursively(@NotNull String text, final boolean caseSensitive) {
|
||||
public @NotNull CharSequence substituteRecursively(@NotNull String text, boolean caseSensitive) {
|
||||
CharSequence result = text;
|
||||
for (final String path : getPathIndex()) {
|
||||
for (String path : getPathIndex()) {
|
||||
result = replacePathMacroRecursively(result, path, caseSensitive);
|
||||
}
|
||||
return result.toString();
|
||||
return result;
|
||||
}
|
||||
|
||||
private CharSequence replacePathMacroRecursively(@NotNull final CharSequence text, @NotNull final String path, boolean caseSensitive) {
|
||||
private CharSequence replacePathMacroRecursively(@NotNull CharSequence text, @NotNull String path, boolean caseSensitive) {
|
||||
if ((text.length() < path.length()) || path.isEmpty()) {
|
||||
return text;
|
||||
}
|
||||
|
||||
final StringBuilder newText = new StringBuilder();
|
||||
final boolean isWindowsRoot = path.endsWith(":/");
|
||||
StringBuilder newText = new StringBuilder();
|
||||
boolean isWindowsRoot = path.endsWith(":/");
|
||||
int i = 0;
|
||||
while (i < text.length()) {
|
||||
int occurrenceOfPath = caseSensitive ? StringUtil.indexOf(text, path, i) : StringUtil.indexOfIgnoreCase(text, path, i);
|
||||
int occurrenceOfPath = caseSensitive ? Strings.indexOf(text, path, i) : Strings.indexOfIgnoreCase(text, path, i);
|
||||
if (occurrenceOfPath >= 0) {
|
||||
int endOfOccurrence = occurrenceOfPath + path.length();
|
||||
if (!isWindowsRoot &&
|
||||
@@ -133,7 +130,7 @@ public final class ReplacePathToMacroMap extends PathMacroMap {
|
||||
text.charAt(endOfOccurrence) != '/' &&
|
||||
text.charAt(endOfOccurrence) != '\"' &&
|
||||
text.charAt(endOfOccurrence) != ' ' &&
|
||||
!StringUtil.startsWith(text, endOfOccurrence, "!/")) {
|
||||
!Strings.startsWith(text, endOfOccurrence, "!/")) {
|
||||
newText.append(text, i, endOfOccurrence);
|
||||
i = endOfOccurrence;
|
||||
continue;
|
||||
@@ -186,26 +183,26 @@ public final class ReplacePathToMacroMap extends PathMacroMap {
|
||||
return key.length();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<String> getPathIndex() {
|
||||
if (myPathsIndex == null || myPathsIndex.size() != myMacroMap.size()) {
|
||||
List<Map.Entry<String, String>> entries = new ArrayList<>(myMacroMap.entrySet());
|
||||
|
||||
final TObjectIntHashMap<String> weights = new TObjectIntHashMap<>(entries.size());
|
||||
for (Map.Entry<String, String> entry : entries) {
|
||||
weights.put(entry.getKey(), getIndex(entry.getValue()) * 512 + stripPrefix(entry.getKey()));
|
||||
}
|
||||
|
||||
entries.sort((o1, o2) -> weights.get(o2.getKey()) - weights.get(o1.getKey()));
|
||||
myPathsIndex = ContainerUtil.map2List(entries, entry -> entry.getKey());
|
||||
private @NotNull List<String> getPathIndex() {
|
||||
if (myPathsIndex != null && myPathsIndex.size() == myMacroMap.size()) {
|
||||
return myPathsIndex;
|
||||
}
|
||||
|
||||
List<Map.Entry<String, String>> entries = new ArrayList<>(myMacroMap.entrySet());
|
||||
|
||||
Object2IntMap<String> weights = new Object2IntOpenHashMap<>(entries.size());
|
||||
for (Map.Entry<String, String> entry : entries) {
|
||||
weights.put(entry.getKey(), getIndex(entry.getValue()) * 512 + stripPrefix(entry.getKey()));
|
||||
}
|
||||
|
||||
entries.sort((o1, o2) -> weights.getInt(o2.getKey()) - weights.getInt(o1.getKey()));
|
||||
myPathsIndex = ContainerUtil.map2List(entries, entry -> entry.getKey());
|
||||
return myPathsIndex;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) return true;
|
||||
if (!(obj instanceof ReplacePathToMacroMap)) return false;
|
||||
|
||||
return myMacroMap.equals(((ReplacePathToMacroMap)obj).myMacroMap);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// 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.configurationStore
|
||||
|
||||
import com.intellij.util.containers.ObjectIntHashMap
|
||||
import com.intellij.util.io.IOUtil
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap
|
||||
import org.jdom.*
|
||||
import java.io.DataOutputStream
|
||||
|
||||
@@ -17,7 +17,11 @@ private fun String.isEmptySafe(): Boolean {
|
||||
}
|
||||
|
||||
internal class BinaryXmlWriter(private val out: DataOutputStream) {
|
||||
private val strings = ObjectIntHashMap<String>()
|
||||
private val strings = Object2IntOpenHashMap<String>()
|
||||
|
||||
init {
|
||||
strings.defaultReturnValue(-1)
|
||||
}
|
||||
|
||||
fun write(element: Element) {
|
||||
writeElement(element)
|
||||
@@ -29,13 +33,13 @@ internal class BinaryXmlWriter(private val out: DataOutputStream) {
|
||||
return
|
||||
}
|
||||
|
||||
val reference = strings.get(string)
|
||||
val reference = strings.getInt(string)
|
||||
if (reference != -1) {
|
||||
writeUInt29(reference shl 1)
|
||||
return
|
||||
}
|
||||
|
||||
strings.put(string, strings.size())
|
||||
strings.put(string, strings.size)
|
||||
// don't write actual length, IOUtil does it
|
||||
out.write((1 shl 1) or 1)
|
||||
IOUtil.writeUTF(out, string)
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.intellij.openapi.application.PathMacros;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.io.OSAgnosticPathUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.util.text.Strings;
|
||||
import com.intellij.util.PathUtilRt;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
@@ -49,7 +49,7 @@ public class PathMacroManager implements PathMacroSubstitutor {
|
||||
|
||||
protected static void addFileHierarchyReplacements(@NotNull ExpandMacroToPathMap result, @NotNull String macroName, @SystemIndependent @Nullable String path) {
|
||||
if (path != null) {
|
||||
doAddFileHierarchyReplacements(result, StringUtil.trimEnd(path, "/"), '$' + macroName + '$');
|
||||
doAddFileHierarchyReplacements(result, Strings.trimEnd(path, "/"), '$' + macroName + '$');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,9 +65,9 @@ public class PathMacroManager implements PathMacroSubstitutor {
|
||||
if (path == null) return;
|
||||
|
||||
String macro = '$' + macroName + '$';
|
||||
path = StringUtil.trimEnd(FileUtil.toSystemIndependentName(path), "/");
|
||||
path = Strings.trimEnd(FileUtil.toSystemIndependentName(path), "/");
|
||||
boolean overwrite = true;
|
||||
while (StringUtil.isNotEmpty(path) && path.contains("/") && !"/".equals(path)) {
|
||||
while (Strings.isNotEmpty(path) && path.contains("/") && !"/".equals(path)) {
|
||||
result.addReplacement(path, macro, overwrite);
|
||||
if (path.equals(stopAt)) break;
|
||||
macro += "/..";
|
||||
@@ -111,7 +111,7 @@ public class PathMacroManager implements PathMacroSubstitutor {
|
||||
@Override
|
||||
@Contract("null -> null; !null -> !null")
|
||||
public String expandPath(@Nullable String text) {
|
||||
if (StringUtil.isEmpty(text)) {
|
||||
if (Strings.isEmpty(text)) {
|
||||
return text;
|
||||
}
|
||||
return getExpandMacroMap().substitute(text, SystemInfo.isFileSystemCaseSensitive);
|
||||
@@ -120,10 +120,10 @@ public class PathMacroManager implements PathMacroSubstitutor {
|
||||
@Contract("null, _ -> null; !null, _ -> !null")
|
||||
@Override
|
||||
public String collapsePath(@Nullable String text, boolean recursively) {
|
||||
if (StringUtil.isEmpty(text)) {
|
||||
if (Strings.isEmpty(text)) {
|
||||
return text;
|
||||
}
|
||||
return getReplacePathMap().substitute(text, SystemInfo.isFileSystemCaseSensitive, recursively);
|
||||
return getReplacePathMap().substitute(text, SystemInfo.isFileSystemCaseSensitive, recursively).toString();
|
||||
}
|
||||
|
||||
@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.components.impl.stores;
|
||||
|
||||
import com.intellij.application.options.PathMacrosCollector;
|
||||
@@ -9,16 +9,16 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.text.StringUtilRt;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DirectoryStorageUtil {
|
||||
public final class DirectoryStorageUtil {
|
||||
private static final Logger LOG = Logger.getInstance(DirectoryStorageUtil.class);
|
||||
|
||||
@NotNull
|
||||
@@ -27,7 +27,7 @@ public class DirectoryStorageUtil {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
Map<String, Element> fileToState = new THashMap<>();
|
||||
Map<String, Element> fileToState = new HashMap<>();
|
||||
for (VirtualFile file : dir.getChildren()) {
|
||||
// ignore system files like .DS_Store on Mac
|
||||
if (!StringUtilRt.endsWithIgnoreCase(file.getNameSequence(), FileStorageCoreUtil.DEFAULT_EXT)) {
|
||||
|
||||
@@ -40,9 +40,11 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.Interner;
|
||||
import com.intellij.util.graph.*;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.THashSet;
|
||||
import gnu.trove.TObjectHashingStrategy;
|
||||
import it.unimi.dsi.fastutil.Hash;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrays;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -75,7 +77,7 @@ public abstract class ModuleManagerImpl extends ModuleManagerEx implements Dispo
|
||||
protected volatile ModuleModelImpl myModuleModel = new ModuleModelImpl(this);
|
||||
|
||||
private Set<ModulePath> myModulePathsToLoad;
|
||||
private final Set<ModulePath> myFailedModulePaths = new THashSet<>();
|
||||
private final Set<ModulePath> myFailedModulePaths = new HashSet<>();
|
||||
private final Map<String, UnloadedModuleDescriptionImpl> myUnloadedModules = new LinkedHashMap<>();
|
||||
private boolean myModulesLoaded;
|
||||
|
||||
@@ -127,17 +129,8 @@ public abstract class ModuleManagerImpl extends ModuleManagerEx implements Dispo
|
||||
|
||||
private static final class ModuleGroupInterner {
|
||||
private final Interner<String> groups = Interner.createStringInterner();
|
||||
private final Map<String[], String[]> paths = new THashMap<>(new TObjectHashingStrategy<String[]>() {
|
||||
@Override
|
||||
public int computeHashCode(String[] object) {
|
||||
return Arrays.hashCode(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(String[] o1, String[] o2) {
|
||||
return Arrays.equals(o1, o2);
|
||||
}
|
||||
});
|
||||
@SuppressWarnings("unchecked")
|
||||
private final Map<String[], String[]> paths = new Object2ObjectOpenCustomHashMap<>((Hash.Strategy<? super String[]>)ObjectArrays.HASH_STRATEGY);
|
||||
|
||||
private void setModuleGroupPath(@NotNull ModifiableModuleModel model, @NotNull Module module, String @Nullable [] group) {
|
||||
String[] cached = group == null ? null : paths.get(group);
|
||||
@@ -203,7 +196,7 @@ public abstract class ModuleManagerImpl extends ModuleManagerEx implements Dispo
|
||||
Module[] existingModules = model.getModules();
|
||||
ModuleGroupInterner groupInterner = new ModuleGroupInterner();
|
||||
|
||||
Map<String, ModulePath> modulePathMap = new THashMap<>(myModulePathsToLoad.size());
|
||||
Map<String, ModulePath> modulePathMap = new Object2ObjectOpenHashMap<>(myModulePathsToLoad.size());
|
||||
for (ModulePath modulePath : myModulePathsToLoad) {
|
||||
modulePathMap.put(modulePath.getPath(), modulePath);
|
||||
}
|
||||
@@ -276,7 +269,7 @@ public abstract class ModuleManagerImpl extends ModuleManagerEx implements Dispo
|
||||
ExecutorService service = isParallel ? AppExecutorUtil.createBoundedApplicationPoolExecutor("ModuleManager Loader", Math.min(2, Runtime.getRuntime().availableProcessors()))
|
||||
: ConcurrencyUtil.newSameThreadExecutorService();
|
||||
List<Pair<Future<Module>, ModulePath>> tasks = new ArrayList<>();
|
||||
Set<String> paths = new THashSet<>();
|
||||
Set<String> paths = new ObjectOpenHashSet<>(myModulePathsToLoad.size());
|
||||
for (ModulePath modulePath : myModulePathsToLoad) {
|
||||
if (progressIndicator.isCanceled()) {
|
||||
break;
|
||||
@@ -344,7 +337,7 @@ public abstract class ModuleManagerImpl extends ModuleManagerEx implements Dispo
|
||||
|
||||
Application app = ApplicationManager.getApplication();
|
||||
if (app.isInternal() || app.isEAP() || ApplicationInfo.getInstance().getBuild().isSnapshot()) {
|
||||
Map<String, Module> track = new THashMap<>();
|
||||
Map<String, Module> track = new Object2ObjectOpenHashMap<>();
|
||||
for (Module module : moduleModel.getModules()) {
|
||||
for (String url : ModuleRootManager.getInstance(module).getContentRootUrls()) {
|
||||
Module oldModule = track.put(url, module);
|
||||
@@ -700,7 +693,7 @@ public abstract class ModuleManagerImpl extends ModuleManagerEx implements Dispo
|
||||
@NotNull
|
||||
protected abstract ModuleEx createAndLoadModule(@NotNull String filePath) throws IOException;
|
||||
|
||||
static class ModuleModelImpl implements ModifiableModuleModel {
|
||||
final static class ModuleModelImpl implements ModifiableModuleModel {
|
||||
final Map<String, Module> myModules = Collections.synchronizedMap(new LinkedHashMap<>());
|
||||
private volatile Module[] myModulesCache;
|
||||
|
||||
@@ -723,7 +716,7 @@ public abstract class ModuleManagerImpl extends ModuleManagerEx implements Dispo
|
||||
myModules.putAll(that.myModules);
|
||||
final Map<Module, String[]> groupPath = that.myModuleGroupPath;
|
||||
if (groupPath != null){
|
||||
myModuleGroupPath = new THashMap<>();
|
||||
myModuleGroupPath = new Object2ObjectOpenHashMap<>();
|
||||
myModuleGroupPath.putAll(that.myModuleGroupPath);
|
||||
}
|
||||
myIsWritable = true;
|
||||
@@ -997,7 +990,7 @@ public abstract class ModuleManagerImpl extends ModuleManagerEx implements Dispo
|
||||
@Override
|
||||
public void setModuleGroupPath(@NotNull Module module, String @Nullable("null means remove") [] groupPath) {
|
||||
if (myModuleGroupPath == null) {
|
||||
myModuleGroupPath = new THashMap<>();
|
||||
myModuleGroupPath = new Object2ObjectOpenHashMap<>();
|
||||
}
|
||||
if (groupPath == null) {
|
||||
myModuleGroupPath.remove(module);
|
||||
@@ -1028,10 +1021,10 @@ public abstract class ModuleManagerImpl extends ModuleManagerEx implements Dispo
|
||||
removedModules = Collections.emptyList();
|
||||
}
|
||||
else {
|
||||
addedModules = new THashSet<>(newModules);
|
||||
addedModules = new ObjectOpenHashSet<>(newModules);
|
||||
addedModules.removeAll(oldModules);
|
||||
|
||||
removedModules = new THashSet<>(oldModules);
|
||||
removedModules = new ObjectOpenHashSet<>(oldModules);
|
||||
removedModules.removeAll(newModules);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.util.Function
|
||||
import com.intellij.util.containers.MultiMap
|
||||
import gnu.trove.THashMap
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock
|
||||
import kotlin.concurrent.read
|
||||
import kotlin.concurrent.write
|
||||
@@ -25,7 +25,7 @@ class ModulePointerManagerImpl(private val project: Project) : ModulePointerMana
|
||||
private val unresolved = MultiMap<String, ModulePointerImpl>()
|
||||
private val pointers = MultiMap<Module, ModulePointerImpl>()
|
||||
private val lock = ReentrantReadWriteLock()
|
||||
private val oldToNewName = THashMap<String, String>()
|
||||
private val oldToNewName = Object2ObjectOpenHashMap<String, String>()
|
||||
|
||||
init {
|
||||
project.messageBus.connect().subscribe(ProjectTopics.MODULES, object : ModuleListener {
|
||||
@@ -42,7 +42,12 @@ class ModulePointerManagerImpl(private val project: Project) : ModulePointerMana
|
||||
moduleAppears(module)
|
||||
}
|
||||
val renamedOldToNew = modules.associateBy({ oldNameProvider.`fun`(it) }, { it.name })
|
||||
oldToNewName.transformValues { newName -> renamedOldToNew[newName] ?: newName }
|
||||
for (entry in oldToNewName.object2ObjectEntrySet().fastIterator()) {
|
||||
val newValue = renamedOldToNew.get(entry.value)
|
||||
if (newValue != null) {
|
||||
entry.setValue(newValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.openapi.roots.impl;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
@@ -21,14 +7,14 @@ import com.intellij.openapi.roots.OrderEntry;
|
||||
import com.intellij.openapi.roots.OrderEnumerationHandler;
|
||||
import com.intellij.util.PairProcessor;
|
||||
import com.intellij.util.Processor;
|
||||
import gnu.trove.THashSet;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ModuleOrderEnumerator extends OrderEnumeratorBase {
|
||||
public final class ModuleOrderEnumerator extends OrderEnumeratorBase {
|
||||
private final ModuleRootModel myRootModel;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@@ -44,7 +30,7 @@ public class ModuleOrderEnumerator extends OrderEnumeratorBase {
|
||||
|
||||
@Override
|
||||
protected void forEach(@NotNull PairProcessor<? super OrderEntry, ? super List<? extends OrderEnumerationHandler>> processor) {
|
||||
processEntries(myRootModel, myRecursively ? new THashSet<>() : null, true, getCustomHandlers(myRootModel.getModule()), processor);
|
||||
processEntries(myRootModel, myRecursively ? new ObjectOpenHashSet<>() : null, true, getCustomHandlers(myRootModel.getModule()), processor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
// 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;
|
||||
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -36,7 +36,7 @@ import java.util.stream.Collectors;
|
||||
* </li>
|
||||
* </ul>
|
||||
*/
|
||||
public class GroupBasedTestClassFilter extends TestClassesFilter {
|
||||
public final class GroupBasedTestClassFilter extends TestClassesFilter {
|
||||
/**
|
||||
* Holds reserved test group name that serves as a negation of matching result.
|
||||
*
|
||||
@@ -49,7 +49,7 @@ public class GroupBasedTestClassFilter extends TestClassesFilter {
|
||||
|
||||
public GroupBasedTestClassFilter(MultiMap<String, String> filters, List<String> testGroupNames) {
|
||||
//empty group means all patterns from each defined group should be excluded
|
||||
myTestGroupNames = new THashSet<>(testGroupNames);
|
||||
myTestGroupNames = new HashSet<>(testGroupNames);
|
||||
|
||||
for (String groupName : filters.keySet()) {
|
||||
Collection<String> groupFilters = filters.get(groupName);
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
package com.intellij.keymap;
|
||||
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class KeymapsTestCase extends KeymapsTestCaseBase {
|
||||
// @formatter:off
|
||||
@NonNls @SuppressWarnings({"HardCodedStringLiteral"})
|
||||
protected static final Map<String, String[][]> DEFAULT_DUPLICATES = new THashMap<String, String[][]>(){{
|
||||
@NonNls @SuppressWarnings("HardCodedStringLiteral")
|
||||
protected static final Map<String, String[][]> DEFAULT_DUPLICATES = new HashMap<String, String[][]>(){{
|
||||
put("$default", new String[][] {
|
||||
{ "ADD", "ExpandTreeNode", "Graph.ZoomIn"},
|
||||
{ "BACK_SPACE", "EditorBackSpace", "Images.Thumbnails.UpFolder"},
|
||||
|
||||
@@ -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.testFramework.assertions
|
||||
|
||||
import com.intellij.testFramework.UsefulTestCase
|
||||
@@ -6,12 +6,11 @@ import com.intellij.util.io.delete
|
||||
import com.intellij.util.io.directoryStreamIfExists
|
||||
import com.intellij.util.io.isFile
|
||||
import com.intellij.util.io.isHidden
|
||||
import gnu.trove.THashSet
|
||||
import org.junit.rules.ExternalResource
|
||||
import java.nio.file.Path
|
||||
|
||||
class CleanupSnapshots(private val dir: Path) : ExternalResource() {
|
||||
private val usedPaths: MutableSet<Path> = THashSet<Path>()
|
||||
private val usedPaths = HashSet<Path>()
|
||||
|
||||
private val listener = object : SnapshotFileUsageListener {
|
||||
override fun beforeMatch(file: Path) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.intellij.codeInspection.ex.InspectionProfileImpl;
|
||||
import com.intellij.codeInspection.ex.InspectionToolWrapper;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -15,7 +15,7 @@ import java.util.Set;
|
||||
|
||||
public final class MockInspectionProfile extends InspectionProfileImpl {
|
||||
private List<InspectionToolWrapper<?, ?>> myInspectionTools = Collections.emptyList();
|
||||
private final Set<InspectionToolWrapper<?, ?>> myDisabledTools = new THashSet<>();
|
||||
private final Set<InspectionToolWrapper<?, ?>> myDisabledTools = new ObjectOpenHashSet<>();
|
||||
|
||||
public MockInspectionProfile() {
|
||||
super("a");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2017 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.mock;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -7,14 +7,14 @@ import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileSystem;
|
||||
import com.intellij.testFramework.LightVirtualFile;
|
||||
import gnu.trove.THashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
public class MockVirtualFileSystem extends DeprecatedVirtualFileSystem {
|
||||
public final class MockVirtualFileSystem extends DeprecatedVirtualFileSystem {
|
||||
private static final String PROTOCOL = "mock";
|
||||
|
||||
private final MyVirtualFile myRoot = new MyVirtualFile("", null) {
|
||||
@@ -83,7 +83,7 @@ public class MockVirtualFileSystem extends DeprecatedVirtualFileSystem {
|
||||
MyVirtualFile file = findChild(name);
|
||||
if (file == null) {
|
||||
if (myChildren == null) {
|
||||
myChildren = new THashMap<>();
|
||||
myChildren = new Object2ObjectOpenHashMap<>();
|
||||
}
|
||||
file = new MyVirtualFile(name, this);
|
||||
myChildren.put(name, file);
|
||||
|
||||
@@ -1,25 +1,15 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-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.testFramework;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.util.ThrowableRunnable;
|
||||
import com.sun.management.OperatingSystemMXBean;
|
||||
import gnu.trove.TLongLongHashMap;
|
||||
import gnu.trove.TObjectLongHashMap;
|
||||
import it.unimi.dsi.fastutil.longs.Long2LongMap;
|
||||
import it.unimi.dsi.fastutil.longs.Long2LongMaps;
|
||||
import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2LongMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2LongMaps;
|
||||
import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap;
|
||||
import one.util.streamex.StreamEx;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -28,7 +18,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class CpuUsageData {
|
||||
public final class CpuUsageData {
|
||||
private static final ThreadMXBean ourThreadMXBean = ManagementFactory.getThreadMXBean();
|
||||
private static final List<GarbageCollectorMXBean> ourGcBeans = ManagementFactory.getGarbageCollectorMXBeans();
|
||||
private static final CompilationMXBean ourCompilationMXBean = ManagementFactory.getCompilationMXBean();
|
||||
@@ -43,8 +33,8 @@ public class CpuUsageData {
|
||||
private final List<Pair<Long, String>> myThreadTimes = new ArrayList<>();
|
||||
|
||||
private CpuUsageData(long durationMs,
|
||||
TObjectLongHashMap<GarbageCollectorMXBean> gcTimes,
|
||||
TLongLongHashMap threadTimes,
|
||||
Object2LongMap<GarbageCollectorMXBean> gcTimes,
|
||||
Long2LongMap threadTimes,
|
||||
long compilationTime,
|
||||
long processTime,
|
||||
FreeMemorySnapshot memStart,
|
||||
@@ -54,14 +44,12 @@ public class CpuUsageData {
|
||||
myMemEnd = memEnd;
|
||||
myCompilationTime = compilationTime;
|
||||
myProcessTime = processTime;
|
||||
gcTimes.forEachEntry((bean, gcTime) -> {
|
||||
myGcTimes.add(Pair.create(gcTime, bean.getName()));
|
||||
return true;
|
||||
Object2LongMaps.fastForEach(gcTimes, entry -> {
|
||||
myGcTimes.add(Pair.create(entry.getLongValue(), entry.getKey().getName()));
|
||||
});
|
||||
threadTimes.forEachEntry((id, time) -> {
|
||||
ThreadInfo info = ourThreadMXBean.getThreadInfo(id);
|
||||
myThreadTimes.add(Pair.create(toMillis(time), info == null ? "<unknown>" : info.getThreadName()));
|
||||
return true;
|
||||
Long2LongMaps.fastForEach(threadTimes, entry -> {
|
||||
ThreadInfo info = ourThreadMXBean.getThreadInfo(entry.getLongKey());
|
||||
myThreadTimes.add(Pair.create(toMillis(entry.getLongValue()), info == null ? "<unknown>" : info.getThreadName()));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -109,12 +97,12 @@ public class CpuUsageData {
|
||||
public static <E extends Throwable> CpuUsageData measureCpuUsage(ThrowableRunnable<E> runnable) throws E {
|
||||
FreeMemorySnapshot memStart = new FreeMemorySnapshot();
|
||||
|
||||
TObjectLongHashMap<GarbageCollectorMXBean> gcTimes = new TObjectLongHashMap<>();
|
||||
Object2LongOpenHashMap<GarbageCollectorMXBean> gcTimes = new Object2LongOpenHashMap<>();
|
||||
for (GarbageCollectorMXBean bean : ourGcBeans) {
|
||||
gcTimes.put(bean, bean.getCollectionTime());
|
||||
}
|
||||
|
||||
TLongLongHashMap threadTimes = new TLongLongHashMap();
|
||||
Long2LongOpenHashMap threadTimes = new Long2LongOpenHashMap();
|
||||
for (long id : ourThreadMXBean.getAllThreadIds()) {
|
||||
threadTimes.put(id, ourThreadMXBean.getThreadUserTime(id));
|
||||
}
|
||||
@@ -136,7 +124,7 @@ public class CpuUsageData {
|
||||
}
|
||||
|
||||
for (GarbageCollectorMXBean bean : ourGcBeans) {
|
||||
gcTimes.put(bean, bean.getCollectionTime() - gcTimes.get(bean));
|
||||
gcTimes.put(bean, bean.getCollectionTime() - gcTimes.getLong(bean));
|
||||
}
|
||||
|
||||
return new CpuUsageData(duration, gcTimes, threadTimes, compTime, processTime, memStart, memEnd);
|
||||
|
||||
@@ -495,7 +495,7 @@ public abstract class HeavyPlatformTestCase extends UsefulTestCase implements Da
|
||||
},
|
||||
() -> {
|
||||
if (myProject != null) {
|
||||
closeAndDisposeProjectAndCheckThatNoOpenProjects(myProject);
|
||||
PlatformTestUtil.closeAndDisposeProjectAndCheckThatNoOpenProjects(myProject);
|
||||
myProject = null;
|
||||
}
|
||||
},
|
||||
@@ -553,11 +553,6 @@ public abstract class HeavyPlatformTestCase extends UsefulTestCase implements Da
|
||||
);
|
||||
}
|
||||
|
||||
public static void closeAndDisposeProjectAndCheckThatNoOpenProjects(@NotNull Project projectToClose) {
|
||||
ProjectManagerEx.getInstanceEx().forceCloseProject(projectToClose);
|
||||
ProjectRule.checkThatNoOpenProjects();
|
||||
}
|
||||
|
||||
protected void resetAllFields() {
|
||||
resetClassFields(getClass());
|
||||
}
|
||||
|
||||
@@ -1120,4 +1120,9 @@ public final class PlatformTestUtil {
|
||||
Disposer.register(parentDisposable, () -> forceCloseProjectWithoutSaving(project));
|
||||
return project;
|
||||
}
|
||||
|
||||
public static void closeAndDisposeProjectAndCheckThatNoOpenProjects(@NotNull Project projectToClose) {
|
||||
ProjectManagerEx.getInstanceEx().forceCloseProject(projectToClose);
|
||||
ProjectRule.checkThatNoOpenProjects();
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
public class PathUtilRt {
|
||||
public final class PathUtilRt {
|
||||
@NotNull
|
||||
public static String getFileName(@Nullable String path) {
|
||||
if (StringUtilRt.isEmpty(path)) {
|
||||
|
||||
@@ -540,7 +540,7 @@ public class ContainerUtil {
|
||||
|
||||
@Contract(pure = true)
|
||||
public static @NotNull <T> Set<T> union(@NotNull Collection<? extends T> set, @NotNull Collection<? extends T> set2) {
|
||||
Set<T> result = new THashSet<>(set.size() + set2.size());
|
||||
Set<T> result = new HashSet<>(set.size() + set2.size());
|
||||
result.addAll(set);
|
||||
result.addAll(set2);
|
||||
return result;
|
||||
@@ -623,8 +623,8 @@ public class ContainerUtil {
|
||||
};
|
||||
}
|
||||
|
||||
public static class ImmutableMapBuilder<K, V> {
|
||||
private final Map<K, V> myMap = new THashMap<>();
|
||||
public static final class ImmutableMapBuilder<K, V> {
|
||||
private final Map<K, V> myMap = new HashMap<>();
|
||||
|
||||
public @NotNull ImmutableMapBuilder<K, V> put(K key, V value) {
|
||||
myMap.put(key, value);
|
||||
|
||||
@@ -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.idea.devkit.navigation.structure;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
@@ -28,7 +28,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class PluginDescriptorStructureUtil {
|
||||
public final class PluginDescriptorStructureUtil {
|
||||
public static final Icon DEFAULT_ICON = AllIcons.Nodes.Tag;
|
||||
|
||||
private static final Set<String> KNOWN_TOP_LEVEL_NODE_NAMES =
|
||||
@@ -57,9 +57,7 @@ public class PluginDescriptorStructureUtil {
|
||||
private PluginDescriptorStructureUtil() {
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public static String getTagDisplayText(@Nullable XmlTag tag) {
|
||||
public static @NotNull String getTagDisplayText(@Nullable XmlTag tag) {
|
||||
DomElement element = getDomElement(tag);
|
||||
if (element == null) {
|
||||
return safeGetTagDisplayText(tag);
|
||||
@@ -86,17 +84,15 @@ public class PluginDescriptorStructureUtil {
|
||||
else if (element instanceof Separator) {
|
||||
return "----------";
|
||||
}
|
||||
|
||||
|
||||
return toDisplayName(element.getXmlElementName()); // default
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String safeGetTagDisplayText(@Nullable XmlTag tag) {
|
||||
public static @NotNull String safeGetTagDisplayText(@Nullable XmlTag tag) {
|
||||
return tag != null ? toDisplayName(tag.getLocalName()) : DevKitBundle.message("error.plugin.xml.tag.invalid");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Icon getTagIcon(@Nullable XmlTag tag) {
|
||||
public static @Nullable Icon getTagIcon(@Nullable XmlTag tag) {
|
||||
DomElement element = getDomElement(tag);
|
||||
if (element == null) {
|
||||
return tag != null ? DEFAULT_ICON : null;
|
||||
@@ -105,8 +101,7 @@ public class PluginDescriptorStructureUtil {
|
||||
return ObjectUtils.notNull(ElementPresentationManager.getIcon(element), DEFAULT_ICON);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getTagLocationString(@Nullable XmlTag tag) {
|
||||
public static @Nullable String getTagLocationString(@Nullable XmlTag tag) {
|
||||
DomElement element = getDomElement(tag);
|
||||
if (element == null) {
|
||||
return null;
|
||||
@@ -122,7 +117,7 @@ public class PluginDescriptorStructureUtil {
|
||||
return getExtensionsLocation((Extensions)element);
|
||||
}
|
||||
if (element instanceof ExtensionPoints) {
|
||||
return getExtensionPointsLocation((ExtensionPoints)element);
|
||||
return getExtensionPointsLocation(element);
|
||||
}
|
||||
if (element instanceof ExtensionPoint) {
|
||||
return getExtensionPointLocation((ExtensionPoint)element);
|
||||
@@ -149,7 +144,7 @@ public class PluginDescriptorStructureUtil {
|
||||
return getVendorLocation((Vendor)element);
|
||||
}
|
||||
if (element.getParent() instanceof IdeaPlugin && element instanceof GenericDomValue) {
|
||||
return getTopLevelNodeLocation((GenericDomValue)element);
|
||||
return getTopLevelNodeLocation((GenericDomValue<?>)element);
|
||||
}
|
||||
|
||||
return guessTagLocation(element);
|
||||
@@ -159,8 +154,7 @@ public class PluginDescriptorStructureUtil {
|
||||
return pluginModule.getValue().getStringValue();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getIdeaVersionLocation(IdeaVersion element) {
|
||||
private static @Nullable String getIdeaVersionLocation(IdeaVersion element) {
|
||||
String since = element.getSinceBuild().getStringValue();
|
||||
if (StringUtil.isNotEmpty(since)) {
|
||||
String until = element.getUntilBuild().getStringValue();
|
||||
@@ -169,13 +163,11 @@ public class PluginDescriptorStructureUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getExtensionsLocation(Extensions element) {
|
||||
private static @Nullable String getExtensionsLocation(Extensions element) {
|
||||
return element.getDefaultExtensionNs().getStringValue();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getExtensionPointsLocation(ExtensionPoints element) {
|
||||
private static @Nullable String getExtensionPointsLocation(DomElement element) {
|
||||
DomElement parent = element.getParent();
|
||||
if (parent instanceof IdeaPlugin) {
|
||||
return ((IdeaPlugin)parent).getPluginId();
|
||||
@@ -183,8 +175,7 @@ public class PluginDescriptorStructureUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getExtensionPointLocation(ExtensionPoint element) {
|
||||
private static @Nullable String getExtensionPointLocation(ExtensionPoint element) {
|
||||
String epInterface = element.getInterface().getStringValue();
|
||||
if (StringUtil.isNotEmpty(epInterface)) {
|
||||
return toShortName(epInterface);
|
||||
@@ -196,29 +187,24 @@ public class PluginDescriptorStructureUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getWithLocation(With element) {
|
||||
private static @Nullable String getWithLocation(With element) {
|
||||
return element.getAttribute().getStringValue();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getComponentLocation(Component element) {
|
||||
private static @Nullable String getComponentLocation(Component element) {
|
||||
String implementationClassText = element.getImplementationClass().getRawText();
|
||||
return toShortName(implementationClassText);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getGroupLocation(Group element) {
|
||||
private static @Nullable String getGroupLocation(ActionOrGroup element) {
|
||||
return element.getId().getStringValue();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getAddToGroupLocation(AddToGroup element) {
|
||||
private static @Nullable String getAddToGroupLocation(AddToGroup element) {
|
||||
return element.getGroupId().getStringValue();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getExtensionLocation(Extension element) {
|
||||
private static @Nullable String getExtensionLocation(Extension element) {
|
||||
DomElement parent = element.getParent();
|
||||
if (parent instanceof Extensions) {
|
||||
String extensionsNamespace = ((Extensions)parent).getDefaultExtensionNs().getStringValue();
|
||||
@@ -252,18 +238,15 @@ public class PluginDescriptorStructureUtil {
|
||||
return guessTagLocation(element);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getKeyboardShortcutLocation(KeyboardShortcut element) {
|
||||
private static @Nullable String getKeyboardShortcutLocation(KeyboardShortcut element) {
|
||||
return element.getFirstKeystroke().getStringValue();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getVendorLocation(Vendor element) {
|
||||
private static @NotNull String getVendorLocation(Vendor element) {
|
||||
return element.getValue();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getTopLevelNodeLocation(GenericDomValue element) {
|
||||
private static @Nullable String getTopLevelNodeLocation(GenericDomValue<?> element) {
|
||||
if (element instanceof Dependency) {
|
||||
Dependency dependency = (Dependency)element;
|
||||
String result = dependency.getRawText();
|
||||
@@ -282,8 +265,7 @@ public class PluginDescriptorStructureUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String guessTagLocation(DomElement element) {
|
||||
private static @Nullable String guessTagLocation(DomElement element) {
|
||||
String location = toShortName(firstNotNullAttribute(
|
||||
element, "instance", "class", "implementation", "implementationClass", "interface", "interfaceClass"));
|
||||
|
||||
@@ -300,9 +282,9 @@ public class PluginDescriptorStructureUtil {
|
||||
}
|
||||
|
||||
DomGenericInfo genericInfo = element.getGenericInfo();
|
||||
List<? extends DomAttributeChildDescription> attrDescriptions = genericInfo.getAttributeChildrenDescriptions();
|
||||
List<? extends DomAttributeChildDescription<?>> attrDescriptions = genericInfo.getAttributeChildrenDescriptions();
|
||||
String possibleOnlyAttrValue = null;
|
||||
for (DomAttributeChildDescription description : attrDescriptions) {
|
||||
for (DomAttributeChildDescription<?> description : attrDescriptions) {
|
||||
String value = description.getDomAttributeValue(element).getStringValue();
|
||||
if (StringUtil.isEmpty(value)) {
|
||||
continue;
|
||||
@@ -328,7 +310,7 @@ public class PluginDescriptorStructureUtil {
|
||||
// check if tag doesn't have attributes and subtags and use it's text content as a location in such cases
|
||||
if (attrDescriptions.isEmpty() && genericInfo.getFixedChildrenDescriptions().isEmpty()) {
|
||||
if (element instanceof GenericDomValue) {
|
||||
return ((GenericDomValue)element).getRawText();
|
||||
return ((GenericDomValue<?>)element).getRawText();
|
||||
}
|
||||
/*if (element instanceof ExtensionDomExtender.SimpleTagValue) {
|
||||
return ((ExtensionDomExtender.SimpleTagValue)element).getStringValue();
|
||||
@@ -339,8 +321,7 @@ public class PluginDescriptorStructureUtil {
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
private static String toShortName(@Nullable String fqName) {
|
||||
private static @Nullable String toShortName(@Nullable String fqName) {
|
||||
if (fqName == null || fqName.contains(" ")) {
|
||||
return null;
|
||||
}
|
||||
@@ -351,8 +332,7 @@ public class PluginDescriptorStructureUtil {
|
||||
return fqName;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String toDisplayName(@NotNull String tagName) {
|
||||
private static @NotNull String toDisplayName(@NotNull String tagName) {
|
||||
String result = tagName.replaceAll("-", " ").replaceAll("\\.", "|");
|
||||
|
||||
String[] words = NameUtil.nameToWords(result);
|
||||
@@ -370,11 +350,10 @@ public class PluginDescriptorStructureUtil {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String firstNotNullAttribute(DomElement element, String... attributes) {
|
||||
private static @Nullable String firstNotNullAttribute(DomElement element, String... attributes) {
|
||||
DomGenericInfo genericInfo = element.getGenericInfo();
|
||||
for (String attribute : attributes) {
|
||||
DomAttributeChildDescription description = genericInfo.getAttributeChildDescription(attribute);
|
||||
DomAttributeChildDescription<?> description = genericInfo.getAttributeChildDescription(attribute);
|
||||
if (description == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -388,8 +367,7 @@ public class PluginDescriptorStructureUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getSubTagText(DomElement element, @SuppressWarnings("SameParameterValue") String subTagName) {
|
||||
private static @Nullable String getSubTagText(DomElement element, @SuppressWarnings("SameParameterValue") String subTagName) {
|
||||
DomFixedChildDescription subTagDescription = element.getGenericInfo().getFixedChildDescription(subTagName);
|
||||
if (subTagDescription == null) {
|
||||
return null;
|
||||
@@ -402,8 +380,7 @@ public class PluginDescriptorStructureUtil {
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static DomElement getDomElement(@Nullable XmlTag tag) {
|
||||
private static @Nullable DomElement getDomElement(@Nullable XmlTag tag) {
|
||||
if (tag == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,25 +1,20 @@
|
||||
// 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.idea.svn.history;
|
||||
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.xml.bind.annotation.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class LogEntry {
|
||||
import java.util.*;
|
||||
|
||||
public final class LogEntry {
|
||||
public static final LogEntry EMPTY = new LogEntry.Builder().setRevision(-1).setHasChildren(false).build();
|
||||
|
||||
private final long myRevision;
|
||||
@Nullable private final Date myDate;
|
||||
private final @Nullable Date myDate;
|
||||
private final String myMessage;
|
||||
private final String myAuthor;
|
||||
@NotNull private final Map<String, LogEntryPath> myChangedPaths;
|
||||
private final @NotNull Map<String, LogEntryPath> myChangedPaths;
|
||||
private final boolean myHasChildren;
|
||||
|
||||
public LogEntry(@NotNull LogEntry.Builder builder) {
|
||||
@@ -31,19 +26,15 @@ public class LogEntry {
|
||||
myHasChildren = builder.hasChildren();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Map<String, LogEntryPath> toImmutable(@NotNull List<LogEntryPath.Builder> paths) {
|
||||
ContainerUtil.ImmutableMapBuilder<String, LogEntryPath> builder = ContainerUtil.immutableMapBuilder();
|
||||
|
||||
private static @NotNull Map<String, LogEntryPath> toImmutable(@NotNull List<LogEntryPath.Builder> paths) {
|
||||
Map<String, LogEntryPath> result = new HashMap<>();
|
||||
for (LogEntryPath.Builder path : paths) {
|
||||
builder.put(path.getPath(), path.build());
|
||||
result.put(path.getPath(), path.build());
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
return Collections.unmodifiableMap(result);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Map<String, LogEntryPath> getChangedPaths() {
|
||||
public @NotNull Map<String, LogEntryPath> getChangedPaths() {
|
||||
return myChangedPaths;
|
||||
}
|
||||
|
||||
@@ -51,8 +42,7 @@ public class LogEntry {
|
||||
return myAuthor;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Date getDate() {
|
||||
public @Nullable Date getDate() {
|
||||
return myDate;
|
||||
}
|
||||
|
||||
@@ -92,8 +82,7 @@ public class LogEntry {
|
||||
@XmlElement(name = "logentry")
|
||||
private final List<LogEntry.Builder> childEntries = new ArrayList<>();
|
||||
|
||||
@NotNull
|
||||
public List<LogEntry.Builder> getChildEntries() {
|
||||
public @NotNull List<LogEntry.Builder> getChildEntries() {
|
||||
return childEntries;
|
||||
}
|
||||
|
||||
@@ -101,32 +90,27 @@ public class LogEntry {
|
||||
return !childEntries.isEmpty();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Builder setRevision(long revision) {
|
||||
public @NotNull Builder setRevision(long revision) {
|
||||
this.revision = revision;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Builder setAuthor(String author) {
|
||||
public @NotNull Builder setAuthor(String author) {
|
||||
this.author = author;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Builder setDate(Date date) {
|
||||
public @NotNull Builder setDate(Date date) {
|
||||
this.date = date;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Builder setMessage(String message) {
|
||||
public @NotNull Builder setMessage(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Builder setHasChildren(boolean hasChildren) {
|
||||
public @NotNull Builder setHasChildren(boolean hasChildren) {
|
||||
// probably LogEntry interface will be changed and child entries will be specified explicitly later, but for now just use such "fake"
|
||||
// implementation for setting "hasChildren" value
|
||||
childEntries.clear();
|
||||
@@ -136,14 +120,12 @@ public class LogEntry {
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Builder addPath(@NotNull LogEntryPath.Builder path) {
|
||||
public @NotNull Builder addPath(@NotNull LogEntryPath.Builder path) {
|
||||
changedPaths.add(path);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public LogEntry build() {
|
||||
public @NotNull LogEntry build() {
|
||||
return new LogEntry(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.util.xml.impl;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
@@ -48,46 +34,38 @@ import java.util.Map;
|
||||
*/
|
||||
public class DomFileElementImpl<T extends DomElement> implements DomFileElement<T>, SemElement {
|
||||
private static final DomGenericInfo EMPTY_DOM_GENERIC_INFO = new DomGenericInfo() {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public GenericDomValue getNameDomElement(DomElement element) {
|
||||
public @Nullable GenericDomValue getNameDomElement(DomElement element) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<? extends CustomDomChildrenDescription> getCustomNameChildrenDescription() {
|
||||
public @NotNull List<? extends CustomDomChildrenDescription> getCustomNameChildrenDescription() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getElementName(DomElement element) {
|
||||
public @Nullable String getElementName(DomElement element) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<DomChildrenDescription> getChildrenDescriptions() {
|
||||
public @NotNull List<DomChildrenDescription> getChildrenDescriptions() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<DomFixedChildDescription> getFixedChildrenDescriptions() {
|
||||
public @NotNull List<DomFixedChildDescription> getFixedChildrenDescriptions() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<DomCollectionChildDescription> getCollectionChildrenDescriptions() {
|
||||
public @NotNull List<DomCollectionChildDescription> getCollectionChildrenDescriptions() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<DomAttributeChildDescription> getAttributeChildrenDescriptions() {
|
||||
public @NotNull List<DomAttributeChildDescription<?>> getAttributeChildrenDescriptions() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -97,26 +75,22 @@ public class DomFileElementImpl<T extends DomElement> implements DomFileElement<
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public DomFixedChildDescription getFixedChildDescription(String tagName) {
|
||||
public @Nullable DomFixedChildDescription getFixedChildDescription(String tagName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public DomFixedChildDescription getFixedChildDescription(@NonNls String tagName, @NonNls String namespace) {
|
||||
public @Nullable DomFixedChildDescription getFixedChildDescription(@NonNls String tagName, @NonNls String namespace) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public DomCollectionChildDescription getCollectionChildDescription(String tagName) {
|
||||
public @Nullable DomCollectionChildDescription getCollectionChildDescription(String tagName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public DomCollectionChildDescription getCollectionChildDescription(@NonNls String tagName, @NonNls String namespace) {
|
||||
public @Nullable DomCollectionChildDescription getCollectionChildDescription(@NonNls String tagName, @NonNls String namespace) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -126,8 +100,7 @@ public class DomFileElementImpl<T extends DomElement> implements DomFileElement<
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public DomAttributeChildDescription getAttributeChildDescription(@NonNls String attributeName, @NonNls String namespace) {
|
||||
public @Nullable DomAttributeChildDescription getAttributeChildDescription(@NonNls String attributeName, @NonNls String namespace) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -152,20 +125,17 @@ public class DomFileElementImpl<T extends DomElement> implements DomFileElement<
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public final XmlFile getFile() {
|
||||
public final @NotNull XmlFile getFile() {
|
||||
return myFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public XmlFile getOriginalFile() {
|
||||
public @NotNull XmlFile getOriginalFile() {
|
||||
return (XmlFile)myFile.getOriginalFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public XmlTag getRootTag() {
|
||||
public @Nullable XmlTag getRootTag() {
|
||||
if (!myFile.isValid()) {
|
||||
return null;
|
||||
}
|
||||
@@ -206,8 +176,7 @@ public class DomFileElementImpl<T extends DomElement> implements DomFileElement<
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public final DomManagerImpl getManager() {
|
||||
public final @NotNull DomManagerImpl getManager() {
|
||||
return myManager;
|
||||
}
|
||||
|
||||
@@ -217,8 +186,7 @@ public class DomFileElementImpl<T extends DomElement> implements DomFileElement<
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public AbstractDomChildrenDescription getChildDescription() {
|
||||
public @NotNull AbstractDomChildrenDescription getChildDescription() {
|
||||
throw new UnsupportedOperationException("Method getChildDescription is not yet implemented in " + getClass().getName());
|
||||
}
|
||||
|
||||
@@ -228,17 +196,18 @@ public class DomFileElementImpl<T extends DomElement> implements DomFileElement<
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ElementPresentation getPresentation() {
|
||||
public @NotNull ElementPresentation getPresentation() {
|
||||
return new ElementPresentation() {
|
||||
|
||||
@Override
|
||||
public @NonNls String getElementName() {
|
||||
@NonNls
|
||||
public String getElementName() {
|
||||
return "<ROOT>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNls String getTypeName() {
|
||||
@NonNls
|
||||
public String getTypeName() {
|
||||
return "<ROOT>";
|
||||
}
|
||||
|
||||
@@ -255,8 +224,7 @@ public class DomFileElementImpl<T extends DomElement> implements DomFileElement<
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T extends DomElement> T getParentOfType(Class<T> requiredClass, boolean strict) {
|
||||
public @Nullable <T extends DomElement> T getParentOfType(Class<T> requiredClass, boolean strict) {
|
||||
return DomFileElement.class.isAssignableFrom(requiredClass) && !strict ? (T)this : null;
|
||||
}
|
||||
|
||||
@@ -284,21 +252,18 @@ public class DomFileElementImpl<T extends DomElement> implements DomFileElement<
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getXmlElementNamespace() {
|
||||
public @NotNull String getXmlElementNamespace() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
@NonNls
|
||||
public String getXmlElementNamespaceKey() {
|
||||
public @Nullable String getXmlElementNamespaceKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public final T getRootElement() {
|
||||
public final @NotNull T getRootElement() {
|
||||
if (!isValid()) {
|
||||
PsiUtilCore.ensureValid(myFile);
|
||||
throw new AssertionError(this + " is not equal to " + myManager.getFileElement(myFile));
|
||||
@@ -307,23 +272,21 @@ public class DomFileElementImpl<T extends DomElement> implements DomFileElement<
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Class<T> getRootElementClass() {
|
||||
public @NotNull Class<T> getRootElementClass() {
|
||||
return myRootElementClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public DomFileDescription<T> getFileDescription() {
|
||||
public @NotNull DomFileDescription<T> getFileDescription() {
|
||||
return myFileDescription;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected final DomRootInvocationHandler getRootHandler() {
|
||||
protected final @NotNull DomRootInvocationHandler getRootHandler() {
|
||||
return myRootHandler;
|
||||
}
|
||||
|
||||
public @NonNls String toString() {
|
||||
@NonNls
|
||||
public String toString() {
|
||||
return "File " + myFile.toString();
|
||||
}
|
||||
|
||||
@@ -337,14 +300,12 @@ public class DomFileElementImpl<T extends DomElement> implements DomFileElement<
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public <T extends DomElement> DomFileElementImpl<T> getRoot() {
|
||||
public @NotNull <T extends DomElement> DomFileElementImpl<T> getRoot() {
|
||||
return (DomFileElementImpl<T>)this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public DomElement getParent() {
|
||||
public @Nullable DomElement getParent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -377,8 +338,7 @@ public class DomFileElementImpl<T extends DomElement> implements DomFileElement<
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String checkValidity() {
|
||||
public @Nullable String checkValidity() {
|
||||
if (!myFile.isValid()) {
|
||||
return "Invalid file";
|
||||
}
|
||||
@@ -390,14 +350,12 @@ public class DomFileElementImpl<T extends DomElement> implements DomFileElement<
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public final DomGenericInfo getGenericInfo() {
|
||||
public final @NotNull DomGenericInfo getGenericInfo() {
|
||||
return EMPTY_DOM_GENERIC_INFO;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getXmlElementName() {
|
||||
public @NotNull String getXmlElementName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.util.xml.reflect;
|
||||
|
||||
import com.intellij.util.xml.DomElement;
|
||||
@@ -41,7 +27,7 @@ public interface DomGenericInfo {
|
||||
List<? extends DomCollectionChildDescription> getCollectionChildrenDescriptions();
|
||||
|
||||
@NotNull
|
||||
List<? extends DomAttributeChildDescription> getAttributeChildrenDescriptions();
|
||||
List<? extends DomAttributeChildDescription<?>> getAttributeChildrenDescriptions();
|
||||
|
||||
@Nullable DomFixedChildDescription getFixedChildDescription(@NonNls String tagName);
|
||||
|
||||
@@ -52,10 +38,10 @@ public interface DomGenericInfo {
|
||||
@Nullable DomCollectionChildDescription getCollectionChildDescription(@NonNls String tagName, @NonNls String namespaceKey);
|
||||
|
||||
@Nullable
|
||||
DomAttributeChildDescription getAttributeChildDescription(@NonNls String attributeName);
|
||||
DomAttributeChildDescription<?> getAttributeChildDescription(@NonNls String attributeName);
|
||||
|
||||
@Nullable
|
||||
DomAttributeChildDescription getAttributeChildDescription(@NonNls String attributeName, @NonNls String namespaceKey);
|
||||
DomAttributeChildDescription<?> getAttributeChildDescription(@NonNls String attributeName, @NonNls String namespaceKey);
|
||||
|
||||
/**
|
||||
* @return true, if there's no children in the element, only tag value accessors
|
||||
@@ -63,7 +49,7 @@ public interface DomGenericInfo {
|
||||
boolean isTagValueElement();
|
||||
|
||||
@Nullable
|
||||
GenericDomValue getNameDomElement(DomElement element);
|
||||
GenericDomValue<?> getNameDomElement(DomElement element);
|
||||
|
||||
@NotNull
|
||||
List<? extends CustomDomChildrenDescription> getCustomNameChildrenDescription();
|
||||
|
||||
Reference in New Issue
Block a user