From c0a7d2040292471b1c4271e1e702dfd73edb94a5 Mon Sep 17 00:00:00 2001 From: Yuliya Karalenka Date: Mon, 16 Jun 2025 13:18:52 +0200 Subject: [PATCH] [terminal] Refactoring: Small fixes 1. Make `TerminalCommandSpecCompletionContributorGen2` internal 2. Move `TerminalCommandSpecCompletionContributorGen2` to the new package ` reworked.completion `, to distinguish logic 3. Remove duplicate `weighter` GitOrigin-RevId: 3ae31e901ca93213deb31555766566325e79076d --- .../terminal/resources/META-INF/terminal.xml | 6 +--- ...nalCommandSpecCompletionContributorGen2.kt | 34 ++++++++++--------- 2 files changed, 19 insertions(+), 21 deletions(-) rename plugins/terminal/src/org/jetbrains/plugins/terminal/block/{ => reworked}/completion/TerminalCommandSpecCompletionContributorGen2.kt (91%) diff --git a/plugins/terminal/resources/META-INF/terminal.xml b/plugins/terminal/resources/META-INF/terminal.xml index ff4855966e03..e0940ba546ce 100644 --- a/plugins/terminal/resources/META-INF/terminal.xml +++ b/plugins/terminal/resources/META-INF/terminal.xml @@ -100,17 +100,13 @@ order="first, before terminalPowerShell, after ml_context"/> - List? = { commandName -> tracer.spanBuilder("terminal-completion-compute-completion-items").useWithScope { completion.computeCompletionItems(commandName, commandArguments) @@ -191,7 +193,7 @@ class TerminalCommandSpecCompletionContributorGen2 : CompletionContributor(), Du } // aliases generator does not requires actual typed prefix val dummyRuntimeContext = context.runtimeContextProvider.getContext("") - val aliases: Map = context.generatorsExecutor.execute(dummyRuntimeContext, aliasesGenerator()) + val aliases: Map = context.generatorsExecutor.execute(dummyRuntimeContext, ShellEnvBasedGenerators.aliasesGenerator()) val expandedTokens = expandAliases(tokens, aliases, context) return expandedTokens } @@ -224,9 +226,9 @@ class TerminalCommandSpecCompletionContributorGen2 : CompletionContributor(), Du } private fun ShellCompletionSuggestion.toLookupElement(shellType: ShellType): LookupElement { - val actualIcon = icon ?: findIconForSuggestion(name, type) + val actualIcon = icon ?: TerminalCompletionUtil.findIconForSuggestion(name, type) val realInsertValue = insertValue?.replace("{cursor}", "") - val nextSuggestions = getNextSuggestionsString(this).takeIf { it.isNotEmpty() } + val nextSuggestions = TerminalCompletionUtil.getNextSuggestionsString(this).takeIf { it.isNotEmpty() } val escapedInsertValue = StringUtil.escapeChar(realInsertValue ?: name, ' ') // Remove path separator from insert value, so there will be an exact match @@ -290,4 +292,4 @@ class TerminalCommandSpecCompletionContributorGen2 : CompletionContributor(), Du get() = parameters.editor.project!! } -} +} \ No newline at end of file