mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[terminal] Make command spec completion logic internal back
GitOrigin-RevId: a760ba3567fb8226d39e1ca1e3d14d950e4e5d81
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4ff5daa22c
commit
31b751fde6
+5
-5
@@ -6,7 +6,7 @@ import org.jetbrains.terminal.completion.ShellCommand
|
||||
import org.jetbrains.terminal.completion.ShellCommandParserDirectives
|
||||
import org.jetbrains.terminal.completion.ShellOption
|
||||
|
||||
abstract class CommandPartNode<T>(val text: String, open val spec: T?, val parent: CommandPartNode<*>?) {
|
||||
internal abstract class CommandPartNode<T>(val text: String, open val spec: T?, val parent: CommandPartNode<*>?) {
|
||||
val children: MutableList<CommandPartNode<*>> = mutableListOf()
|
||||
|
||||
override fun toString(): String {
|
||||
@@ -14,7 +14,7 @@ abstract class CommandPartNode<T>(val text: String, open val spec: T?, val paren
|
||||
}
|
||||
}
|
||||
|
||||
class SubcommandNode(text: String,
|
||||
internal class SubcommandNode(text: String,
|
||||
override val spec: ShellCommand,
|
||||
parent: CommandPartNode<*>?) : CommandPartNode<ShellCommand>(text, spec, parent) {
|
||||
fun getMergedParserDirectives(): ShellCommandParserDirectives {
|
||||
@@ -37,12 +37,12 @@ class SubcommandNode(text: String,
|
||||
}
|
||||
}
|
||||
|
||||
class OptionNode(text: String,
|
||||
internal class OptionNode(text: String,
|
||||
override val spec: ShellOption,
|
||||
parent: CommandPartNode<*>?) : CommandPartNode<ShellOption>(text, spec, parent)
|
||||
|
||||
class ArgumentNode(text: String,
|
||||
internal class ArgumentNode(text: String,
|
||||
override val spec: ShellArgument,
|
||||
parent: CommandPartNode<*>?) : CommandPartNode<ShellArgument>(text, spec, parent)
|
||||
|
||||
class UnknownNode(text: String, parent: CommandPartNode<*>?) : CommandPartNode<Any>(text, null, parent)
|
||||
internal class UnknownNode(text: String, parent: CommandPartNode<*>?) : CommandPartNode<Any>(text, null, parent)
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.intellij.terminal.completion
|
||||
|
||||
import org.jetbrains.terminal.completion.ShellArgument
|
||||
|
||||
object CommandSpecCompletionUtil {
|
||||
fun ShellArgument.isFilePath(): Boolean = isWithTemplate("filepaths")
|
||||
|
||||
fun ShellArgument.isFolder(): Boolean = isWithTemplate("folders")
|
||||
|
||||
private fun ShellArgument.isWithTemplate(template: String): Boolean {
|
||||
return templates.contains(template) || generators.any { it.templates.contains(template) }
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -7,7 +7,7 @@ import org.jetbrains.terminal.completion.BaseSuggestion
|
||||
import org.jetbrains.terminal.completion.ShellCommand
|
||||
import org.jetbrains.terminal.completion.ShellOption
|
||||
|
||||
class CommandTreeBuilder private constructor(
|
||||
internal class CommandTreeBuilder private constructor(
|
||||
private val suggestionsProvider: CommandTreeSuggestionsProvider,
|
||||
private val commandSpecManager: CommandSpecManager,
|
||||
private val arguments: List<String>
|
||||
|
||||
+3
-11
@@ -1,12 +1,14 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.terminal.completion
|
||||
|
||||
import com.intellij.terminal.completion.CommandSpecCompletionUtil.isFilePath
|
||||
import com.intellij.terminal.completion.CommandSpecCompletionUtil.isFolder
|
||||
import org.jetbrains.terminal.completion.BaseSuggestion
|
||||
import org.jetbrains.terminal.completion.ShellArgument
|
||||
import org.jetbrains.terminal.completion.ShellOption
|
||||
import org.jetbrains.terminal.completion.ShellSuggestion
|
||||
|
||||
class CommandTreeSuggestionsProvider(private val runtimeDataProvider: ShellRuntimeDataProvider) {
|
||||
internal class CommandTreeSuggestionsProvider(private val runtimeDataProvider: ShellRuntimeDataProvider) {
|
||||
suspend fun getSuggestionsOfNext(node: CommandPartNode<*>, nextNodeText: String): List<BaseSuggestion> {
|
||||
return when (node) {
|
||||
is SubcommandNode -> getSuggestionsForSubcommand(node, nextNodeText)
|
||||
@@ -134,14 +136,4 @@ class CommandTreeSuggestionsProvider(private val runtimeDataProvider: ShellRunti
|
||||
.let { if (basePath != ".") it.plus(ShellArgumentSuggestion(ShellSuggestion(names = listOf("")), arg)) else it }
|
||||
.toList()
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun ShellArgument.isFilePath(): Boolean = isWithTemplate("filepaths")
|
||||
|
||||
fun ShellArgument.isFolder(): Boolean = isWithTemplate("folders")
|
||||
|
||||
private fun ShellArgument.isWithTemplate(template: String): Boolean {
|
||||
return templates.contains(template) || generators.any { it.templates.contains(template) }
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -4,8 +4,8 @@ package org.jetbrains.plugins.terminal.exp.completion
|
||||
import com.intellij.codeInsight.completion.CompletionLocation
|
||||
import com.intellij.codeInsight.completion.CompletionWeigher
|
||||
import com.intellij.codeInsight.lookup.LookupElement
|
||||
import com.intellij.terminal.completion.CommandTreeSuggestionsProvider.Companion.isFilePath
|
||||
import com.intellij.terminal.completion.CommandTreeSuggestionsProvider.Companion.isFolder
|
||||
import com.intellij.terminal.completion.CommandSpecCompletionUtil.isFilePath
|
||||
import com.intellij.terminal.completion.CommandSpecCompletionUtil.isFolder
|
||||
import com.intellij.terminal.completion.ShellArgumentSuggestion
|
||||
import org.jetbrains.terminal.completion.BaseSuggestion
|
||||
import org.jetbrains.terminal.completion.ShellCommand
|
||||
|
||||
Reference in New Issue
Block a user