diff --git a/.idea/modules.xml b/.idea/modules.xml index cb4a78f94746..45907371f0c3 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -466,6 +466,8 @@ + + diff --git a/intellij.idea.community.main.iml b/intellij.idea.community.main.iml index 03b8577a5ab4..8924e68a4297 100644 --- a/intellij.idea.community.main.iml +++ b/intellij.idea.community.main.iml @@ -224,5 +224,7 @@ + + \ No newline at end of file diff --git a/java/java-terminal/intellij.java.terminal.iml b/java/java-terminal/intellij.java.terminal.iml new file mode 100644 index 000000000000..18ec07d2b627 --- /dev/null +++ b/java/java-terminal/intellij.java.terminal.iml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/java/java-terminal/intellij.java.terminal.tests.iml b/java/java-terminal/intellij.java.terminal.tests.iml new file mode 100644 index 000000000000..2cf1868b603b --- /dev/null +++ b/java/java-terminal/intellij.java.terminal.tests.iml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/java/java-terminal/resources/intellij.java.terminal.xml b/java/java-terminal/resources/intellij.java.terminal.xml new file mode 100644 index 000000000000..17cfa214c779 --- /dev/null +++ b/java/java-terminal/resources/intellij.java.terminal.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/java/java-terminal/resources/messages/JavaTerminalBundle.properties b/java/java-terminal/resources/messages/JavaTerminalBundle.properties new file mode 100644 index 000000000000..ef72b40b0547 --- /dev/null +++ b/java/java-terminal/resources/messages/JavaTerminalBundle.properties @@ -0,0 +1,2 @@ +java.command.terminal.description=Runs java +java.command.terminal.help.option.description=Prints help message \ No newline at end of file diff --git a/java/java-terminal/src/com/intellij/java/terminal/JavaShellCommandSpecsProvider.kt b/java/java-terminal/src/com/intellij/java/terminal/JavaShellCommandSpecsProvider.kt new file mode 100644 index 000000000000..c2fbda6a3015 --- /dev/null +++ b/java/java-terminal/src/com/intellij/java/terminal/JavaShellCommandSpecsProvider.kt @@ -0,0 +1,21 @@ +// 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.java.terminal + +import com.intellij.terminal.completion.spec.ShellCommandSpec +import org.jetbrains.plugins.terminal.block.completion.spec.ShellCommandSpec +import org.jetbrains.plugins.terminal.block.completion.spec.ShellCommandSpecConflictStrategy +import org.jetbrains.plugins.terminal.block.completion.spec.ShellCommandSpecInfo +import org.jetbrains.plugins.terminal.block.completion.spec.ShellCommandSpecsProvider + +class JavaShellCommandSpecsProvider : ShellCommandSpecsProvider { + override fun getCommandSpecs(): List { + return listOf(ShellCommandSpecInfo.create(getSpecs(), ShellCommandSpecConflictStrategy.REPLACE)) + } +} + +private fun getSpecs() : ShellCommandSpec = ShellCommandSpec("java") { + description(JavaTerminalBundle.message("java.command.terminal.description")) + option("--help", "-help", "-h") { + description(JavaTerminalBundle.message("java.command.terminal.help.option.description")) + } +} \ No newline at end of file diff --git a/java/java-terminal/src/com/intellij/java/terminal/JavaTerminalBundle.kt b/java/java-terminal/src/com/intellij/java/terminal/JavaTerminalBundle.kt new file mode 100644 index 000000000000..58bcf2ea8821 --- /dev/null +++ b/java/java-terminal/src/com/intellij/java/terminal/JavaTerminalBundle.kt @@ -0,0 +1,23 @@ +// 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.java.terminal + +import com.intellij.DynamicBundle +import org.jetbrains.annotations.Nls +import org.jetbrains.annotations.PropertyKey +import java.util.function.Supplier + +private const val BUNDLE: String = "messages.JavaTerminalBundle" + +object JavaTerminalBundle { + private val INSTANCE = DynamicBundle(JavaTerminalBundle::class.java, BUNDLE) + + @JvmStatic + fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any?): @Nls String { + return INSTANCE.getMessage(key = key, params = params) + } + + @JvmStatic + fun messagePointer(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any?): Supplier<@Nls String> { + return INSTANCE.getLazyMessage(key = key, params = params) + } +} \ No newline at end of file diff --git a/java/java-terminal/test/com/intellij/java/terminal/completion/JavaCommandCompletionTest.kt b/java/java-terminal/test/com/intellij/java/terminal/completion/JavaCommandCompletionTest.kt new file mode 100644 index 000000000000..437073e809a8 --- /dev/null +++ b/java/java-terminal/test/com/intellij/java/terminal/completion/JavaCommandCompletionTest.kt @@ -0,0 +1,20 @@ +// 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.java.terminal.completion + +import com.intellij.terminal.completion.spec.ShellCompletionSuggestion +import com.intellij.testFramework.fixtures.BasePlatformTestCase +import kotlinx.coroutines.runBlocking +import org.jetbrains.plugins.terminal.block.util.ShellCompletionTestFixture +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 + +@RunWith(JUnit4::class) +class JavaCommandCompletionTest : BasePlatformTestCase() { + @Test + fun runCustomTest() = runBlocking { + val fixture = ShellCompletionTestFixture.builder(project).build() + val actual: List = fixture.getCompletions("java ") + assertSameElements(actual.map { it.name }, listOf("--help", "-help", "-h")) + } +} \ No newline at end of file diff --git a/java/plugin/plugin-content.yaml b/java/plugin/plugin-content.yaml index 81288744e448..dd17e530a078 100644 --- a/java/plugin/plugin-content.yaml +++ b/java/plugin/plugin-content.yaml @@ -68,6 +68,7 @@ contentModules: - name: intellij.java.performancePlugin - name: intellij.java.compiler.charts + - name: intellij.java.terminal - name: lib/javac2.jar modules: - name: intellij.java.compiler.antTasks diff --git a/java/plugin/resources/META-INF/plugin.xml b/java/plugin/resources/META-INF/plugin.xml index 4ce5be55c713..e7608290a4f5 100644 --- a/java/plugin/resources/META-INF/plugin.xml +++ b/java/plugin/resources/META-INF/plugin.xml @@ -38,6 +38,7 @@ + com.intellij.modules.remoteServers diff --git a/platform/build-scripts/src/org/jetbrains/intellij/build/JavaPluginLayout.kt b/platform/build-scripts/src/org/jetbrains/intellij/build/JavaPluginLayout.kt index ca824f2ab485..75ce141a0050 100644 --- a/platform/build-scripts/src/org/jetbrains/intellij/build/JavaPluginLayout.kt +++ b/platform/build-scripts/src/org/jetbrains/intellij/build/JavaPluginLayout.kt @@ -60,6 +60,7 @@ object JavaPluginLayout { spec.withModules(listOf( "intellij.java.compiler.impl", "intellij.java.debugger.impl", + "intellij.java.terminal", "intellij.java.debugger.memory.agent", "intellij.java.execution.impl", "intellij.java.ui",