mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
reduce the usage of kotlinx-immutable-collections
GitOrigin-RevId: f5a8cc34ffff305e2793ea2a109156dcde4014b0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
edb02741c0
commit
72efd72cf0
@@ -49,6 +49,7 @@
|
||||
<orderEntry type="library" name="opentelemetry" level="project" />
|
||||
<orderEntry type="library" name="opentelemetry-semconv" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.diagnostic.telemetry" />
|
||||
<orderEntry type="library" name="kotlinx-collections-immutable" level="project" />
|
||||
</component>
|
||||
<component name="copyright">
|
||||
<Base>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.packaging.impl.elements;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -103,39 +103,33 @@ public final class PackagingElementFactoryImpl extends PackagingElementFactory {
|
||||
return toPersistentList(PackagingElementType.EP_NAME.getExtensionList()).addAll(STANDARD_TYPES);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PackagingElement<?> createArtifactElement(@NotNull Artifact artifact, @NotNull Project project) {
|
||||
public @NotNull PackagingElement<?> createArtifactElement(@NotNull Artifact artifact, @NotNull Project project) {
|
||||
return new ArtifactPackagingElement(project, ArtifactPointerManager.getInstance(project).createPointer(artifact));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PackagingElement<?> createArtifactElement(@NotNull String artifactName, @NotNull Project project) {
|
||||
public @NotNull PackagingElement<?> createArtifactElement(@NotNull String artifactName, @NotNull Project project) {
|
||||
return new ArtifactPackagingElement(project, ArtifactPointerManager.getInstance(project).createPointer(artifactName));
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public DirectoryPackagingElement createDirectory(@NotNull @NonNls String directoryName) {
|
||||
public @NotNull DirectoryPackagingElement createDirectory(@NotNull @NonNls String directoryName) {
|
||||
return new DirectoryPackagingElement(directoryName);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ArtifactRootElement<?> createArtifactRootElement() {
|
||||
public @NotNull ArtifactRootElement<?> createArtifactRootElement() {
|
||||
return new ArtifactRootElementImpl();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public CompositePackagingElement<?> getOrCreateDirectory(@NotNull CompositePackagingElement<?> parent, @NotNull String relativePath) {
|
||||
public @NotNull CompositePackagingElement<?> getOrCreateDirectory(@NotNull CompositePackagingElement<?> parent, @NotNull String relativePath) {
|
||||
return getOrCreateDirectoryOrArchive(parent, relativePath, true, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CompositePackagingElement<?> getOrCreateArchive(@NotNull CompositePackagingElement<?> parent, @NotNull String relativePath) {
|
||||
public @NotNull CompositePackagingElement<?> getOrCreateArchive(@NotNull CompositePackagingElement<?> parent, @NotNull String relativePath) {
|
||||
return getOrCreateDirectoryOrArchive(parent, relativePath, false, false);
|
||||
}
|
||||
|
||||
@@ -161,8 +155,7 @@ public final class PackagingElementFactoryImpl extends PackagingElementFactory {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private CompositePackagingElement<?> getOrCreateDirectoryOrArchive(@NotNull CompositePackagingElement<?> root,
|
||||
private @NotNull CompositePackagingElement<?> getOrCreateDirectoryOrArchive(@NotNull CompositePackagingElement<?> root,
|
||||
@NotNull @NonNls String path,
|
||||
final boolean directory, boolean addAsFirstChild) {
|
||||
path = StringUtil.trimStart(StringUtil.trimEnd(path, "/"), "/");
|
||||
@@ -185,43 +178,37 @@ public final class PackagingElementFactoryImpl extends PackagingElementFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PackagingElement<?> createModuleOutput(@NotNull String moduleName, @NotNull Project project) {
|
||||
public @NotNull PackagingElement<?> createModuleOutput(@NotNull String moduleName, @NotNull Project project) {
|
||||
final ModulePointer pointer = ModulePointerManager.getInstance(project).create(moduleName);
|
||||
return new ProductionModuleOutputPackagingElement(project, pointer);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PackagingElement<?> createModuleOutput(@NotNull Module module) {
|
||||
public @NotNull PackagingElement<?> createModuleOutput(@NotNull Module module) {
|
||||
final ModulePointer modulePointer = ModulePointerManager.getInstance(module.getProject()).create(module);
|
||||
return new ProductionModuleOutputPackagingElement(module.getProject(), modulePointer);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PackagingElement<?> createModuleSource(@NotNull Module module) {
|
||||
public @NotNull PackagingElement<?> createModuleSource(@NotNull Module module) {
|
||||
final ModulePointer modulePointer = ModulePointerManager.getInstance(module.getProject()).create(module);
|
||||
return new ProductionModuleSourcePackagingElement(module.getProject(), modulePointer);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PackagingElement<?> createTestModuleOutput(@NotNull String moduleName, @NotNull Project project) {
|
||||
public @NotNull PackagingElement<?> createTestModuleOutput(@NotNull String moduleName, @NotNull Project project) {
|
||||
ModulePointer pointer = ModulePointerManager.getInstance(project).create(moduleName);
|
||||
return new TestModuleOutputPackagingElement(project, pointer);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PackagingElement<?> createTestModuleOutput(@NotNull Module module) {
|
||||
public @NotNull PackagingElement<?> createTestModuleOutput(@NotNull Module module) {
|
||||
ModulePointer pointer = ModulePointerManager.getInstance(module.getProject()).create(module);
|
||||
return new TestModuleOutputPackagingElement(module.getProject(), pointer);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<PackagingElement<?>> createLibraryElements(@NotNull Library library) {
|
||||
public @NotNull List<PackagingElement<?>> createLibraryElements(@NotNull Library library) {
|
||||
final LibraryTable table = library.getTable();
|
||||
final String libraryName = library.getName();
|
||||
if (table != null) {
|
||||
@@ -241,9 +228,8 @@ public final class PackagingElementFactoryImpl extends PackagingElementFactory {
|
||||
return elements;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<? extends PackagingElement<?>> createLibraryElements(@NotNull LibraryEntity libraryEntity, String moduleName) {
|
||||
public @NotNull List<? extends PackagingElement<?>> createLibraryElements(@NotNull LibraryEntity libraryEntity, String moduleName) {
|
||||
final String libraryType = libraryEntity.getTableId().getLevel();
|
||||
final String libraryName = libraryEntity.getName();
|
||||
if (PROJECT_LEVEL.equals(libraryType) || APPLICATION_LEVEL.equals(libraryType)) {
|
||||
@@ -253,26 +239,22 @@ public final class PackagingElementFactoryImpl extends PackagingElementFactory {
|
||||
return Collections.singletonList(createLibraryFiles(libraryName, libraryType, moduleName));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PackagingElement<?> createArtifactElement(@NotNull ArtifactPointer artifactPointer, @NotNull Project project) {
|
||||
public @NotNull PackagingElement<?> createArtifactElement(@NotNull ArtifactPointer artifactPointer, @NotNull Project project) {
|
||||
return new ArtifactPackagingElement(project, artifactPointer);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PackagingElement<?> createLibraryFiles(@NotNull String libraryName, @NotNull String level, String moduleName) {
|
||||
public @NotNull PackagingElement<?> createLibraryFiles(@NotNull String libraryName, @NotNull String level, String moduleName) {
|
||||
return new LibraryPackagingElement(level, libraryName, moduleName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public CompositePackagingElement<?> createArchive(@NotNull @NonNls String archiveFileName) {
|
||||
public @NotNull CompositePackagingElement<?> createArchive(@NotNull @NonNls String archiveFileName) {
|
||||
return new ArchivePackagingElement(archiveFileName);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static PackagingElement<?> findArchiveOrDirectoryByName(@NotNull CompositePackagingElement<?> parent, @NotNull String name) {
|
||||
private static @Nullable PackagingElement<?> findArchiveOrDirectoryByName(@NotNull CompositePackagingElement<?> parent, @NotNull String name) {
|
||||
for (PackagingElement<?> element : parent.getChildren()) {
|
||||
if (element instanceof ArchivePackagingElement && ((ArchivePackagingElement)element).getArchiveFileName().equals(name) ||
|
||||
element instanceof DirectoryPackagingElement && ((DirectoryPackagingElement)element).getDirectoryName().equals(name)) {
|
||||
@@ -282,8 +264,7 @@ public final class PackagingElementFactoryImpl extends PackagingElementFactory {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String suggestFileName(@NotNull CompositePackagingElement<?> parent, @NonNls @NotNull String prefix, @NonNls @NotNull String suffix) {
|
||||
public static @NotNull String suggestFileName(@NotNull CompositePackagingElement<?> parent, @NonNls @NotNull String prefix, @NonNls @NotNull String suffix) {
|
||||
String name = prefix + suffix;
|
||||
int i = 2;
|
||||
while (findArchiveOrDirectoryByName(parent, name) != null) {
|
||||
@@ -292,37 +273,32 @@ public final class PackagingElementFactoryImpl extends PackagingElementFactory {
|
||||
return name;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PackagingElement<?> createDirectoryCopyWithParentDirectories(@NotNull String filePath, @NotNull String relativeOutputPath) {
|
||||
public @NotNull PackagingElement<?> createDirectoryCopyWithParentDirectories(@NotNull String filePath, @NotNull String relativeOutputPath) {
|
||||
return createParentDirectories(relativeOutputPath, new DirectoryCopyPackagingElement(filePath));
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PackagingElement<?> createExtractedDirectoryWithParentDirectories(@NotNull String jarPath, @NotNull String pathInJar,
|
||||
public @NotNull PackagingElement<?> createExtractedDirectoryWithParentDirectories(@NotNull String jarPath, @NotNull String pathInJar,
|
||||
@NotNull String relativeOutputPath) {
|
||||
return createParentDirectories(relativeOutputPath, new ExtractedDirectoryPackagingElement(jarPath, pathInJar));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PackagingElement<?> createExtractedDirectory(@NotNull VirtualFile jarEntry) {
|
||||
public @NotNull PackagingElement<?> createExtractedDirectory(@NotNull VirtualFile jarEntry) {
|
||||
LOG.assertTrue(jarEntry.getFileSystem() instanceof JarFileSystem, "Expected file from JAR but file from " + jarEntry.getFileSystem() + " found");
|
||||
final String fullPath = jarEntry.getPath();
|
||||
final int jarEnd = fullPath.indexOf(JarFileSystem.JAR_SEPARATOR);
|
||||
return new ExtractedDirectoryPackagingElement(fullPath.substring(0, jarEnd), fullPath.substring(jarEnd + 1));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PackagingElement<?> createFileCopyWithParentDirectories(@NotNull String filePath, @NotNull String relativeOutputPath) {
|
||||
public @NotNull PackagingElement<?> createFileCopyWithParentDirectories(@NotNull String filePath, @NotNull String relativeOutputPath) {
|
||||
return createFileCopyWithParentDirectories(filePath, relativeOutputPath, null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PackagingElement<?> createFileCopyWithParentDirectories(@NotNull String filePath,
|
||||
public @NotNull PackagingElement<?> createFileCopyWithParentDirectories(@NotNull String filePath,
|
||||
@NotNull String relativeOutputPath,
|
||||
@Nullable String outputFileName) {
|
||||
return createParentDirectories(relativeOutputPath, createFileCopy(filePath, outputFileName));
|
||||
@@ -333,15 +309,13 @@ public final class PackagingElementFactoryImpl extends PackagingElementFactory {
|
||||
return new FileCopyPackagingElement(filePath, outputFileName);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PackagingElement<?> createParentDirectories(@NotNull String relativeOutputPath, @NotNull PackagingElement<?> element) {
|
||||
public @NotNull PackagingElement<?> createParentDirectories(@NotNull String relativeOutputPath, @NotNull PackagingElement<?> element) {
|
||||
return createParentDirectories(relativeOutputPath, Collections.singletonList(element)).get(0);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<? extends PackagingElement<?>> createParentDirectories(@NotNull String relativeOutputPath, @NotNull List<? extends PackagingElement<?>> elements) {
|
||||
public @NotNull List<? extends PackagingElement<?>> createParentDirectories(@NotNull String relativeOutputPath, @NotNull List<? extends PackagingElement<?>> elements) {
|
||||
relativeOutputPath = StringUtil.trimStart(relativeOutputPath, "/");
|
||||
if (relativeOutputPath.length() == 0) {
|
||||
return elements;
|
||||
@@ -375,15 +349,13 @@ public final class PackagingElementFactoryImpl extends PackagingElementFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<? extends ArtifactRootElement<?>> chooseAndCreate(@NotNull ArtifactEditorContext context, @NotNull Artifact artifact,
|
||||
public @NotNull List<? extends ArtifactRootElement<?>> chooseAndCreate(@NotNull ArtifactEditorContext context, @NotNull Artifact artifact,
|
||||
@NotNull CompositePackagingElement<?> parent) {
|
||||
throw new UnsupportedOperationException("'create' not implemented in " + getClass().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ArtifactRootElement<?> createEmpty(@NotNull Project project) {
|
||||
public @NotNull ArtifactRootElement<?> createEmpty(@NotNull Project project) {
|
||||
return new ArtifactRootElementImpl();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.psi;
|
||||
|
||||
import com.intellij.lang.LanguageExtension;
|
||||
|
||||
/**
|
||||
* @author Serega.Vasiliev
|
||||
*/
|
||||
public final class LanguageAnnotationSupport extends LanguageExtension<PsiAnnotationSupport> {
|
||||
public static final LanguageAnnotationSupport INSTANCE = new LanguageAnnotationSupport();
|
||||
|
||||
|
||||
@@ -29,5 +29,6 @@
|
||||
<orderEntry type="library" name="jackson-dataformat-yaml" level="project" />
|
||||
<orderEntry type="library" name="caffeine" level="project" />
|
||||
<orderEntry type="library" name="StreamEx" level="project" />
|
||||
<orderEntry type="library" name="kotlinx-collections-immutable" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -52,7 +52,6 @@ internal fun <T> mergeSets(first: Set<T>?, second: Set<T>?): Set<T>? {
|
||||
return merged.toImmutableSet()
|
||||
}
|
||||
|
||||
|
||||
internal fun MergedJsonSchemaObjectView.booleanOr(memberReference: JsonSchemaObject.() -> Boolean): Boolean {
|
||||
val first = base.memberReference()
|
||||
if (first) return true
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<orderEntry type="library" name="kotlinx-coroutines-core" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.xmlDom" />
|
||||
<orderEntry type="module" module-name="intellij.platform.diagnostic" />
|
||||
<orderEntry type="library" exported="" name="kotlinx-collections-immutable" level="project" />
|
||||
<orderEntry type="library" name="kotlinx-collections-immutable" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.coroutines" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.lang;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
@@ -17,8 +17,8 @@ import java.util.*;
|
||||
import static kotlinx.collections.immutable.ExtensionsKt.persistentListOf;
|
||||
|
||||
public class LanguageExtension<T> extends KeyedExtensionCollector<T, Language> {
|
||||
private final T myDefaultImplementation;
|
||||
private final /* non static!!! */ Key<T> myCacheKey;
|
||||
private final T defaultImplementation;
|
||||
private final /* non static!!! */ Key<T> cacheKey;
|
||||
private final /* non static!!! */ Key<PersistentList<T>> allCacheKey;
|
||||
|
||||
public LanguageExtension(final @NotNull ExtensionPointName<? extends KeyedLazyInstance<T>> epName) {
|
||||
@@ -35,8 +35,8 @@ public class LanguageExtension<T> extends KeyedExtensionCollector<T, Language> {
|
||||
|
||||
public LanguageExtension(@NonNls String epName, @Nullable T defaultImplementation) {
|
||||
super(epName);
|
||||
myDefaultImplementation = defaultImplementation;
|
||||
myCacheKey = Key.create("EXTENSIONS_IN_LANGUAGE_" + epName);
|
||||
this.defaultImplementation = defaultImplementation;
|
||||
cacheKey = Key.create("EXTENSIONS_IN_LANGUAGE_" + epName);
|
||||
allCacheKey = Key.create("ALL_EXTENSIONS_IN_LANGUAGE_" + epName);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class LanguageExtension<T> extends KeyedExtensionCollector<T, Language> {
|
||||
}
|
||||
|
||||
private void clearCacheForLanguage(@NotNull Language language) {
|
||||
language.putUserData(myCacheKey, null);
|
||||
language.putUserData(cacheKey, null);
|
||||
language.putUserData(allCacheKey, null);
|
||||
super.invalidateCacheForExtension(language.getID());
|
||||
}
|
||||
@@ -87,12 +87,12 @@ public class LanguageExtension<T> extends KeyedExtensionCollector<T, Language> {
|
||||
}
|
||||
|
||||
public T forLanguage(@NotNull Language l) {
|
||||
T cached = l.getUserData(myCacheKey);
|
||||
T cached = l.getUserData(cacheKey);
|
||||
if (cached != null) return cached;
|
||||
|
||||
T result = findForLanguage(l);
|
||||
if (result == null) return null;
|
||||
result = l.putUserDataIfAbsent(myCacheKey, result);
|
||||
result = l.putUserDataIfAbsent(cacheKey, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public class LanguageExtension<T> extends KeyedExtensionCollector<T, Language> {
|
||||
return extensions.get(0);
|
||||
}
|
||||
}
|
||||
return myDefaultImplementation;
|
||||
return defaultImplementation;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,7 +163,7 @@ public class LanguageExtension<T> extends KeyedExtensionCollector<T, Language> {
|
||||
}
|
||||
|
||||
protected T getDefaultImplementation() {
|
||||
return myDefaultImplementation;
|
||||
return defaultImplementation;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.openapi.project
|
||||
|
||||
import com.intellij.openapi.Disposable
|
||||
@@ -15,13 +15,12 @@ import com.intellij.openapi.util.*
|
||||
import com.intellij.util.ThrowableRunnable
|
||||
import com.intellij.util.concurrency.annotations.RequiresBlockingContext
|
||||
import com.intellij.util.messages.Topic
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.annotations.ApiStatus.Experimental
|
||||
import org.jetbrains.annotations.ApiStatus.Obsolete
|
||||
import org.jetbrains.annotations.Contract
|
||||
import org.jetbrains.annotations.Unmodifiable
|
||||
import java.util.*
|
||||
import javax.swing.JComponent
|
||||
|
||||
/**
|
||||
@@ -195,7 +194,7 @@ abstract class DumbService {
|
||||
}
|
||||
return result
|
||||
}
|
||||
return if (collection is List<*>) collection as List<T> else collection.toImmutableList()
|
||||
return if (collection is List<*>) collection as List<T> else collection.toList()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -435,7 +434,7 @@ abstract class DumbService {
|
||||
val point = extensionPoint.point
|
||||
val size = point.size()
|
||||
if (size == 0) {
|
||||
return persistentListOf()
|
||||
return Collections.emptyList()
|
||||
}
|
||||
|
||||
if (!getInstance(project).isDumb) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.openapi.util;
|
||||
|
||||
import com.intellij.util.KeyedLazyInstance;
|
||||
@@ -23,7 +23,7 @@ public class ClassExtension<T> extends KeyedExtensionCollector<T, Class<?>> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final @NotNull PersistentList<T> buildExtensions(@NotNull String key, @NotNull Class classKey) {
|
||||
protected final @NotNull List<T> buildExtensions(@NotNull String key, @NotNull Class classKey) {
|
||||
Set<String> allSupers = new LinkedHashSet<>();
|
||||
collectSupers(classKey, allSupers);
|
||||
return buildExtensionsWithInheritance(allSupers);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.openapi.util;
|
||||
|
||||
import com.intellij.diagnostic.PluginException;
|
||||
@@ -18,6 +18,7 @@ import java.util.function.Predicate;
|
||||
import static com.intellij.util.containers.UtilKt.with;
|
||||
import static com.intellij.util.containers.UtilKt.without;
|
||||
import static kotlinx.collections.immutable.ExtensionsKt.persistentListOf;
|
||||
import static kotlinx.collections.immutable.ExtensionsKt.toPersistentList;
|
||||
|
||||
public class KeyedExtensionCollector<T, KeyT> implements ModificationTracker {
|
||||
private static final Logger LOG = Logger.getInstance(KeyedExtensionCollector.class);
|
||||
@@ -210,10 +211,10 @@ public class KeyedExtensionCollector<T, KeyT> implements ModificationTracker {
|
||||
}
|
||||
}
|
||||
|
||||
protected final @NotNull PersistentList<T> buildExtensions(@NotNull Set<String> keys) {
|
||||
protected final @NotNull List<T> buildExtensions(@NotNull Set<String> keys) {
|
||||
List<KeyedLazyInstance<T>> extensions = getExtensions();
|
||||
synchronized (lock) {
|
||||
PersistentList<T> explicit = buildExtensionsFromExplicitRegistration(keys::contains);
|
||||
List<T> explicit = buildExtensionsFromExplicitRegistration(keys::contains);
|
||||
List<T> result = buildExtensionsFromExtensionPoint(bean -> {
|
||||
String key;
|
||||
try {
|
||||
@@ -226,11 +227,11 @@ public class KeyedExtensionCollector<T, KeyT> implements ModificationTracker {
|
||||
|
||||
return keys.contains(key);
|
||||
}, extensions);
|
||||
return explicit.addAll(result);
|
||||
return toPersistentList(explicit).addAll(result);
|
||||
}
|
||||
}
|
||||
|
||||
protected final @NotNull PersistentList<T> buildExtensionsFromExplicitRegistration(@NotNull Predicate<? super String> isMyBean) {
|
||||
protected final @NotNull List<T> buildExtensionsFromExplicitRegistration(@NotNull Predicate<? super String> isMyBean) {
|
||||
PersistentList<T> result = persistentListOf();
|
||||
for (Map.Entry<String, PersistentList<T>> entry : explicitExtensions.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
<orderEntry type="library" name="automaton" level="project" />
|
||||
<orderEntry type="library" name="Guava" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.diff" />
|
||||
<orderEntry type="library" name="kotlinx-collections-immutable" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.diagnostic" />
|
||||
<orderEntry type="module" module-name="intellij.platform.diagnostic.telemetry" />
|
||||
<orderEntry type="library" name="opentelemetry" level="project" />
|
||||
|
||||
@@ -11,8 +11,6 @@ import com.intellij.openapi.extensions.ExtensionDescriptor
|
||||
import com.intellij.openapi.extensions.PluginId
|
||||
import com.intellij.openapi.extensions.impl.ExtensionPointImpl
|
||||
import com.intellij.util.Java11Shim
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.toPersistentList
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.annotations.Nls
|
||||
import org.jetbrains.annotations.NonNls
|
||||
@@ -77,7 +75,7 @@ class IdeaPluginDescriptorImpl(raw: RawPluginDescriptor,
|
||||
// https://youtrack.jetbrains.com/issue/IDEA-206274
|
||||
val list = raw.depends
|
||||
if (list.isNullOrEmpty()) {
|
||||
pluginDependencies = persistentListOf()
|
||||
pluginDependencies = Java11Shim.INSTANCE.listOf()
|
||||
}
|
||||
else {
|
||||
val iterator = list.iterator()
|
||||
@@ -93,7 +91,7 @@ class IdeaPluginDescriptorImpl(raw: RawPluginDescriptor,
|
||||
}
|
||||
}
|
||||
}
|
||||
pluginDependencies = list.toPersistentList()
|
||||
pluginDependencies = list
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.ide.plugins
|
||||
|
||||
import com.intellij.openapi.extensions.PluginId
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import com.intellij.util.Java11Shim
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import java.util.*
|
||||
|
||||
@@ -26,7 +26,7 @@ class ModuleDependenciesDescriptor(@JvmField val modules: List<ModuleReference>,
|
||||
@ApiStatus.Internal
|
||||
class PluginContentDescriptor(@JvmField val modules: List<ModuleItem>) {
|
||||
companion object {
|
||||
@JvmField val EMPTY: PluginContentDescriptor = PluginContentDescriptor(persistentListOf())
|
||||
@JvmField val EMPTY: PluginContentDescriptor = PluginContentDescriptor(Java11Shim.INSTANCE.listOf())
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
@file:Suppress("ReplacePutWithAssignment", "ReplaceGetOrSet", "ReplaceNegatedIsEmptyWithIsNotEmpty")
|
||||
|
||||
package com.intellij.ide.plugins
|
||||
|
||||
import com.intellij.util.graph.DFSTBuilder
|
||||
import com.intellij.util.graph.Graph
|
||||
import kotlinx.collections.immutable.toPersistentList
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import java.util.*
|
||||
|
||||
@@ -90,7 +89,7 @@ internal fun createModuleGraph(plugins: Collection<IdeaPluginDescriptorImpl>): M
|
||||
}
|
||||
|
||||
if (!result.isEmpty()) {
|
||||
directDependencies.put(module, result.toPersistentList())
|
||||
directDependencies.put(module, result.toList())
|
||||
result.clear()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,9 +27,6 @@ import com.intellij.util.Java11Shim
|
||||
import com.intellij.util.PlatformUtils
|
||||
import com.intellij.util.lang.UrlClassLoader
|
||||
import com.intellij.util.lang.ZipFilePool
|
||||
import kotlinx.collections.immutable.persistentSetOf
|
||||
import kotlinx.collections.immutable.toPersistentMap
|
||||
import kotlinx.collections.immutable.toPersistentSet
|
||||
import kotlinx.coroutines.CompletableDeferred
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Deferred
|
||||
@@ -112,7 +109,7 @@ object PluginManagerCore {
|
||||
* Bundled plugins that were updated.
|
||||
* When we update a bundled plugin, it becomes non-bundled, so it is more challenging for analytics to use that data.
|
||||
*/
|
||||
private var shadowedBundledPlugins: Set<PluginId> = persistentSetOf()
|
||||
private var shadowedBundledPlugins: Set<PluginId> = Collections.emptySet()
|
||||
|
||||
private var isRunningFromSources: Boolean? = null
|
||||
|
||||
@@ -292,7 +289,7 @@ object PluginManagerCore {
|
||||
future.cancel(CancellationException("invalidatePlugins"))
|
||||
}
|
||||
invalidate()
|
||||
shadowedBundledPlugins = persistentSetOf()
|
||||
shadowedBundledPlugins = Collections.emptySet()
|
||||
}
|
||||
|
||||
@ReviseWhenPortedToJDK(value = "10", description = "Collectors.toUnmodifiableList()")
|
||||
@@ -625,7 +622,7 @@ object PluginManagerCore {
|
||||
}
|
||||
|
||||
val actions = prepareActions(pluginNamesToDisable = pluginsToDisable.values, pluginNamesToEnable = pluginsToEnable.values)
|
||||
pluginLoadingErrors = pluginErrorsById.toPersistentMap()
|
||||
pluginLoadingErrors = pluginErrorsById
|
||||
|
||||
val errorList = preparePluginErrors(globalErrors)
|
||||
if (!errorList.isEmpty()) {
|
||||
@@ -829,7 +826,7 @@ object PluginManagerCore {
|
||||
parentActivity = tracerShim.getTraceActivity())
|
||||
pluginsToDisable = Java11Shim.INSTANCE.copyOf(initResult.pluginIdsToDisable)
|
||||
pluginsToEnable = Java11Shim.INSTANCE.copyOf(initResult.pluginIdsToEnable)
|
||||
shadowedBundledPlugins = loadingResult.shadowedBundledIds.toPersistentSet()
|
||||
shadowedBundledPlugins = loadingResult.shadowedBundledIds
|
||||
//activity.setDescription("plugin count: ${initResult.pluginSet.enabledPlugins.size}")
|
||||
nullablePluginSet = initResult.pluginSet
|
||||
initResult.pluginSet
|
||||
@@ -981,7 +978,7 @@ private fun message(key: @PropertyKey(resourceBundle = CoreBundle.BUNDLE) String
|
||||
Supplier { CoreBundle.message(key!!, *params) }
|
||||
|
||||
@Synchronized
|
||||
@ApiStatus.Internal
|
||||
@Internal
|
||||
fun tryReadPluginIdsFromFile(path: Path, log: Logger): Set<PluginId> {
|
||||
try {
|
||||
return readPluginIdsFromFile(path)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
@file:Suppress("ReplaceGetOrSet", "ReplacePutWithAssignment", "ReplaceNegatedIsEmptyWithIsNotEmpty")
|
||||
|
||||
package com.intellij.ide.plugins
|
||||
@@ -7,9 +7,6 @@ import com.intellij.core.CoreBundle
|
||||
import com.intellij.openapi.extensions.PluginId
|
||||
import com.intellij.util.Java11Shim
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap
|
||||
import kotlinx.collections.immutable.mutate
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.persistentSetOf
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.annotations.Nls
|
||||
import org.jetbrains.annotations.PropertyKey
|
||||
@@ -132,8 +129,8 @@ class PluginSetBuilder(@JvmField val unsortedPlugins: Set<IdeaPluginDescriptorIm
|
||||
|
||||
internal fun createPluginSet(incompletePlugins: Collection<IdeaPluginDescriptorImpl>): PluginSet {
|
||||
val sortedPlugins = getSortedPlugins()
|
||||
// ordered - do not use persistentHashSetOf
|
||||
val allPlugins = persistentSetOf<IdeaPluginDescriptorImpl>().mutate { result ->
|
||||
// must be ordered
|
||||
val allPlugins = LinkedHashSet<IdeaPluginDescriptorImpl>().also { result ->
|
||||
result.addAll(sortedPlugins)
|
||||
result.addAll(incompletePlugins)
|
||||
}
|
||||
@@ -142,12 +139,12 @@ class PluginSetBuilder(@JvmField val unsortedPlugins: Set<IdeaPluginDescriptorIm
|
||||
return PluginSet(
|
||||
moduleGraph = moduleGraph,
|
||||
allPlugins = allPlugins,
|
||||
enabledPlugins = persistentListOf<IdeaPluginDescriptorImpl>().mutate { result ->
|
||||
enabledPlugins = ArrayList<IdeaPluginDescriptorImpl>().also { result ->
|
||||
sortedPlugins.filterTo(result) { it.isEnabled }
|
||||
},
|
||||
enabledModuleMap = java11Shim.copyOf(enabledModuleV2Ids),
|
||||
enabledPluginAndV1ModuleMap = java11Shim.copyOf(enabledPluginIds),
|
||||
enabledModules = persistentListOf<IdeaPluginDescriptorImpl>().mutate { result ->
|
||||
enabledModules = ArrayList<IdeaPluginDescriptorImpl>().also { result ->
|
||||
for (module in moduleGraph.nodes) {
|
||||
if (if (module.moduleName == null) module.isEnabled else enabledModuleV2Ids.containsKey(module.moduleName)) {
|
||||
result.add(module)
|
||||
|
||||
@@ -12,13 +12,12 @@ import com.intellij.openapi.extensions.ExtensionDescriptor
|
||||
import com.intellij.openapi.extensions.ExtensionPointDescriptor
|
||||
import com.intellij.openapi.extensions.LoadingOrder
|
||||
import com.intellij.openapi.extensions.PluginId
|
||||
import com.intellij.util.Java11Shim
|
||||
import com.intellij.util.messages.ListenerDescriptor
|
||||
import com.intellij.util.xml.dom.NoOpXmlInterner
|
||||
import com.intellij.util.xml.dom.XmlInterner
|
||||
import com.intellij.util.xml.dom.createNonCoalescingXmlStreamReader
|
||||
import com.intellij.util.xml.dom.readXmlAsModel
|
||||
import kotlinx.collections.immutable.persistentHashSetOf
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import org.codehaus.stax2.XMLStreamReader2
|
||||
import org.codehaus.stax2.typed.TypedXMLStreamException
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
@@ -171,17 +170,17 @@ private fun readRootAttributes(reader: XMLStreamReader2, descriptor: RawPluginDe
|
||||
/**
|
||||
* Keep in sync with KotlinPluginUtil.KNOWN_KOTLIN_PLUGIN_IDS
|
||||
*/
|
||||
private val KNOWN_KOTLIN_PLUGIN_IDS = persistentHashSetOf(
|
||||
private val KNOWN_KOTLIN_PLUGIN_IDS = Java11Shim.INSTANCE.copyOf(listOf(
|
||||
"org.jetbrains.kotlin",
|
||||
"com.intellij.appcode.kmm",
|
||||
"org.jetbrains.kotlin.native.appcode"
|
||||
)
|
||||
))
|
||||
|
||||
fun isKotlinPlugin(pluginId: PluginId): Boolean {
|
||||
return pluginId.idString in KNOWN_KOTLIN_PLUGIN_IDS
|
||||
}
|
||||
|
||||
private val K2_ALLOWED_PLUGIN_IDS = KNOWN_KOTLIN_PLUGIN_IDS.addAll(persistentHashSetOf(
|
||||
private val K2_ALLOWED_PLUGIN_IDS = Java11Shim.INSTANCE.copyOf(KNOWN_KOTLIN_PLUGIN_IDS + listOf(
|
||||
"fleet.backend.mercury",
|
||||
"fleet.backend.mercury.macos",
|
||||
"fleet.backend.mercury.kotlin.macos",
|
||||
@@ -779,8 +778,8 @@ private fun readContent(reader: XMLStreamReader2, descriptor: RawPluginDescripto
|
||||
}
|
||||
|
||||
private fun readDependencies(reader: XMLStreamReader2, descriptor: RawPluginDescriptor, readContext: ReadModuleContext) {
|
||||
var modules = persistentListOf<ModuleDependenciesDescriptor.ModuleReference>()
|
||||
var plugins = persistentListOf<ModuleDependenciesDescriptor.PluginReference>()
|
||||
val modules = ArrayList<ModuleDependenciesDescriptor.ModuleReference>()
|
||||
val plugins = ArrayList<ModuleDependenciesDescriptor.PluginReference>()
|
||||
reader.consumeChildElements { elementName ->
|
||||
when (elementName) {
|
||||
"module" -> {
|
||||
@@ -791,7 +790,7 @@ private fun readDependencies(reader: XMLStreamReader2, descriptor: RawPluginDesc
|
||||
}
|
||||
}
|
||||
|
||||
modules = modules.add(ModuleDependenciesDescriptor.ModuleReference(name!!))
|
||||
modules.add(ModuleDependenciesDescriptor.ModuleReference(name!!))
|
||||
}
|
||||
"plugin" -> {
|
||||
var id: String? = null
|
||||
@@ -801,12 +800,13 @@ private fun readDependencies(reader: XMLStreamReader2, descriptor: RawPluginDesc
|
||||
}
|
||||
}
|
||||
|
||||
plugins = plugins.add(ModuleDependenciesDescriptor.PluginReference(PluginId.getId(id!!)))
|
||||
plugins.add(ModuleDependenciesDescriptor.PluginReference(PluginId.getId(id!!)))
|
||||
}
|
||||
else -> throw RuntimeException("Unknown content item type: $elementName")
|
||||
}
|
||||
reader.skipElement()
|
||||
}
|
||||
|
||||
descriptor.dependencies = ModuleDependenciesDescriptor(modules, plugins)
|
||||
assert(reader.isEndElement)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
@file:Suppress("ReplacePutWithAssignment")
|
||||
|
||||
package com.intellij.ide.plugins
|
||||
@@ -6,8 +6,6 @@ package com.intellij.ide.plugins
|
||||
import com.intellij.openapi.application.PathManager
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.extensions.PluginId
|
||||
import kotlinx.collections.immutable.mutate
|
||||
import kotlinx.collections.immutable.persistentHashSetOf
|
||||
import org.jetbrains.annotations.ApiStatus.Internal
|
||||
import java.io.BufferedInputStream
|
||||
import java.io.BufferedOutputStream
|
||||
@@ -111,7 +109,7 @@ private fun tryReadBrokenPluginsFile(brokenPluginsStorage: Path): Map<PluginId,
|
||||
val result = HashMap<PluginId, Set<String>>(count)
|
||||
for (i in 0 until count) {
|
||||
val pluginId = PluginId.getId(stream.readUTF())
|
||||
result.put(pluginId, persistentHashSetOf<String>().mutate { r ->
|
||||
result.put(pluginId, HashSet<String>().also { r ->
|
||||
repeat(stream.readUnsignedShort()) {
|
||||
r.add(stream.readUTF())
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.openapi.fileTypes;
|
||||
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
@@ -13,8 +13,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static kotlinx.collections.immutable.ExtensionsKt.persistentListOf;
|
||||
|
||||
public final class FileTypeEditorHighlighterProviders extends FileTypeExtension<EditorHighlighterProvider> {
|
||||
public static final ExtensionPointName<KeyedLazyInstance<EditorHighlighterProvider>> EP_NAME = ExtensionPointName.create("com.intellij.editorHighlighterProvider");
|
||||
public static final FileTypeEditorHighlighterProviders INSTANCE = new FileTypeEditorHighlighterProviders();
|
||||
@@ -40,7 +38,7 @@ public final class FileTypeEditorHighlighterProviders extends FileTypeExtension<
|
||||
SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, project, virtualFile), colors);
|
||||
}
|
||||
};
|
||||
return persistentListOf(defaultProvider);
|
||||
return List.of(defaultProvider);
|
||||
}
|
||||
return fromEP;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.openapi.fileTypes;
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
@@ -12,8 +12,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static kotlinx.collections.immutable.ExtensionsKt.persistentListOf;
|
||||
|
||||
public final class SyntaxHighlighterLanguageFactory extends LanguageExtension<SyntaxHighlighterFactory> {
|
||||
public static final ExtensionPointName<KeyedLazyInstance<SyntaxHighlighterFactory>> EP_NAME = new ExtensionPointName<>("com.intellij.lang.syntaxHighlighterFactory");
|
||||
|
||||
@@ -33,7 +31,7 @@ public final class SyntaxHighlighterLanguageFactory extends LanguageExtension<Sy
|
||||
SyntaxHighlighter highlighter = LanguageSyntaxHighlighters.INSTANCE.forLanguage(key);
|
||||
if (highlighter != null) {
|
||||
checkAddEPListener();
|
||||
return persistentListOf(new SingleLazyInstanceSyntaxHighlighterFactory() {
|
||||
return List.of(new SingleLazyInstanceSyntaxHighlighterFactory() {
|
||||
@Override
|
||||
protected @NotNull SyntaxHighlighter createHighlighter() {
|
||||
return highlighter;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package com.intellij.lang.findUsages;
|
||||
|
||||
@@ -13,7 +13,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
|
||||
public class LanguageFindUsages extends LanguageExtension<FindUsagesProvider> {
|
||||
public static final LanguageFindUsages INSTANCE = new LanguageFindUsages() {
|
||||
@NotNull
|
||||
|
||||
@@ -98,5 +98,6 @@
|
||||
<orderEntry type="module" module-name="intellij.platform.util.coroutines" />
|
||||
<orderEntry type="module" module-name="intellij.platform.analysis" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.xmlDom" />
|
||||
<orderEntry type="library" name="kotlinx-collections-immutable" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -144,5 +144,6 @@
|
||||
<orderEntry type="library" name="lz4-java" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.ml" />
|
||||
<orderEntry type="library" name="commons-compress" level="project" />
|
||||
<orderEntry type="library" name="kotlinx-collections-immutable" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -128,7 +128,7 @@ internal class IdeaFreezeReporter : PerformanceListener {
|
||||
val edtStack = dump.edtStackTrace
|
||||
if (edtStack != null) {
|
||||
stacktraceCommonPart = if (stacktraceCommonPart == null) {
|
||||
@Suppress("ReplaceJavaStaticMethodWithKotlinAnalog", "RemoveRedundantQualifierName")
|
||||
@Suppress("ReplaceJavaStaticMethodWithKotlinAnalog")
|
||||
java.util.List.of(*edtStack)
|
||||
}
|
||||
else {
|
||||
@@ -191,7 +191,7 @@ internal class IdeaFreezeReporter : PerformanceListener {
|
||||
reportDir: Path?,
|
||||
performanceWatcher: PerformanceWatcher,
|
||||
finished: Boolean): IdeaLoggingEvent? {
|
||||
var infos: List<Array<ThreadInfo>> = dumpTask.threadInfos
|
||||
var infos = dumpTask.threadInfos.toList()
|
||||
val dumpInterval = (if (infos.isEmpty()) performanceWatcher.dumpInterval else dumpTask.dumpInterval).toLong()
|
||||
if (infos.isEmpty()) {
|
||||
infos = currentDumps.map { it.threadInfos }
|
||||
@@ -314,7 +314,7 @@ private class CallTreeNode(private val stackTraceElement: StackTraceElement?,
|
||||
|
||||
fun findDominantCommonStack(threshold: Long): CallTreeNode? {
|
||||
var node: CallTreeNode? = getMostHitChild() ?: return null
|
||||
while (node != null && !node.children.isNullOrEmpty()) {
|
||||
while (node != null && !node.children.isEmpty()) {
|
||||
val mostHitChild = node.getMostHitChild()
|
||||
if (mostHitChild == null || mostHitChild.time <= threshold) break
|
||||
node = mostHitChild
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
@file:Suppress("ReplaceGetOrSet", "JAVA_MODULE_DOES_NOT_EXPORT_PACKAGE")
|
||||
|
||||
package com.intellij.diagnostic
|
||||
@@ -451,7 +451,7 @@ private fun postProcessReportFolder(durationMs: Long, task: SamplingTask, dir: P
|
||||
|
||||
private fun getFreezePlaceSuffix(task: SamplingTask): String {
|
||||
var stacktraceCommonPart: List<StackTraceElement>? = null
|
||||
for (info in task.threadInfos) {
|
||||
for (info in task.threadInfos.asIterable()) {
|
||||
val edt = info.firstOrNull(ThreadDumper::isEDT) ?: continue
|
||||
val edtStack = edt.stackTrace ?: continue
|
||||
stacktraceCommonPart = if (stacktraceCommonPart == null) {
|
||||
@@ -466,7 +466,7 @@ private fun getFreezePlaceSuffix(task: SamplingTask): String {
|
||||
return ""
|
||||
}
|
||||
|
||||
val element = stacktraceCommonPart[0]
|
||||
val element = stacktraceCommonPart.first()
|
||||
return "-${sanitizeFileName(StringUtilRt.getShortName(element.className))}.${sanitizeFileName(element.methodName)}"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.diagnostic
|
||||
|
||||
import com.intellij.util.containers.UList
|
||||
import com.sun.management.OperatingSystemMXBean
|
||||
import kotlinx.collections.immutable.PersistentList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.coroutines.*
|
||||
import java.lang.management.ManagementFactory
|
||||
import java.lang.management.ThreadInfo
|
||||
@@ -14,7 +13,7 @@ import kotlin.time.Duration.Companion.milliseconds
|
||||
internal open class SamplingTask(@JvmField internal val dumpInterval: Int, maxDurationMs: Int, coroutineScope: CoroutineScope) {
|
||||
private val maxDumps: Int = maxDurationMs / dumpInterval
|
||||
|
||||
var threadInfos: PersistentList<Array<ThreadInfo>> = persistentListOf()
|
||||
var threadInfos: UList<Array<ThreadInfo>> = UList()
|
||||
private set
|
||||
|
||||
private val job: Job?
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.openapi.project
|
||||
|
||||
import com.intellij.openapi.Disposable
|
||||
@@ -48,11 +48,11 @@ class UnindexedFilesScannerExecutor(project: Project)
|
||||
thisLogger().debug(Throwable("submit task, thread=${Thread.currentThread()}"))
|
||||
|
||||
// Two tasks with limited checks should be just run one after another.
|
||||
// A case of a full check followed by a limited change cancelling first one and making a full check anew results
|
||||
// A case of a full check followed by a limited change cancelling the first one and making a full check anew results
|
||||
// in endless restart of full checks on Windows with empty Maven cache.
|
||||
// So only in case the second one is a full check should the first one be cancelled.
|
||||
if (task.isFullIndexUpdate()) {
|
||||
// we don't want to execute any of the existing tasks - the only task we want to execute will be submitted few lines below
|
||||
// we don't want to execute any of the existing tasks - the only task we want to execute will be submitted the few lines below
|
||||
cancelAllTasks()
|
||||
cancelRunningScannerTaskInDumbQueue()
|
||||
}
|
||||
@@ -90,7 +90,7 @@ class UnindexedFilesScannerExecutor(project: Project)
|
||||
}
|
||||
|
||||
fun cancelAllTasksAndWait() {
|
||||
cancelAllTasks() // this also cancels running task even if they paused by ProgressSuspender
|
||||
cancelAllTasks() // this also cancels a running task even if they paused by ProgressSuspender
|
||||
while (isRunning.value && !project.isDisposed) {
|
||||
PingProgress.interactWithEdtProgress()
|
||||
LockSupport.parkNanos(50_000_000)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.platform.ide.bootstrap
|
||||
|
||||
import com.intellij.concurrency.ConcurrentCollectionFactory
|
||||
@@ -45,8 +45,7 @@ class Java11ShimImpl : Java11Shim() {
|
||||
9 -> java.util.List.of(array[0], array[1], array[2], array[3], array[4], array[5], array[6], array[7], array[8])
|
||||
10 -> java.util.List.of(array[0], array[1], array[2], array[3], array[4], array[5], array[6], array[7], array[8], array[9])
|
||||
11 -> java.util.List.of(array[0], array[1], array[2], array[3], array[4], array[5], array[6], array[7], array[8], array[9], array[10])
|
||||
12 -> java.util.List.of(array[0], array[1], array[2], array[3], array[4], array[5], array[6], array[7], array[8], array[9], array[10],
|
||||
array[11])
|
||||
12 -> java.util.List.of(array[0], array[1], array[2], array[3], array[4], array[5], array[6], array[7], array[8], array[9], array[10], array[11])
|
||||
else -> {
|
||||
if (array.size == size) {
|
||||
java.util.List.of(*array)
|
||||
|
||||
@@ -35,12 +35,11 @@ import com.intellij.platform.instanceContainer.internal.*
|
||||
import com.intellij.platform.util.coroutines.namedChildScope
|
||||
import com.intellij.util.concurrency.ThreadingAssertions
|
||||
import com.intellij.util.concurrency.annotations.RequiresBlockingContext
|
||||
import com.intellij.util.containers.UList
|
||||
import com.intellij.util.messages.*
|
||||
import com.intellij.util.messages.impl.MessageBusEx
|
||||
import com.intellij.util.messages.impl.MessageBusImpl
|
||||
import com.intellij.util.runSuppressing
|
||||
import kotlinx.collections.immutable.PersistentList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.coroutines.*
|
||||
import org.jetbrains.annotations.ApiStatus.Internal
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
@@ -1408,7 +1407,7 @@ abstract class ComponentManagerImpl(
|
||||
|
||||
private class PluginServicesStore {
|
||||
private val regularServices = ConcurrentHashMap<IdeaPluginDescriptor, UnregisterHandle>()
|
||||
private val dynamicServices = ConcurrentHashMap<IdeaPluginDescriptor, PersistentList<InstanceHolder>>()
|
||||
private val dynamicServices = ConcurrentHashMap<IdeaPluginDescriptor, UList<InstanceHolder>>()
|
||||
|
||||
fun putServicesUnregisterHandle(descriptor: IdeaPluginDescriptor, handle: UnregisterHandle) {
|
||||
val prev = regularServices.put(descriptor, handle)
|
||||
@@ -1421,12 +1420,12 @@ private class PluginServicesStore {
|
||||
|
||||
fun addDynamicService(descriptor: IdeaPluginDescriptor, holder: InstanceHolder) {
|
||||
dynamicServices.compute(descriptor) { _, instances ->
|
||||
(instances ?: persistentListOf()).add(holder)
|
||||
(instances ?: UList()).add(holder)
|
||||
}
|
||||
}
|
||||
|
||||
fun removeDynamicServices(descriptor: IdeaPluginDescriptor): List<InstanceHolder> {
|
||||
return dynamicServices.remove(descriptor) ?: java.util.List.of()
|
||||
return dynamicServices.remove(descriptor)?.toList() ?: java.util.List.of()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
@file:Suppress("ReplacePutWithAssignment")
|
||||
|
||||
package com.intellij.util.containers
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.util.ArrayUtil
|
||||
import com.intellij.util.ArrayUtilRt
|
||||
import com.intellij.util.Java11Shim
|
||||
import com.intellij.util.SmartList
|
||||
import com.intellij.util.lang.CompoundRuntimeException
|
||||
@@ -14,6 +16,28 @@ import java.util.stream.Stream
|
||||
import kotlin.collections.ArrayDeque
|
||||
import kotlin.collections.isNullOrEmpty
|
||||
|
||||
@Internal
|
||||
@Experimental
|
||||
@JvmInline
|
||||
value class UList<T>(private val array: Array<Any?> = ArrayUtilRt.EMPTY_OBJECT_ARRAY) {
|
||||
val size: Int
|
||||
get() = array.size
|
||||
|
||||
fun add(item: T): UList<T> {
|
||||
return UList(ArrayUtil.append(/* src = */ array, /* element = */ item, /* factory = */ ArrayUtil.OBJECT_ARRAY_FACTORY))
|
||||
}
|
||||
|
||||
fun remove(item: T): UList<T> {
|
||||
return UList(ArrayUtil.remove(/* src = */ array, /* element = */ item, /* factory = */ ArrayUtil.OBJECT_ARRAY_FACTORY))
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun toList(): List<T> = Java11Shim.INSTANCE.listOf(array, array.size) as List<T>
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun asIterable(): Iterable<T> = array.asIterable() as Iterable<T>
|
||||
}
|
||||
|
||||
fun <K, V> MutableMap<K, MutableList<V>>.remove(key: K, value: V) {
|
||||
val list = get(key)
|
||||
if (list != null && list.remove(value) && list.isEmpty()) {
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.openapi.vcs.impl
|
||||
|
||||
import com.intellij.openapi.vcs.AbstractVcs
|
||||
import com.intellij.openapi.vcs.checkin.BaseCheckinHandlerFactory
|
||||
import com.intellij.openapi.vcs.checkin.CheckinHandlerFactory
|
||||
import com.intellij.openapi.vcs.checkin.VcsCheckinHandlerFactory
|
||||
import kotlinx.collections.immutable.mutate
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
|
||||
class CheckinHandlersManagerImpl : CheckinHandlersManager() {
|
||||
override fun getRegisteredCheckinHandlerFactories(vcses: Array<AbstractVcs>): List<BaseCheckinHandlerFactory> {
|
||||
val vcsesKeys = vcses.mapTo(HashSet()) { it.keyInstanceMethod }
|
||||
return persistentListOf<BaseCheckinHandlerFactory>().mutate { builder ->
|
||||
return ArrayList<BaseCheckinHandlerFactory>().also { builder ->
|
||||
VcsCheckinHandlerFactory.EP_NAME.extensionList.filterTo(builder) { it.key in vcsesKeys }
|
||||
builder.addAll(CheckinHandlerFactory.EP_NAME.extensionList)
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
<orderEntry type="module" module-name="intellij.platform.backend.workspace" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.tools.ide.metrics.benchmark" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.coroutines" scope="TEST" />
|
||||
<orderEntry type="library" name="kotlinx-collections-immutable" level="project" />
|
||||
</component>
|
||||
<component name="TestModuleProperties" production-module="intellij.platform.workspace.jps" />
|
||||
</module>
|
||||
@@ -17,6 +17,7 @@
|
||||
<orderEntry type="library" name="kotlin-test" level="project" />
|
||||
<orderEntry type="library" name="Kryo5" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.testFramework.junit5" scope="TEST" />
|
||||
<orderEntry type="library" name="kotlinx-collections-immutable" level="project" />
|
||||
</component>
|
||||
<component name="TestModuleProperties" production-module="intellij.platform.workspace.storage" />
|
||||
</module>
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.idea.maven.indices
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
@@ -18,7 +18,6 @@ import com.intellij.platform.ide.progress.withBackgroundProgress
|
||||
import com.intellij.util.PathUtilRt
|
||||
import com.intellij.util.messages.Topic
|
||||
import com.intellij.util.xmlb.annotations.OptionTag
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
@@ -307,7 +306,7 @@ class MavenSystemIndicesManager(val cs: CoroutineScope) : PersistentStateCompone
|
||||
|
||||
@TestOnly
|
||||
fun getAllGavIndices(): List<MavenGAVIndex> {
|
||||
return inMemoryIndices.values.toImmutableList()
|
||||
return java.util.List.copyOf(inMemoryIndices.values)
|
||||
}
|
||||
|
||||
fun updateIndexContent(repositoryInfo: MavenRepositoryInfo, project: Project) {
|
||||
|
||||
Reference in New Issue
Block a user