From 80492a316179049359d16afbb5123e1bf3f8c355 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Wed, 13 Sep 2023 10:33:03 +0200 Subject: [PATCH] IJPL-238 remove the unnecessary usage of commons-lang library (part 5 - introduce commons-text) GitOrigin-RevId: cd43b822494cea06bfd4eba2af1f70869b954024 --- .idea/libraries/Velocity.xml | 6 +- .idea/libraries/commons_text.xml | 18 ++++ .idea/libraries/kotlinx_datetime_jvm.xml | 10 +- .idea/libraries/maven_resolver_provider.xml | 99 ++++++++----------- .../libraries/org_codehaus_groovy_groovy.xml | 2 +- .idea/libraries/plexus_utils.xml | 10 +- ...intellij.java.aetherDependencyResolver.iml | 32 +++--- .../aether/ArtifactRepositoryManager.java | 12 +-- .../build/impl/DistributionBuilderState.kt | 8 +- .../build/impl/DistributionJARsBuilder.kt | 42 +++----- .../intellij/build/impl/JarPackager.kt | 1 + .../intellij/build/impl/PlatformModules.kt | 5 +- .../editorconfig/intellij.editorconfig.iml | 1 - .../resources/META-INF/plugin.xml | 1 - .../editor/EditorConfigPreviewManager.java | 45 +-------- .../core/intellij.evaluationPlugin.core.iml | 1 + .../intellij/cce/metric/SimilarityMetrics.kt | 8 +- .../intellij.evaluationPlugin.iml | 1 + plugins/grazie/src/intellij.grazie.core.iml | 19 +--- 19 files changed, 126 insertions(+), 195 deletions(-) create mode 100644 .idea/libraries/commons_text.xml diff --git a/.idea/libraries/Velocity.xml b/.idea/libraries/Velocity.xml index 3d81b7797721..1b87fec92f48 100644 --- a/.idea/libraries/Velocity.xml +++ b/.idea/libraries/Velocity.xml @@ -5,22 +5,18 @@ b086cee8fd8183e240b4afcf54fe38ec33dd8eb0da414636e5bf7aa4d9856629 - - 4ee380259c068d1dbe9e84ab52186f2acd65de067ec09beff731fca1697fdb16 - + - - \ No newline at end of file diff --git a/.idea/libraries/commons_text.xml b/.idea/libraries/commons_text.xml new file mode 100644 index 000000000000..814d7761ef56 --- /dev/null +++ b/.idea/libraries/commons_text.xml @@ -0,0 +1,18 @@ + + + + + + 770cd903fa7b604d1f7ef7ba17f84108667294b2b478be8ed1af3bffb4ae0018 + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/kotlinx_datetime_jvm.xml b/.idea/libraries/kotlinx_datetime_jvm.xml index 0c5f34f0c5bf..708bc5d83e5a 100644 --- a/.idea/libraries/kotlinx_datetime_jvm.xml +++ b/.idea/libraries/kotlinx_datetime_jvm.xml @@ -1,18 +1,18 @@ - + - - 075ca75a16e356484c07de3cc7bce79da9e4adbc670bbcf23c5e13f4e12ee6e7 + + 7ddf52a4d3bbf3138fff1f8c581a3149ca7ff2c4895f33dcdb20c759a3dda050 - + - + \ No newline at end of file diff --git a/.idea/libraries/maven_resolver_provider.xml b/.idea/libraries/maven_resolver_provider.xml index 03b0d6aa1749..f164d4d5a413 100644 --- a/.idea/libraries/maven_resolver_provider.xml +++ b/.idea/libraries/maven_resolver_provider.xml @@ -1,92 +1,79 @@ - + - - ba9bf12fd2fa45780235bb61bbf7e4593c60d741f008e089b99929e8c6b58aa9 + + 197a8a6e7c7df66dd1fa70bb495ac7616f0e96f43d354d69ff4794d725d47427 - - 7931dc8dda878eef46988d9fd07c4ade3c91892d7fb3208c742cb9457135bb15 + + c392548bc1a3f0c6a180f888bd2349602de5b1e30059fe0ec46f81ed4ce14129 - - 815b1886d1ec8e1d8b57b61e6ac83235be3f6a60159c8ee5a6f4e91f513f497f + + 288c29acda1d26138c8a53fff326ee79bbce870c63c9ac876e7fe8c2944044d3 b3b5412ce17889103ea564bcdfcf9fb3dfa540344ffeac6b538a73c9d7182662 - - 7dd352fd9f8ff86a1d0a7d89e6289d8d3cd346ac9b214ed85868d585be05ab78 + + 813233a8485cbaf97b1f9a2c17cef723b068f7260a4319cf4958f221d04b9937 - - d919d904486c037f8d193412da0c92e22a9fa24230b9d67a57855c5c31c7e94e - - - 86946fb06cb205515539b93b005c3bb928ba3d0d140af68079cc4cc815125096 + + c425ca169d67217256a8d1991144691fcf23351e09431890af240bfeed33b902 c5994010bcdce1d2bd603a4d50c47191ddbd7875d1157b23aaa26d33c82fda13 - - 1d5c3393aa39f807837fb058d78ac8d0a287adf19f4ba6ad5070353acf61b081 + + b396d3b081b353541ea9a147ab2d3eee5723b460d130ef7cb1d95366aeab7c31 - - 2b8939ebb46a760deca82faae356145105d27a01748aac30d202ce9d4494edf4 + + d0b28ed944058ba4f9be4b54c25d6d5269cc4f3f3c49aa450d4dc2f7e0d552f6 - - 5989f5060b163230b2c3f99d93f68622d6c33cce1a24f0077059dc69d2f7375b + + 17441a39045ac19bc4a8068fb7284facebf6337754bf2bf8f26a76b5f98ed108 - - 04d47ff236f63ddd61cb2d6e537d2ffd4d326370d5d73fb480ba47b08760ffef + + cdcad9355b625743f40e4cead9a96353404e010c39c808d23b044be331afa251 - - 80903754456410ae4c8eb5db2a773b2cbcc3e2eb3f9cffed414cb516d13ff7a0 - - - a5b11158da6c26a09bf894b90df12d11a6a6293790f25c96a4a7e509b6ac59f2 - - - 86e0255d4c879c61b4833ed7f13124e8bb679df47debb127326e7db7dd49a07b + + 17aaebe6e3e59df8cb5b4ec210196f7084637312b9bc4ff14cb77ad1ae3c381b + + - - - + + + - - - + + - - - - - - - + + + + + - - - + + + - - - + + - - - - - - - + + + + + \ No newline at end of file diff --git a/.idea/libraries/org_codehaus_groovy_groovy.xml b/.idea/libraries/org_codehaus_groovy_groovy.xml index 62a107961d2c..b0bf5d417acd 100644 --- a/.idea/libraries/org_codehaus_groovy_groovy.xml +++ b/.idea/libraries/org_codehaus_groovy_groovy.xml @@ -1,6 +1,6 @@ - + 7ad326b0a7e49791f552313e35df7406c1a46bb6faf7908c2ecbb74daeff23fb diff --git a/.idea/libraries/plexus_utils.xml b/.idea/libraries/plexus_utils.xml index 270afbec305f..c4443f8ad778 100644 --- a/.idea/libraries/plexus_utils.xml +++ b/.idea/libraries/plexus_utils.xml @@ -1,18 +1,18 @@ - + - - 270cd703b48c6e5c8c691f1875f22d62d22cfe072c73ae2f5814d83d68c1da0b + + 86e0255d4c879c61b4833ed7f13124e8bb679df47debb127326e7db7dd49a07b - + - + \ No newline at end of file diff --git a/aether-dependency-resolver/intellij.java.aetherDependencyResolver.iml b/aether-dependency-resolver/intellij.java.aetherDependencyResolver.iml index e9714479545e..166a61e43c0d 100644 --- a/aether-dependency-resolver/intellij.java.aetherDependencyResolver.iml +++ b/aether-dependency-resolver/intellij.java.aetherDependencyResolver.iml @@ -33,10 +33,10 @@ - + - - 2402405da2a24324d5b15009c9cf65fc22a3b0d662af1533831c3b8b1ec5ceeb + + 663bc1ab1f5b2e2462d241e48934d84e4cddc950a17f7f19c53ebf1b39cc5569 @@ -46,20 +46,20 @@ - + - + - + - - 903130fb398dbedb1364cded7717ba3aa44084a1e403160cfb17e7ecbdc4e459 + + 465bbb05ee2e1504738d26a1bfeca0c85d133476f3f625ceb1c7eb57e39b15ac @@ -74,20 +74,20 @@ - + - + - + - - 36b7449dc69418d8ecb421fc06a72453980dcc56d57db3c343b16f44c797726c + + 50174586a20ab1d0082bafaa12939932592164fd0fecdcac2f60af26684b6e34 @@ -98,14 +98,16 @@ - + - + + + diff --git a/aether-dependency-resolver/src/org/jetbrains/idea/maven/aether/ArtifactRepositoryManager.java b/aether-dependency-resolver/src/org/jetbrains/idea/maven/aether/ArtifactRepositoryManager.java index 1c24f0296a7f..d11124c15f71 100644 --- a/aether-dependency-resolver/src/org/jetbrains/idea/maven/aether/ArtifactRepositoryManager.java +++ b/aether-dependency-resolver/src/org/jetbrains/idea/maven/aether/ArtifactRepositoryManager.java @@ -48,7 +48,7 @@ import java.util.stream.Collectors; * Aether-based repository manager and dependency resolver using maven implementation of this functionality. *

* instance of this component should be managed by the code which requires dependency resolution functionality - * all necessary params like path to local repo should be passed in constructor + * all necessary params like a path to local repo should be passed in constructor */ public final class ArtifactRepositoryManager { private static final VersionScheme ourVersioning = new GenericVersionScheme(); @@ -281,7 +281,7 @@ public final class ArtifactRepositoryManager { org.slf4j.impl.JDK14LoggerFactory.class, // slf4j-jdk14 - required for aether resolver at runtime org.apache.commons.codec.binary.Base64.class // commons-codec )); - result.addAll(Arrays.asList(ClassPathUtil.getUtilClasses())); // intellij.platform.util module + result.addAll(List.of(ClassPathUtil.getUtilClasses())); // intellij.platform.util module return result.toArray(ArrayUtil.EMPTY_CLASS_ARRAY); } @@ -330,7 +330,7 @@ public final class ArtifactRepositoryManager { VersionConstraint originalConstraints = asVersionConstraint(versionConstraint); for (ArtifactKind kind : artifactKinds) { // RepositorySystem.resolveDependencies() ignores classifiers, so we need to set classifiers explicitly for discovered dependencies. - // Because of that we have to first discover deps and then resolve corresponding artifacts + // Because of that, we have to first discover deps and then resolve corresponding artifacts try { List requests = new ArrayList<>(); Set constraints; @@ -362,7 +362,7 @@ public final class ArtifactRepositoryManager { } catch (ArtifactResolutionException e) { if (kind != ArtifactKind.ARTIFACT) { - // for sources and javadocs try to process requests one-by-one and fetch at least something + // for sources and javadocs, try to process requests one-by-one and fetch at least something if (requests.size() > 1) { for (ArtifactRequest request : requests) { try { @@ -463,7 +463,7 @@ public final class ArtifactRepositoryManager { * Modify version constraint to look for applicable "annotations" artifact. *

* "Annotations" artifact for a given library is matched by Group ID, Artifact ID, and classifier "annotations". - * "Annotations" version is selected using following rules: + * "Annotations" version is selected using the following rules: *

* This allows to re-use existing annotations artifacts across different library versions - * @param constraint - version or range constraint of original library + * @param constraint - version or range constraint of an original library * @return resulting relaxed constraint to select "annotations" artifact. */ private static Set relaxForAnnotations(VersionConstraint constraint) { diff --git a/platform/build-scripts/src/org/jetbrains/intellij/build/impl/DistributionBuilderState.kt b/platform/build-scripts/src/org/jetbrains/intellij/build/impl/DistributionBuilderState.kt index adb4259f1a0b..7ecb314fa439 100644 --- a/platform/build-scripts/src/org/jetbrains/intellij/build/impl/DistributionBuilderState.kt +++ b/platform/build-scripts/src/org/jetbrains/intellij/build/impl/DistributionBuilderState.kt @@ -4,8 +4,6 @@ package org.jetbrains.intellij.build.impl import org.jetbrains.intellij.build.BuildContext -import org.jetbrains.jps.model.library.JpsLibrary -import org.jetbrains.jps.model.module.JpsModuleReference suspend fun createDistributionBuilderState(pluginsToPublish: Set, context: BuildContext): DistributionBuilderState { val pluginsToPublishEffective = pluginsToPublish.toMutableSet() @@ -78,8 +76,4 @@ internal fun filterPluginsToPublish(plugins: MutableSet, context: internal fun getToolModules(): List { return java.util.List.of("intellij.java.rt", "intellij.platform.main", /*required to build searchable options index*/ "intellij.platform.updater") -} - -internal fun isProjectLibraryUsedByPlugin(library: JpsLibrary, plugin: BaseLayout): Boolean { - return library.createReference().parentReference !is JpsModuleReference && !plugin.hasLibrary(library.name) -} +} \ No newline at end of file diff --git a/platform/build-scripts/src/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.kt b/platform/build-scripts/src/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.kt index 679f777e48f0..3dc33caca0bc 100644 --- a/platform/build-scripts/src/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.kt +++ b/platform/build-scripts/src/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.kt @@ -8,7 +8,6 @@ import com.intellij.openapi.util.io.NioFiles import com.intellij.openapi.util.text.StringUtil import com.intellij.platform.diagnostic.telemetry.helpers.useWithScope import com.intellij.platform.diagnostic.telemetry.helpers.useWithScope2 -import com.intellij.util.containers.MultiMap import com.intellij.util.io.Compressor import com.jetbrains.plugin.blockmap.core.BlockMap import com.jetbrains.plugin.blockmap.core.FileHash @@ -22,7 +21,6 @@ import io.opentelemetry.extension.kotlin.asContextElement import kotlinx.collections.immutable.persistentListOf import kotlinx.coroutines.* import org.apache.commons.compress.archivers.zip.Zip64Mode -import org.jetbrains.annotations.TestOnly import org.jetbrains.annotations.VisibleForTesting import org.jetbrains.intellij.build.* import org.jetbrains.intellij.build.TraceManager.spanBuilder @@ -32,12 +30,8 @@ import org.jetbrains.intellij.build.io.* import org.jetbrains.jps.model.artifact.JpsArtifact import org.jetbrains.jps.model.artifact.JpsArtifactService import org.jetbrains.jps.model.artifact.elements.JpsLibraryFilesPackagingElement -import org.jetbrains.jps.model.java.JpsJavaClasspathKind -import org.jetbrains.jps.model.java.JpsJavaExtensionService import org.jetbrains.jps.model.java.JpsProductionModuleOutputPackagingElement import org.jetbrains.jps.model.java.JpsTestModuleOutputPackagingElement -import org.jetbrains.jps.model.library.JpsLibrary -import org.jetbrains.jps.model.module.JpsModule import org.jetbrains.jps.model.module.JpsModuleReference import org.jetbrains.jps.util.JpsPathUtil import java.nio.ByteBuffer @@ -101,9 +95,12 @@ internal suspend fun buildDistribution(state: DistributionBuilderState, val distAllDir = context.paths.distAllDir val libDir = distAllDir.resolve("lib") - context.bootClassPathJarNames = - if (context.useModularLoader) persistentListOf(PLATFORM_LOADER_JAR) - else generateClasspath(homeDir = distAllDir, libDir = libDir, antTargetFile = antTargetFile) + context.bootClassPathJarNames = if (context.useModularLoader) { + persistentListOf(PLATFORM_LOADER_JAR) + } + else { + generateClasspath(homeDir = distAllDir, libDir = libDir, antTargetFile = antTargetFile) + } result } } @@ -137,7 +134,7 @@ internal suspend fun buildDistribution(state: DistributionBuilderState, val pluginDir = context.paths.distAllDir.resolve("plugins") withContext(Dispatchers.IO) { for (sourceDir in additionalPluginPaths) { - copyDir(sourceDir, pluginDir.resolve(sourceDir.fileName)) + copyDir(sourceDir = sourceDir, targetDir = pluginDir.resolve(sourceDir.fileName)) } } } @@ -147,9 +144,7 @@ internal suspend fun buildDistribution(state: DistributionBuilderState, spanBuilder("generate content report").useWithScope2 { Files.createDirectories(context.paths.artifactDir) val contentMappingJson = context.paths.artifactDir.resolve("content-mapping.json") - writeProjectStructureReport(entries = entries, - file = contentMappingJson, - buildPaths = context.paths) + writeProjectStructureReport(entries = entries, file = contentMappingJson, buildPaths = context.paths) val contentJson = context.paths.artifactDir.resolve("content.json") Files.newOutputStream(contentJson).use { buildJarContentReport(entries = entries, out = it, buildPaths = context.paths, context = context) @@ -488,7 +483,7 @@ private suspend fun buildPlugins(moduleOutputPatcher: ModuleOutputPatcher, Span.current().addEvent("skip scrambling plugin because step is disabled", attributes) } else { - // we can not start executing right now because the plugin can use other plugins in a scramble classpath + // we cannot start executing right now because the plugin can use other plugins in a scramble classpath scrambleTasks.add(ScrambleTask(plugin, pluginDir, targetDir)) } } @@ -531,7 +526,7 @@ internal class PluginRepositorySpec(@JvmField val pluginZip: Path, @JvmField val fun getPluginLayoutsByJpsModuleNames(modules: Collection, productLayout: ProductModulesLayout): MutableSet { if (modules.isEmpty()) { - return createPluginLayoutSet(0) + return createPluginLayoutSet(expectedSize = 0) } val pluginLayouts = productLayout.pluginLayouts @@ -540,7 +535,7 @@ fun getPluginLayoutsByJpsModuleNames(modules: Collection, productLayout: for (moduleName in modules) { val customLayouts = pluginLayoutsByMainModule.get(moduleName) if (customLayouts == null) { - check(moduleName == "kotlin-ultimate.kmm-plugin" || result.add(PluginLayout.plugin(moduleName))) { + check(moduleName == "kotlin-ultimate.kmm-plugin" || result.add(PluginLayout.pluginAuto(listOf(moduleName)))) { "Plugin layout for module $moduleName is already added (duplicated module name?)" } } @@ -555,21 +550,6 @@ fun getPluginLayoutsByJpsModuleNames(modules: Collection, productLayout: return result } -@TestOnly -fun collectProjectLibrariesWhichShouldBeProvidedByPlatform(plugin: BaseLayout, - result: MultiMap, - context: BuildContext) { - for (moduleName in plugin.includedModules.map { it.moduleName }.distinct()) { - val module = context.findRequiredModule((moduleName)) - val dependencies = JpsJavaExtensionService.dependencies(module) - for (library in dependencies.includedIn(JpsJavaClasspathKind.PRODUCTION_RUNTIME).libraries) { - if (isProjectLibraryUsedByPlugin(library, plugin)) { - result.putValue(library, module) - } - } - } -} - private fun basePath(buildContext: BuildContext, moduleName: String): Path { return Path.of(JpsPathUtil.urlToPath(buildContext.findRequiredModule(moduleName).contentRootsList.urls.first())) } diff --git a/platform/build-scripts/src/org/jetbrains/intellij/build/impl/JarPackager.kt b/platform/build-scripts/src/org/jetbrains/intellij/build/impl/JarPackager.kt index 309f67990b6a..c07849c86488 100644 --- a/platform/build-scripts/src/org/jetbrains/intellij/build/impl/JarPackager.kt +++ b/platform/build-scripts/src/org/jetbrains/intellij/build/impl/JarPackager.kt @@ -604,6 +604,7 @@ private fun getLibraryFiles(library: JpsLibrary, val alreadyCopiedLibraryName = alreadyCopiedFor.library.name alreadyCopiedFor.targetFile == targetFile && (alreadyCopiedLibraryName.startsWith("ktor-") || + alreadyCopiedLibraryName.startsWith("commons-") || alreadyCopiedLibraryName.startsWith("ai.grazie.") || (isModuleLevel && alreadyCopiedLibraryName == libName)) } diff --git a/platform/build-scripts/src/org/jetbrains/intellij/build/impl/PlatformModules.kt b/platform/build-scripts/src/org/jetbrains/intellij/build/impl/PlatformModules.kt index 34ee4337c45c..3ccdda97de2f 100644 --- a/platform/build-scripts/src/org/jetbrains/intellij/build/impl/PlatformModules.kt +++ b/platform/build-scripts/src/org/jetbrains/intellij/build/impl/PlatformModules.kt @@ -184,7 +184,7 @@ internal suspend fun createPlatformLayout(addPlatformCoverage: Boolean, ), productLayout = productLayout, layout = layout) layout.withProjectLibrary(libraryName = "ion", jarName = UTIL_RT_JAR) - // JDOM is used by maven in an external process + // Maven uses JDOM in an external process addModule(UTIL_8_JAR, listOf( "intellij.platform.util.jdom", "intellij.platform.util.xmlDom", @@ -199,6 +199,9 @@ internal suspend fun createPlatformLayout(addPlatformCoverage: Boolean, // Space plugin uses it and bundles into IntelliJ IDEA, but not bundles into DataGrip, so, or Space plugin should bundle this lib, // or IJ Platform. As it is a small library and consistency is important across other coroutine libs, bundle to IJ Platform. layout.withProjectLibrary(libraryName = "kotlinx-coroutines-slf4j", jarName = APP_JAR) + // make sure that all ktor libraries bundled into the platform + layout.withProjectLibrary(libraryName = "ktor-client-content-negotiation") + layout.withProjectLibrary(libraryName = "ktor-client-logging") // used by intellij.database.jdbcConsole - // cannot be in 3rd-party-rt.jar, because this JAR must contain classes for java versions <= 7 only diff --git a/plugins/editorconfig/intellij.editorconfig.iml b/plugins/editorconfig/intellij.editorconfig.iml index a5307af24038..74c8c92e56ef 100644 --- a/plugins/editorconfig/intellij.editorconfig.iml +++ b/plugins/editorconfig/intellij.editorconfig.iml @@ -29,6 +29,5 @@ - \ No newline at end of file diff --git a/plugins/editorconfig/resources/META-INF/plugin.xml b/plugins/editorconfig/resources/META-INF/plugin.xml index 15c067631c02..c92250d47c6d 100644 --- a/plugins/editorconfig/resources/META-INF/plugin.xml +++ b/plugins/editorconfig/resources/META-INF/plugin.xml @@ -40,7 +40,6 @@ For more information, check the documentation for - diff --git a/plugins/editorconfig/src/org/editorconfig/configmanagement/editor/EditorConfigPreviewManager.java b/plugins/editorconfig/src/org/editorconfig/configmanagement/editor/EditorConfigPreviewManager.java index 4cb60b2f2b7f..25c235a8d163 100644 --- a/plugins/editorconfig/src/org/editorconfig/configmanagement/editor/EditorConfigPreviewManager.java +++ b/plugins/editorconfig/src/org/editorconfig/configmanagement/editor/EditorConfigPreviewManager.java @@ -1,41 +1,33 @@ // Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.editorconfig.configmanagement.editor; -import com.intellij.openapi.components.PersistentStateComponent; -import com.intellij.openapi.components.State; -import com.intellij.openapi.components.Storage; -import com.intellij.openapi.components.StoragePathMacros; +import com.intellij.openapi.components.*; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; -import org.apache.commons.lang3.CharUtils; -import org.editorconfig.language.psi.EditorConfigHeader; import org.jdom.Element; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; +@Service(Service.Level.PROJECT) @State( name = "EditorConfigPreviewManager", storages = @Storage(StoragePathMacros.WORKSPACE_FILE) ) -public class EditorConfigPreviewManager implements PersistentStateComponent { - +public final class EditorConfigPreviewManager implements PersistentStateComponent { private final Map myPreviewMap = new HashMap<>(); public static final String PREVIEW_RECORD_TAG = "editorConfig"; public static final String EDITORCONFIG_FILE_ATTR = "file"; public static final String PREVIEW_FILE_ATTR = "previewFile"; - @Nullable @Override - public Element getState() { + public @NotNull Element getState() { Element state = new Element("previewData"); for (String key : myPreviewMap.keySet()) { String value = myPreviewMap.get(key); @@ -64,32 +56,6 @@ public class EditorConfigPreviewManager implements PersistentStateComponent extractExtensions(@NotNull EditorConfigHeader header) { - List extensions = new ArrayList<>(); - CharSequence headerChars = header.getNode().getChars(); - boolean isInExt = false; - StringBuilder extBuilder = new StringBuilder(); - for (int i = 0; i < headerChars.length(); i ++) { - char c = headerChars.charAt(i); - if (c == '.') { - isInExt = true; - } - else if ((CharUtils.isAsciiAlpha(c) || CharUtils.isAsciiNumeric(c)) && isInExt) { - extBuilder.append(c); - } - else { - if (isInExt && !extBuilder.isEmpty()) { - extensions.add(extBuilder.toString()); - extBuilder = new StringBuilder(); - } - isInExt = false; - } - } - return extensions; - } - - public void associateWithPreviewFile(@NotNull VirtualFile editorConfigFile, @Nullable VirtualFile previewFile) { if (previewFile != null) { myPreviewMap.put(editorConfigFile.getPath(), previewFile.getPath()); @@ -99,8 +65,7 @@ public class EditorConfigPreviewManager implements PersistentStateComponent + \ No newline at end of file diff --git a/plugins/evaluation-plugin/core/src/com/intellij/cce/metric/SimilarityMetrics.kt b/plugins/evaluation-plugin/core/src/com/intellij/cce/metric/SimilarityMetrics.kt index 3f9e732e634c..58c31e07533b 100644 --- a/plugins/evaluation-plugin/core/src/com/intellij/cce/metric/SimilarityMetrics.kt +++ b/plugins/evaluation-plugin/core/src/com/intellij/cce/metric/SimilarityMetrics.kt @@ -5,6 +5,7 @@ import com.intellij.cce.core.Lookup import com.intellij.cce.core.Session import com.intellij.cce.metric.util.Bootstrap import org.apache.commons.lang3.StringUtils +import org.apache.commons.text.similarity.LevenshteinDistance import kotlin.math.max import kotlin.math.min @@ -87,8 +88,9 @@ class EditSimilarity(showByDefault: Boolean = false) : SimilarityMetric(showByDe override val name = "Edit Similarity" override val description: String = "The minimum edit similarity among proposals normalized by expected text (avg by invocations)" - override fun computeSimilarity(lookup: Lookup, expectedText: String): Double? = - lookup.suggestions.maxOfOrNull { - expectedText.length - StringUtils.getLevenshteinDistance(it.text.drop(lookup.prefix.length), expectedText) + override fun computeSimilarity(lookup: Lookup, expectedText: String): Double? { + return lookup.suggestions.maxOfOrNull { + expectedText.length - LevenshteinDistance.getDefaultInstance().apply(it.text.drop(lookup.prefix.length), expectedText) }?.toDouble() + } } diff --git a/plugins/evaluation-plugin/intellij.evaluationPlugin.iml b/plugins/evaluation-plugin/intellij.evaluationPlugin.iml index ff7c70b0d8b5..f706af818003 100644 --- a/plugins/evaluation-plugin/intellij.evaluationPlugin.iml +++ b/plugins/evaluation-plugin/intellij.evaluationPlugin.iml @@ -21,5 +21,6 @@ + \ No newline at end of file diff --git a/plugins/grazie/src/intellij.grazie.core.iml b/plugins/grazie/src/intellij.grazie.core.iml index dc9c746f748f..265a94bcfe12 100644 --- a/plugins/grazie/src/intellij.grazie.core.iml +++ b/plugins/grazie/src/intellij.grazie.core.iml @@ -15,24 +15,7 @@ - - - - - - 770cd903fa7b604d1f7ef7ba17f84108667294b2b478be8ed1af3bffb4ae0018 - - - - - - - - - - - - +