From e95af7e14188a669f63d134f728ec4dbcd9b5544 Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Mon, 8 Jan 2024 18:45:01 +0100 Subject: [PATCH] Move commandInterface to the separate module: towards v2 refactoring GitOrigin-RevId: 18dcc57922878c8ad1fe0bb6be85097d4d81cc34 --- .idea/modules.xml | 3 +- .idea/vcs.xml | 3 +- commandInterface/README.txt | 1 + .../commandLine/CommandLineElementTypes.java | 4 +- .../commandLine/CommandLineParser.java | 6 +- .../commandLine/_CommandLineLexer.flex | 62 +++++++++++++++++++ .../commandLine/_CommandLineLexer.java | 6 +- .../commandLine/psi/CommandLineArgument.java | 22 +++---- .../commandLine/psi/CommandLineCommand.java | 4 +- .../commandLine/psi/CommandLineOption.java | 16 ++--- .../commandLine/psi/CommandLineVisitor.java | 4 +- .../psi/impl/CommandLineArgumentImpl.java | 32 +++++----- .../psi/impl/CommandLineCommandImpl.java | 10 +-- .../psi/impl/CommandLineOptionImpl.java | 26 ++++---- .../intellij.commandInterface.iml | 17 +++++ .../src/META-INF/command-line-plugin.xml | 26 ++++++++ .../CommandInterfaceBundle.kt | 23 +++++++ .../CommandInterfaceBundle.properties | 6 ++ .../commandInterface/command/Argument.java | 18 +----- .../command/ArgumentType.java | 17 +++++ .../command/ArgumentsInfo.java | 18 +----- .../commandInterface/command/Command.java | 18 +----- .../command/CommandExecutor.java | 18 +----- .../commandInterface/command/Help.java | 18 +----- .../command/KnownArgumentsInfo.java | 21 +------ .../command/NoArgumentsInfo.java | 27 ++++++++ .../commandInterface/command/Option.java | 22 +------ .../command/SimpleCommand.java | 18 +----- .../command/UnknownArgumentsInfo.java | 18 +----- .../command/package-info.java | 13 ++++ .../CommandLineArgumentReference.java | 26 ++------ .../CommandLineCommandReference.java | 26 ++------ .../CommandLineDocumentationProvider.java | 22 +++---- .../commandLine/CommandLineElement.java | 22 ++----- .../CommandLineElementManipulator.java | 21 +++++++ .../CommandLineElementReference.java | 22 ++----- .../commandLine/CommandLineElementType.java | 17 +++++ .../commandLine/CommandLineFileType.java | 18 +----- .../commandLine/CommandLineInspection.java | 32 +++------- .../commandLine/CommandLineLanguage.java | 25 ++++++++ .../CommandLineOptionReference.java | 22 ++----- .../CommandLineParserDefinition.java | 10 +-- .../commandLine/CommandLineParserUtil.java | 22 ++----- .../commandLine/CommandLinePart.java | 27 ++++++++ .../CommandLineReferenceContributor.java | 20 +----- .../CommandLineSyntaxHighlighter.java | 6 +- .../commandLine/LookupWithIndentsBuilder.java | 18 +----- .../commandLine/ValidationResult.java | 26 ++------ .../commandLine/command_line.bnf | 20 +++--- .../commandLine/package-info.java | 27 ++++++++ .../commandLine/psi/CommandLineFile.java | 29 +++------ .../commandLine/psi/ValidationResultImpl.java | 29 +++------ .../psi/impl/CommandLinePsiImplUtils.java | 38 ++++-------- .../commandLine/psi/impl/package-info.java | 10 +++ .../commandLine/psi/package-info.java | 9 +++ .../commandInterface/package-info.java | 41 ++++++++++++ .../python/PythonCommunityPluginModules.kt | 1 + python/intellij.python.community.impl.iml | 1 + .../messages/PyBundle.properties | 7 --- python/src/META-INF/command-line-plugin.xml | 26 -------- .../ArgumentHintLayer.java | 24 ++----- .../CommandConsole.java | 8 +-- .../CommandLineConsoleApi.kt | 22 ++----- .../CommandModeConsumer.java | 26 ++------ .../ConsoleStopProcessAction.java | 4 +- .../ConsoleWithProcess.java | 4 +- .../PanelWithActions.java | 4 +- .../ProcessModeConsumer.java | 18 +----- .../commandInterfaceConsole/package-info.java | 20 ++++++ .../command/ArgumentType.java | 31 ---------- .../command/NoArgumentsInfo.java | 41 ------------ .../command/package-info.java | 27 -------- .../CommandLineElementManipulator.java | 35 ----------- .../commandLine/CommandLineElementType.java | 31 ---------- .../commandLine/CommandLineLanguage.java | 39 ------------ .../commandLine/CommandLinePart.java | 41 ------------ .../commandLine/_CommandLineLexer.flex | 62 ------------------- .../commandLine/package-info.java | 39 ------------ .../commandLine/psi/impl/package-info.java | 24 ------- .../commandLine/psi/package-info.java | 23 ------- .../console/package-info.java | 34 ---------- .../commandInterface/package-info.java | 55 ---------------- .../commandLine/CommandLineArgsTest.java | 22 ++----- .../CommandLineInspectionTest.java | 20 +----- .../commandLine/CommandLineParserTest.java | 22 ++----- .../CommandLineSuggestionTest.java | 2 +- .../commandLine/CommandTestTools.java | 26 ++------ .../env/CommandBasedProcessRunner.java | 6 +- .../intellij.python.community.tests.iml | 1 + 89 files changed, 636 insertions(+), 1192 deletions(-) create mode 100644 commandInterface/README.txt rename {python/gen/com/jetbrains => commandInterface/gen/com/intellij}/commandInterface/commandLine/CommandLineElementTypes.java (94%) rename {python/gen/com/jetbrains => commandInterface/gen/com/intellij}/commandInterface/commandLine/CommandLineParser.java (96%) create mode 100644 commandInterface/gen/com/intellij/commandInterface/commandLine/_CommandLineLexer.flex rename {python/gen/com/jetbrains => commandInterface/gen/com/intellij}/commandInterface/commandLine/_CommandLineLexer.java (99%) rename {python/gen/com/jetbrains => commandInterface/gen/com/intellij}/commandInterface/commandLine/psi/CommandLineArgument.java (63%) rename {python/gen/com/jetbrains => commandInterface/gen/com/intellij}/commandInterface/commandLine/psi/CommandLineCommand.java (69%) rename {python/gen/com/jetbrains => commandInterface/gen/com/intellij}/commandInterface/commandLine/psi/CommandLineOption.java (52%) rename {python/gen/com/jetbrains => commandInterface/gen/com/intellij}/commandInterface/commandLine/psi/CommandLineVisitor.java (84%) rename {python/gen/com/jetbrains => commandInterface/gen/com/intellij}/commandInterface/commandLine/psi/impl/CommandLineArgumentImpl.java (75%) rename {python/gen/com/jetbrains => commandInterface/gen/com/intellij}/commandInterface/commandLine/psi/impl/CommandLineCommandImpl.java (71%) rename {python/gen/com/jetbrains => commandInterface/gen/com/intellij}/commandInterface/commandLine/psi/impl/CommandLineOptionImpl.java (67%) create mode 100644 commandInterface/intellij.commandInterface.iml create mode 100644 commandInterface/src/META-INF/command-line-plugin.xml create mode 100644 commandInterface/src/com/intellij/commandInterface/CommandInterfaceBundle.kt create mode 100644 commandInterface/src/com/intellij/commandInterface/CommandInterfaceBundle.properties rename {python/src/com/jetbrains => commandInterface/src/com/intellij}/commandInterface/command/Argument.java (87%) create mode 100644 commandInterface/src/com/intellij/commandInterface/command/ArgumentType.java rename {python/src/com/jetbrains => commandInterface/src/com/intellij}/commandInterface/command/ArgumentsInfo.java (56%) rename {python/src/com/jetbrains => commandInterface/src/com/intellij}/commandInterface/command/Command.java (60%) rename {python/src/com/jetbrains => commandInterface/src/com/intellij}/commandInterface/command/CommandExecutor.java (63%) rename {python/src/com/jetbrains => commandInterface/src/com/intellij}/commandInterface/command/Help.java (62%) rename {python/src/com/jetbrains => commandInterface/src/com/intellij}/commandInterface/command/KnownArgumentsInfo.java (82%) create mode 100644 commandInterface/src/com/intellij/commandInterface/command/NoArgumentsInfo.java rename {python/src/com/jetbrains => commandInterface/src/com/intellij}/commandInterface/command/Option.java (73%) rename {python/src/com/jetbrains => commandInterface/src/com/intellij}/commandInterface/command/SimpleCommand.java (84%) rename {python/src/com/jetbrains => commandInterface/src/com/intellij}/commandInterface/command/UnknownArgumentsInfo.java (53%) create mode 100644 commandInterface/src/com/intellij/commandInterface/command/package-info.java rename {python/src/com/jetbrains => commandInterface/src/com/intellij}/commandInterface/commandLine/CommandLineArgumentReference.java (67%) rename {python/src/com/jetbrains => commandInterface/src/com/intellij}/commandInterface/commandLine/CommandLineCommandReference.java (58%) rename {python/src/com/jetbrains => commandInterface/src/com/intellij}/commandInterface/commandLine/CommandLineDocumentationProvider.java (82%) rename {python/src/com/jetbrains => commandInterface/src/com/intellij}/commandInterface/commandLine/CommandLineElement.java (61%) create mode 100644 commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineElementManipulator.java rename {python/src/com/jetbrains => commandInterface/src/com/intellij}/commandInterface/commandLine/CommandLineElementReference.java (61%) create mode 100644 commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineElementType.java rename {python/src/com/jetbrains => commandInterface/src/com/intellij}/commandInterface/commandLine/CommandLineFileType.java (56%) rename {python/src/com/jetbrains => commandInterface/src/com/intellij}/commandInterface/commandLine/CommandLineInspection.java (69%) create mode 100644 commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineLanguage.java rename {python/src/com/jetbrains => commandInterface/src/com/intellij}/commandInterface/commandLine/CommandLineOptionReference.java (62%) rename {python/src/com/jetbrains => commandInterface/src/com/intellij}/commandInterface/commandLine/CommandLineParserDefinition.java (80%) rename {python/src/com/jetbrains => commandInterface/src/com/intellij}/commandInterface/commandLine/CommandLineParserUtil.java (60%) create mode 100644 commandInterface/src/com/intellij/commandInterface/commandLine/CommandLinePart.java rename {python/src/com/jetbrains => commandInterface/src/com/intellij}/commandInterface/commandLine/CommandLineReferenceContributor.java (67%) rename {python/src/com/jetbrains => commandInterface/src/com/intellij}/commandInterface/commandLine/CommandLineSyntaxHighlighter.java (85%) rename {python/src/com/jetbrains => commandInterface/src/com/intellij}/commandInterface/commandLine/LookupWithIndentsBuilder.java (86%) rename {python/src/com/jetbrains => commandInterface/src/com/intellij}/commandInterface/commandLine/ValidationResult.java (66%) rename {python/src/com/jetbrains => commandInterface/src/com/intellij}/commandInterface/commandLine/command_line.bnf (74%) create mode 100644 commandInterface/src/com/intellij/commandInterface/commandLine/package-info.java rename {python/src/com/jetbrains => commandInterface/src/com/intellij}/commandInterface/commandLine/psi/CommandLineFile.java (76%) rename {python/src/com/jetbrains => commandInterface/src/com/intellij}/commandInterface/commandLine/psi/ValidationResultImpl.java (88%) rename {python/src/com/jetbrains => commandInterface/src/com/intellij}/commandInterface/commandLine/psi/impl/CommandLinePsiImplUtils.java (78%) create mode 100644 commandInterface/src/com/intellij/commandInterface/commandLine/psi/impl/package-info.java create mode 100644 commandInterface/src/com/intellij/commandInterface/commandLine/psi/package-info.java create mode 100644 commandInterface/src/com/intellij/commandInterface/package-info.java delete mode 100644 python/src/META-INF/command-line-plugin.xml rename python/src/com/{jetbrains/commandInterface/console => intellij/python/community/impl/commandInterfaceConsole}/ArgumentHintLayer.java (81%) rename python/src/com/{jetbrains/commandInterface/console => intellij/python/community/impl/commandInterfaceConsole}/CommandConsole.java (97%) rename python/src/com/{jetbrains/commandInterface/console => intellij/python/community/impl/commandInterfaceConsole}/CommandLineConsoleApi.kt (86%) rename python/src/com/{jetbrains/commandInterface/console => intellij/python/community/impl/commandInterfaceConsole}/CommandModeConsumer.java (78%) rename python/src/com/{jetbrains/commandInterface/console => intellij/python/community/impl/commandInterfaceConsole}/ConsoleStopProcessAction.java (89%) rename python/src/com/{jetbrains/commandInterface/console => intellij/python/community/impl/commandInterfaceConsole}/ConsoleWithProcess.java (83%) rename python/src/com/{jetbrains/commandInterface/console => intellij/python/community/impl/commandInterfaceConsole}/PanelWithActions.java (97%) rename python/src/com/{jetbrains/commandInterface/console => intellij/python/community/impl/commandInterfaceConsole}/ProcessModeConsumer.java (53%) create mode 100644 python/src/com/intellij/python/community/impl/commandInterfaceConsole/package-info.java delete mode 100644 python/src/com/jetbrains/commandInterface/command/ArgumentType.java delete mode 100644 python/src/com/jetbrains/commandInterface/command/NoArgumentsInfo.java delete mode 100644 python/src/com/jetbrains/commandInterface/command/package-info.java delete mode 100644 python/src/com/jetbrains/commandInterface/commandLine/CommandLineElementManipulator.java delete mode 100644 python/src/com/jetbrains/commandInterface/commandLine/CommandLineElementType.java delete mode 100644 python/src/com/jetbrains/commandInterface/commandLine/CommandLineLanguage.java delete mode 100644 python/src/com/jetbrains/commandInterface/commandLine/CommandLinePart.java delete mode 100644 python/src/com/jetbrains/commandInterface/commandLine/_CommandLineLexer.flex delete mode 100644 python/src/com/jetbrains/commandInterface/commandLine/package-info.java delete mode 100644 python/src/com/jetbrains/commandInterface/commandLine/psi/impl/package-info.java delete mode 100644 python/src/com/jetbrains/commandInterface/commandLine/psi/package-info.java delete mode 100644 python/src/com/jetbrains/commandInterface/console/package-info.java delete mode 100644 python/src/com/jetbrains/commandInterface/package-info.java rename python/testSrc/com/{jetbrains => intellij}/commandInterface/commandLine/CommandLineArgsTest.java (73%) rename python/testSrc/com/{jetbrains => intellij}/commandInterface/commandLine/CommandLineInspectionTest.java (65%) rename python/testSrc/com/{jetbrains => intellij}/commandInterface/commandLine/CommandLineParserTest.java (61%) rename python/testSrc/com/{jetbrains => intellij}/commandInterface/commandLine/CommandLineSuggestionTest.java (97%) rename python/testSrc/com/{jetbrains => intellij}/commandInterface/commandLine/CommandTestTools.java (77%) diff --git a/.idea/modules.xml b/.idea/modules.xml index b84c222b4753..7e0d7e6ab48c 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -629,6 +629,7 @@ + @@ -1480,4 +1481,4 @@ - + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index ac254a0bf48c..e6cfac1544ec 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -51,6 +51,7 @@ + - + \ No newline at end of file diff --git a/commandInterface/README.txt b/commandInterface/README.txt new file mode 100644 index 000000000000..0510c96be591 --- /dev/null +++ b/commandInterface/README.txt @@ -0,0 +1 @@ +Language for command-line commands and arguments POSIX with GNU extensions \ No newline at end of file diff --git a/python/gen/com/jetbrains/commandInterface/commandLine/CommandLineElementTypes.java b/commandInterface/gen/com/intellij/commandInterface/commandLine/CommandLineElementTypes.java similarity index 94% rename from python/gen/com/jetbrains/commandInterface/commandLine/CommandLineElementTypes.java rename to commandInterface/gen/com/intellij/commandInterface/commandLine/CommandLineElementTypes.java index 53c787aa4c99..9a2238a79aaa 100644 --- a/python/gen/com/jetbrains/commandInterface/commandLine/CommandLineElementTypes.java +++ b/commandInterface/gen/com/intellij/commandInterface/commandLine/CommandLineElementTypes.java @@ -1,10 +1,10 @@ // This is a generated file. Not intended for manual editing. -package com.jetbrains.commandInterface.commandLine; +package com.intellij.commandInterface.commandLine; import com.intellij.psi.tree.IElementType; import com.intellij.psi.PsiElement; import com.intellij.lang.ASTNode; -import com.jetbrains.commandInterface.commandLine.psi.impl.*; +import com.intellij.commandInterface.commandLine.psi.impl.*; public interface CommandLineElementTypes { diff --git a/python/gen/com/jetbrains/commandInterface/commandLine/CommandLineParser.java b/commandInterface/gen/com/intellij/commandInterface/commandLine/CommandLineParser.java similarity index 96% rename from python/gen/com/jetbrains/commandInterface/commandLine/CommandLineParser.java rename to commandInterface/gen/com/intellij/commandInterface/commandLine/CommandLineParser.java index 4079f9507994..4eb1cd1af3c5 100644 --- a/python/gen/com/jetbrains/commandInterface/commandLine/CommandLineParser.java +++ b/commandInterface/gen/com/intellij/commandInterface/commandLine/CommandLineParser.java @@ -1,10 +1,10 @@ // This is a generated file. Not intended for manual editing. -package com.jetbrains.commandInterface.commandLine; +package com.intellij.commandInterface.commandLine; import com.intellij.lang.PsiBuilder; import com.intellij.lang.PsiBuilder.Marker; -import static com.jetbrains.commandInterface.commandLine.CommandLineElementTypes.*; -import static com.jetbrains.commandInterface.commandLine.CommandLineParserUtil.*; +import static com.intellij.commandInterface.commandLine.CommandLineElementTypes.*; +import static com.intellij.commandInterface.commandLine.CommandLineParserUtil.*; import com.intellij.psi.tree.IElementType; import com.intellij.lang.ASTNode; import com.intellij.psi.tree.TokenSet; diff --git a/commandInterface/gen/com/intellij/commandInterface/commandLine/_CommandLineLexer.flex b/commandInterface/gen/com/intellij/commandInterface/commandLine/_CommandLineLexer.flex new file mode 100644 index 000000000000..8cb9ae254a03 --- /dev/null +++ b/commandInterface/gen/com/intellij/commandInterface/commandLine/_CommandLineLexer.flex @@ -0,0 +1,62 @@ +package com.intellij.commandInterface.commandLine; + +import com.intellij.lexer.FlexLexer; +import com.intellij.psi.tree.IElementType; + +import static com.intellij.psi.TokenType.BAD_CHARACTER; +import static com.intellij.psi.TokenType.WHITE_SPACE; +import static com.intellij.commandInterface.commandLine.CommandLineElementTypes.*; + +%% + +%{ + public _CommandLineLexer() { + this((java.io.Reader)null); + } +%} + +%public +%class _CommandLineLexer +%implements FlexLexer +%function advance +%type IElementType +%unicode + +EOL=\R +WHITE_SPACE=\s+ + +SPACE=[ \t\n\x0B\f\r]+ +LITERAL_STARTS_FROM_LETTER=[:letter:]([a-zA-Z_0-9]|:|\\|"/"|\.|-|\!|\*)* +LITERAL_STARTS_FROM_DIGIT=[:digit:]([a-zA-Z_0-9]|:|\\|"/"|\.|-|\!|\*)* +LITERAL_STARTS_FROM_SYMBOL=([/\~\.!*]([a-zA-Z_0-9]|:|\\|"/"|\.|-|\!|\*)*) +SPACED_LITERAL_STARTS_FROM_LETTER=\"[:letter:]([a-zA-Z_0-9]|:|\\|"/"|\.|-|[ \t\n\x0B\f\r]|\!|\*)*\" +SPACED_LITERAL_STARTS_FROM_DIGIT=\"[:digit:]([a-zA-Z_0-9]|:|\\|"/"|\.|-|[ \t\n\x0B\f\r]|\!|\*)*\" +SPACED_LITERAL_STARTS_FROM_SYMBOL=\"([/\~\.!*]([a-zA-Z_0-9]|:|\\|"/"|\.|-|[ \t\n\x0B\f\r]|\!|\*)*)\" +SINGLE_Q_SPACED_LITERAL_STARTS_FROM_LETTER='[:letter:]([a-zA-Z_0-9]|:|\\|"/"|\.|-|[ \t\n\x0B\f\r]|\!|\*)*' +SINGLE_Q_SPACED_LITERAL_STARTS_FROM_DIGIT='[:digit:]([a-zA-Z_0-9]|:|\\|"/"|\.|-|[ \t\n\x0B\f\r]|\!|\*)*' +SINGLE_Q_SPACED_LITERAL_STARTS_FROM_SYMBOL='([/\~\.!*]([a-zA-Z_0-9]|:|\\|"/"|\.|-|[ \t\n\x0B\f\r]|\!|\*)*)' +SHORT_OPTION_NAME_TOKEN=-[:letter:] +LONG_OPTION_NAME_TOKEN=--[:letter:](-|[a-zA-Z_0-9])* + +%% + { + {WHITE_SPACE} { return WHITE_SPACE; } + + "=" { return EQ; } + + {SPACE} { return SPACE; } + {LITERAL_STARTS_FROM_LETTER} { return LITERAL_STARTS_FROM_LETTER; } + {LITERAL_STARTS_FROM_DIGIT} { return LITERAL_STARTS_FROM_DIGIT; } + {LITERAL_STARTS_FROM_SYMBOL} { return LITERAL_STARTS_FROM_SYMBOL; } + {SPACED_LITERAL_STARTS_FROM_LETTER} { return SPACED_LITERAL_STARTS_FROM_LETTER; } + {SPACED_LITERAL_STARTS_FROM_DIGIT} { return SPACED_LITERAL_STARTS_FROM_DIGIT; } + {SPACED_LITERAL_STARTS_FROM_SYMBOL} { return SPACED_LITERAL_STARTS_FROM_SYMBOL; } + {SINGLE_Q_SPACED_LITERAL_STARTS_FROM_LETTER} { return SINGLE_Q_SPACED_LITERAL_STARTS_FROM_LETTER; } + {SINGLE_Q_SPACED_LITERAL_STARTS_FROM_DIGIT} { return SINGLE_Q_SPACED_LITERAL_STARTS_FROM_DIGIT; } + {SINGLE_Q_SPACED_LITERAL_STARTS_FROM_SYMBOL} { return SINGLE_Q_SPACED_LITERAL_STARTS_FROM_SYMBOL; } + {SHORT_OPTION_NAME_TOKEN} { return SHORT_OPTION_NAME_TOKEN; } + {LONG_OPTION_NAME_TOKEN} { return LONG_OPTION_NAME_TOKEN; } + +} + +[^] { return BAD_CHARACTER; } diff --git a/python/gen/com/jetbrains/commandInterface/commandLine/_CommandLineLexer.java b/commandInterface/gen/com/intellij/commandInterface/commandLine/_CommandLineLexer.java similarity index 99% rename from python/gen/com/jetbrains/commandInterface/commandLine/_CommandLineLexer.java rename to commandInterface/gen/com/intellij/commandInterface/commandLine/_CommandLineLexer.java index 0f3a52dc0761..d93b505a7a8a 100644 --- a/python/gen/com/jetbrains/commandInterface/commandLine/_CommandLineLexer.java +++ b/commandInterface/gen/com/intellij/commandInterface/commandLine/_CommandLineLexer.java @@ -1,16 +1,14 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. - // Generated by JFlex 1.9.1 http://jflex.de/ (tweaked for IntelliJ platform) // source: _CommandLineLexer.flex -package com.jetbrains.commandInterface.commandLine; +package com.intellij.commandInterface.commandLine; import com.intellij.lexer.FlexLexer; import com.intellij.psi.tree.IElementType; import static com.intellij.psi.TokenType.BAD_CHARACTER; import static com.intellij.psi.TokenType.WHITE_SPACE; -import static com.jetbrains.commandInterface.commandLine.CommandLineElementTypes.*; +import static com.intellij.commandInterface.commandLine.CommandLineElementTypes.*; public class _CommandLineLexer implements FlexLexer { diff --git a/python/gen/com/jetbrains/commandInterface/commandLine/psi/CommandLineArgument.java b/commandInterface/gen/com/intellij/commandInterface/commandLine/psi/CommandLineArgument.java similarity index 63% rename from python/gen/com/jetbrains/commandInterface/commandLine/psi/CommandLineArgument.java rename to commandInterface/gen/com/intellij/commandInterface/commandLine/psi/CommandLineArgument.java index 64f043d0bb0f..cb9ef4c5e317 100644 --- a/python/gen/com/jetbrains/commandInterface/commandLine/psi/CommandLineArgument.java +++ b/commandInterface/gen/com/intellij/commandInterface/commandLine/psi/CommandLineArgument.java @@ -1,13 +1,13 @@ // This is a generated file. Not intended for manual editing. -package com.jetbrains.commandInterface.commandLine.psi; +package com.intellij.commandInterface.commandLine.psi; import java.util.List; import org.jetbrains.annotations.*; import com.intellij.psi.PsiElement; -import com.jetbrains.commandInterface.commandLine.CommandLinePart; -import com.jetbrains.commandInterface.command.Argument; -import com.jetbrains.commandInterface.command.Help; -import com.jetbrains.commandInterface.command.Option; +import com.intellij.commandInterface.commandLine.CommandLinePart; +import com.intellij.commandInterface.command.Argument; +import com.intellij.commandInterface.command.Help; +import com.intellij.commandInterface.command.Option; public interface CommandLineArgument extends CommandLinePart { @@ -38,16 +38,12 @@ public interface CommandLineArgument extends CommandLinePart { @Nullable PsiElement getSpacedLiteralStartsFromSymbol(); - @Nullable - Option findOptionForOptionArgument(); + @Nullable Option findOptionForOptionArgument(); - @Nullable - Argument findRealArgument(); + @Nullable Argument findRealArgument(); - @Nullable - Help findBestHelp(); + @Nullable Help findBestHelp(); - @NotNull - String getValueNoQuotes(); + @NotNull String getValueNoQuotes(); } diff --git a/python/gen/com/jetbrains/commandInterface/commandLine/psi/CommandLineCommand.java b/commandInterface/gen/com/intellij/commandInterface/commandLine/psi/CommandLineCommand.java similarity index 69% rename from python/gen/com/jetbrains/commandInterface/commandLine/psi/CommandLineCommand.java rename to commandInterface/gen/com/intellij/commandInterface/commandLine/psi/CommandLineCommand.java index 3e925f19591c..4a4571649869 100644 --- a/python/gen/com/jetbrains/commandInterface/commandLine/psi/CommandLineCommand.java +++ b/commandInterface/gen/com/intellij/commandInterface/commandLine/psi/CommandLineCommand.java @@ -1,10 +1,10 @@ // This is a generated file. Not intended for manual editing. -package com.jetbrains.commandInterface.commandLine.psi; +package com.intellij.commandInterface.commandLine.psi; import java.util.List; import org.jetbrains.annotations.*; import com.intellij.psi.PsiElement; -import com.jetbrains.commandInterface.commandLine.CommandLinePart; +import com.intellij.commandInterface.commandLine.CommandLinePart; public interface CommandLineCommand extends CommandLinePart { diff --git a/python/gen/com/jetbrains/commandInterface/commandLine/psi/CommandLineOption.java b/commandInterface/gen/com/intellij/commandInterface/commandLine/psi/CommandLineOption.java similarity index 52% rename from python/gen/com/jetbrains/commandInterface/commandLine/psi/CommandLineOption.java rename to commandInterface/gen/com/intellij/commandInterface/commandLine/psi/CommandLineOption.java index b5e691ce3584..2d9569a01f11 100644 --- a/python/gen/com/jetbrains/commandInterface/commandLine/psi/CommandLineOption.java +++ b/commandInterface/gen/com/intellij/commandInterface/commandLine/psi/CommandLineOption.java @@ -1,11 +1,11 @@ // This is a generated file. Not intended for manual editing. -package com.jetbrains.commandInterface.commandLine.psi; +package com.intellij.commandInterface.commandLine.psi; import java.util.List; import org.jetbrains.annotations.*; import com.intellij.psi.PsiElement; -import com.jetbrains.commandInterface.commandLine.CommandLinePart; -import com.jetbrains.commandInterface.command.Option; +import com.intellij.commandInterface.commandLine.CommandLinePart; +import com.intellij.commandInterface.command.Option; public interface CommandLineOption extends CommandLinePart { @@ -15,16 +15,12 @@ public interface CommandLineOption extends CommandLinePart { @Nullable PsiElement getShortOptionNameToken(); - @Nullable - @NonNls - String getOptionName(); + @Nullable @NonNls String getOptionName(); boolean isLong(); - @Nullable - Option findRealOption(); + @Nullable Option findRealOption(); - @Nullable - CommandLineArgument findArgument(); + @Nullable CommandLineArgument findArgument(); } diff --git a/python/gen/com/jetbrains/commandInterface/commandLine/psi/CommandLineVisitor.java b/commandInterface/gen/com/intellij/commandInterface/commandLine/psi/CommandLineVisitor.java similarity index 84% rename from python/gen/com/jetbrains/commandInterface/commandLine/psi/CommandLineVisitor.java rename to commandInterface/gen/com/intellij/commandInterface/commandLine/psi/CommandLineVisitor.java index b0bf2caa071c..7b8246761fab 100644 --- a/python/gen/com/jetbrains/commandInterface/commandLine/psi/CommandLineVisitor.java +++ b/commandInterface/gen/com/intellij/commandInterface/commandLine/psi/CommandLineVisitor.java @@ -1,10 +1,10 @@ // This is a generated file. Not intended for manual editing. -package com.jetbrains.commandInterface.commandLine.psi; +package com.intellij.commandInterface.commandLine.psi; import org.jetbrains.annotations.*; import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.PsiElement; -import com.jetbrains.commandInterface.commandLine.CommandLinePart; +import com.intellij.commandInterface.commandLine.CommandLinePart; public class CommandLineVisitor extends PsiElementVisitor { diff --git a/python/gen/com/jetbrains/commandInterface/commandLine/psi/impl/CommandLineArgumentImpl.java b/commandInterface/gen/com/intellij/commandInterface/commandLine/psi/impl/CommandLineArgumentImpl.java similarity index 75% rename from python/gen/com/jetbrains/commandInterface/commandLine/psi/impl/CommandLineArgumentImpl.java rename to commandInterface/gen/com/intellij/commandInterface/commandLine/psi/impl/CommandLineArgumentImpl.java index 37ac99fb7bcf..99aa1cc97f20 100644 --- a/python/gen/com/jetbrains/commandInterface/commandLine/psi/impl/CommandLineArgumentImpl.java +++ b/commandInterface/gen/com/intellij/commandInterface/commandLine/psi/impl/CommandLineArgumentImpl.java @@ -1,5 +1,5 @@ // This is a generated file. Not intended for manual editing. -package com.jetbrains.commandInterface.commandLine.psi.impl; +package com.intellij.commandInterface.commandLine.psi.impl; import java.util.List; import org.jetbrains.annotations.*; @@ -7,16 +7,16 @@ import com.intellij.lang.ASTNode; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.util.PsiTreeUtil; -import static com.jetbrains.commandInterface.commandLine.CommandLineElementTypes.*; -import com.jetbrains.commandInterface.commandLine.CommandLineElement; -import com.jetbrains.commandInterface.commandLine.psi.*; -import com.jetbrains.commandInterface.command.Argument; -import com.jetbrains.commandInterface.command.Help; -import com.jetbrains.commandInterface.command.Option; +import static com.intellij.commandInterface.commandLine.CommandLineElementTypes.*; +import com.intellij.commandInterface.commandLine.CommandLineElement; +import com.intellij.commandInterface.commandLine.psi.*; +import com.intellij.commandInterface.command.Argument; +import com.intellij.commandInterface.command.Help; +import com.intellij.commandInterface.command.Option; public class CommandLineArgumentImpl extends CommandLineElement implements CommandLineArgument { - public CommandLineArgumentImpl(ASTNode node) { + public CommandLineArgumentImpl(@NotNull ASTNode node) { super(node); } @@ -84,23 +84,23 @@ public class CommandLineArgumentImpl extends CommandLineElement implements Comma return findChildByType(SPACED_LITERAL_STARTS_FROM_SYMBOL); } - @Nullable - public Option findOptionForOptionArgument() { + @Override + public @Nullable Option findOptionForOptionArgument() { return CommandLinePsiImplUtils.findOptionForOptionArgument(this); } - @Nullable - public Argument findRealArgument() { + @Override + public @Nullable Argument findRealArgument() { return CommandLinePsiImplUtils.findRealArgument(this); } - @Nullable - public Help findBestHelp() { + @Override + public @Nullable Help findBestHelp() { return CommandLinePsiImplUtils.findBestHelp(this); } - @NotNull - public String getValueNoQuotes() { + @Override + public @NotNull String getValueNoQuotes() { return CommandLinePsiImplUtils.getValueNoQuotes(this); } diff --git a/python/gen/com/jetbrains/commandInterface/commandLine/psi/impl/CommandLineCommandImpl.java b/commandInterface/gen/com/intellij/commandInterface/commandLine/psi/impl/CommandLineCommandImpl.java similarity index 71% rename from python/gen/com/jetbrains/commandInterface/commandLine/psi/impl/CommandLineCommandImpl.java rename to commandInterface/gen/com/intellij/commandInterface/commandLine/psi/impl/CommandLineCommandImpl.java index c67c862d8c08..592a38e49db6 100644 --- a/python/gen/com/jetbrains/commandInterface/commandLine/psi/impl/CommandLineCommandImpl.java +++ b/commandInterface/gen/com/intellij/commandInterface/commandLine/psi/impl/CommandLineCommandImpl.java @@ -1,5 +1,5 @@ // This is a generated file. Not intended for manual editing. -package com.jetbrains.commandInterface.commandLine.psi.impl; +package com.intellij.commandInterface.commandLine.psi.impl; import java.util.List; import org.jetbrains.annotations.*; @@ -7,13 +7,13 @@ import com.intellij.lang.ASTNode; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.util.PsiTreeUtil; -import static com.jetbrains.commandInterface.commandLine.CommandLineElementTypes.*; -import com.jetbrains.commandInterface.commandLine.CommandLineElement; -import com.jetbrains.commandInterface.commandLine.psi.*; +import static com.intellij.commandInterface.commandLine.CommandLineElementTypes.*; +import com.intellij.commandInterface.commandLine.CommandLineElement; +import com.intellij.commandInterface.commandLine.psi.*; public class CommandLineCommandImpl extends CommandLineElement implements CommandLineCommand { - public CommandLineCommandImpl(ASTNode node) { + public CommandLineCommandImpl(@NotNull ASTNode node) { super(node); } diff --git a/python/gen/com/jetbrains/commandInterface/commandLine/psi/impl/CommandLineOptionImpl.java b/commandInterface/gen/com/intellij/commandInterface/commandLine/psi/impl/CommandLineOptionImpl.java similarity index 67% rename from python/gen/com/jetbrains/commandInterface/commandLine/psi/impl/CommandLineOptionImpl.java rename to commandInterface/gen/com/intellij/commandInterface/commandLine/psi/impl/CommandLineOptionImpl.java index 21ecc9866806..62dea5b7f68c 100644 --- a/python/gen/com/jetbrains/commandInterface/commandLine/psi/impl/CommandLineOptionImpl.java +++ b/commandInterface/gen/com/intellij/commandInterface/commandLine/psi/impl/CommandLineOptionImpl.java @@ -1,5 +1,5 @@ // This is a generated file. Not intended for manual editing. -package com.jetbrains.commandInterface.commandLine.psi.impl; +package com.intellij.commandInterface.commandLine.psi.impl; import java.util.List; import org.jetbrains.annotations.*; @@ -7,14 +7,14 @@ import com.intellij.lang.ASTNode; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.util.PsiTreeUtil; -import static com.jetbrains.commandInterface.commandLine.CommandLineElementTypes.*; -import com.jetbrains.commandInterface.commandLine.CommandLineElement; -import com.jetbrains.commandInterface.commandLine.psi.*; -import com.jetbrains.commandInterface.command.Option; +import static com.intellij.commandInterface.commandLine.CommandLineElementTypes.*; +import com.intellij.commandInterface.commandLine.CommandLineElement; +import com.intellij.commandInterface.commandLine.psi.*; +import com.intellij.commandInterface.command.Option; public class CommandLineOptionImpl extends CommandLineElement implements CommandLineOption { - public CommandLineOptionImpl(ASTNode node) { + public CommandLineOptionImpl(@NotNull ASTNode node) { super(node); } @@ -40,23 +40,23 @@ public class CommandLineOptionImpl extends CommandLineElement implements Command return findChildByType(SHORT_OPTION_NAME_TOKEN); } - @Nullable - @NonNls - public String getOptionName() { + @Override + public @Nullable @NonNls String getOptionName() { return CommandLinePsiImplUtils.getOptionName(this); } + @Override public boolean isLong() { return CommandLinePsiImplUtils.isLong(this); } - @Nullable - public Option findRealOption() { + @Override + public @Nullable Option findRealOption() { return CommandLinePsiImplUtils.findRealOption(this); } - @Nullable - public CommandLineArgument findArgument() { + @Override + public @Nullable CommandLineArgument findArgument() { return CommandLinePsiImplUtils.findArgument(this); } diff --git a/commandInterface/intellij.commandInterface.iml b/commandInterface/intellij.commandInterface.iml new file mode 100644 index 000000000000..a69fefeae783 --- /dev/null +++ b/commandInterface/intellij.commandInterface.iml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/commandInterface/src/META-INF/command-line-plugin.xml b/commandInterface/src/META-INF/command-line-plugin.xml new file mode 100644 index 000000000000..56936c4c39d3 --- /dev/null +++ b/commandInterface/src/META-INF/command-line-plugin.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + diff --git a/commandInterface/src/com/intellij/commandInterface/CommandInterfaceBundle.kt b/commandInterface/src/com/intellij/commandInterface/CommandInterfaceBundle.kt new file mode 100644 index 000000000000..d7897a7406df --- /dev/null +++ b/commandInterface/src/com/intellij/commandInterface/CommandInterfaceBundle.kt @@ -0,0 +1,23 @@ +// 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. +package com.intellij.commandInterface + +import com.intellij.DynamicBundle +import org.jetbrains.annotations.Nls +import org.jetbrains.annotations.NonNls +import org.jetbrains.annotations.PropertyKey +import java.util.function.Supplier + +private const val BUNDLE: @NonNls String = "com.intellij.commandInterface.CommandInterfaceBundle" + +internal object CommandInterfaceBundle : DynamicBundle(BUNDLE) { + + @JvmStatic + fun message(key: @PropertyKey(resourceBundle = BUNDLE) String, vararg params: Any): @Nls String { + return getMessage(key, *params) + } + + @JvmStatic + fun messagePointer(key: @PropertyKey(resourceBundle = BUNDLE) String, vararg params: Any): Supplier { + return getLazyMessage(key, *params) + } +} diff --git a/commandInterface/src/com/intellij/commandInterface/CommandInterfaceBundle.properties b/commandInterface/src/com/intellij/commandInterface/CommandInterfaceBundle.properties new file mode 100644 index 000000000000..a7d416ceb07e --- /dev/null +++ b/commandInterface/src/com/intellij/commandInterface/CommandInterfaceBundle.properties @@ -0,0 +1,6 @@ +command.line.parser.error.message=Space between an argument and its value is unexpected +commandLine.inspection.name=Incorrect CLI syntax +commandLine.inspection.badCommand=Bad or unknown command. Ensure this command exists. +commandLine.inspection.badOption=Bad or unknown option. Ensure this option exists. +commandLine.inspection.badArgument=Argument cannot have this value. Use autocompletion to check the list of possible values. +commandLine.inspection.excessArgument=Excess argument or argument is not possible here diff --git a/python/src/com/jetbrains/commandInterface/command/Argument.java b/commandInterface/src/com/intellij/commandInterface/command/Argument.java similarity index 87% rename from python/src/com/jetbrains/commandInterface/command/Argument.java rename to commandInterface/src/com/intellij/commandInterface/command/Argument.java index faff17f95cf9..c80ddec26a84 100644 --- a/python/src/com/jetbrains/commandInterface/command/Argument.java +++ b/commandInterface/src/com/intellij/commandInterface/command/Argument.java @@ -1,19 +1,5 @@ -/* - * Copyright 2000-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.command; +// 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.commandInterface.command; import com.intellij.openapi.util.Pair; import org.jetbrains.annotations.NotNull; diff --git a/commandInterface/src/com/intellij/commandInterface/command/ArgumentType.java b/commandInterface/src/com/intellij/commandInterface/command/ArgumentType.java new file mode 100644 index 000000000000..f4c2c09f4ec9 --- /dev/null +++ b/commandInterface/src/com/intellij/commandInterface/command/ArgumentType.java @@ -0,0 +1,17 @@ +// 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.commandInterface.command; + +/** + * Argument type to be used with {@link Argument} + * @author Ilya.Kazakevich + */ +public enum ArgumentType { + /** + * String (actually, anything) + */ + STRING, + /** + * Integer or long + */ + INTEGER +} diff --git a/python/src/com/jetbrains/commandInterface/command/ArgumentsInfo.java b/commandInterface/src/com/intellij/commandInterface/command/ArgumentsInfo.java similarity index 56% rename from python/src/com/jetbrains/commandInterface/command/ArgumentsInfo.java rename to commandInterface/src/com/intellij/commandInterface/command/ArgumentsInfo.java index aadf5c9c7c77..26b0d229daff 100644 --- a/python/src/com/jetbrains/commandInterface/command/ArgumentsInfo.java +++ b/commandInterface/src/com/intellij/commandInterface/command/ArgumentsInfo.java @@ -1,19 +1,5 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.command; +// 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.commandInterface.command; import com.intellij.openapi.util.Pair; import org.jetbrains.annotations.Nullable; diff --git a/python/src/com/jetbrains/commandInterface/command/Command.java b/commandInterface/src/com/intellij/commandInterface/command/Command.java similarity index 60% rename from python/src/com/jetbrains/commandInterface/command/Command.java rename to commandInterface/src/com/intellij/commandInterface/command/Command.java index 7ae4d605bcb0..a65319ec30cb 100644 --- a/python/src/com/jetbrains/commandInterface/command/Command.java +++ b/commandInterface/src/com/intellij/commandInterface/command/Command.java @@ -1,19 +1,5 @@ -/* - * Copyright 2000-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.command; +// 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.commandInterface.command; import com.intellij.openapi.util.NlsSafe; import org.jetbrains.annotations.NotNull; diff --git a/python/src/com/jetbrains/commandInterface/command/CommandExecutor.java b/commandInterface/src/com/intellij/commandInterface/command/CommandExecutor.java similarity index 63% rename from python/src/com/jetbrains/commandInterface/command/CommandExecutor.java rename to commandInterface/src/com/intellij/commandInterface/command/CommandExecutor.java index 9a907a400543..bbcdc5f12f20 100644 --- a/python/src/com/jetbrains/commandInterface/command/CommandExecutor.java +++ b/commandInterface/src/com/intellij/commandInterface/command/CommandExecutor.java @@ -1,19 +1,5 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.command; +// 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.commandInterface.command; import com.intellij.execution.process.ProcessHandler; import com.intellij.execution.ui.ConsoleView; diff --git a/python/src/com/jetbrains/commandInterface/command/Help.java b/commandInterface/src/com/intellij/commandInterface/command/Help.java similarity index 62% rename from python/src/com/jetbrains/commandInterface/command/Help.java rename to commandInterface/src/com/intellij/commandInterface/command/Help.java index d1113563d813..a0c40442ced3 100644 --- a/python/src/com/jetbrains/commandInterface/command/Help.java +++ b/commandInterface/src/com/intellij/commandInterface/command/Help.java @@ -1,19 +1,5 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.command; +// 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.commandInterface.command; import com.intellij.openapi.util.NlsSafe; import org.jetbrains.annotations.NotNull; diff --git a/python/src/com/jetbrains/commandInterface/command/KnownArgumentsInfo.java b/commandInterface/src/com/intellij/commandInterface/command/KnownArgumentsInfo.java similarity index 82% rename from python/src/com/jetbrains/commandInterface/command/KnownArgumentsInfo.java rename to commandInterface/src/com/intellij/commandInterface/command/KnownArgumentsInfo.java index 726b6caa68e5..c74dd242fc0e 100644 --- a/python/src/com/jetbrains/commandInterface/command/KnownArgumentsInfo.java +++ b/commandInterface/src/com/intellij/commandInterface/command/KnownArgumentsInfo.java @@ -1,21 +1,6 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.command; +// 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.commandInterface.command; -import com.google.common.base.Preconditions; import com.intellij.openapi.util.Pair; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -101,7 +86,7 @@ public final class KnownArgumentsInfo implements ArgumentsInfo { public KnownArgumentsInfo(@NotNull final Collection arguments, final int minArguments, final int maxArguments) { - Preconditions.checkArgument(!arguments.isEmpty(), "At least one argument should be provided"); + assert !arguments.isEmpty(): "At least one argument should be provided"; myArguments.addAll(arguments); myMinArguments = minArguments; myMaxArguments = maxArguments; diff --git a/commandInterface/src/com/intellij/commandInterface/command/NoArgumentsInfo.java b/commandInterface/src/com/intellij/commandInterface/command/NoArgumentsInfo.java new file mode 100644 index 000000000000..9d522b4595c7 --- /dev/null +++ b/commandInterface/src/com/intellij/commandInterface/command/NoArgumentsInfo.java @@ -0,0 +1,27 @@ +// 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.commandInterface.command; + +import com.intellij.openapi.util.Pair; +import org.jetbrains.annotations.Nullable; + +/** + * TODO: Redundant?! + * Case when command has no arguments (for sure!) + * + * @author Ilya.Kazakevich + */ +public final class NoArgumentsInfo implements ArgumentsInfo { + /** + * Instance to use when command has no arguments + */ + public static final ArgumentsInfo INSTANCE = new NoArgumentsInfo(); + + private NoArgumentsInfo() { + } + + @Nullable + @Override + public Pair getArgument(final int argumentPosition) { + return null; + } +} diff --git a/python/src/com/jetbrains/commandInterface/command/Option.java b/commandInterface/src/com/intellij/commandInterface/command/Option.java similarity index 73% rename from python/src/com/jetbrains/commandInterface/command/Option.java rename to commandInterface/src/com/intellij/commandInterface/command/Option.java index e1f8ea2fba10..467191f2c199 100644 --- a/python/src/com/jetbrains/commandInterface/command/Option.java +++ b/commandInterface/src/com/intellij/commandInterface/command/Option.java @@ -1,21 +1,6 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.command; +// 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.commandInterface.command; -import com.google.common.base.Preconditions; import com.intellij.openapi.util.Pair; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -51,8 +36,7 @@ public final class Option { @NotNull final Help help, @NotNull final Collection shortNames, @NotNull final Collection longNames) { - Preconditions - .checkArgument(argumentAndQuantity == null || argumentAndQuantity.first > 0, "Illegal args and quantity: " + argumentAndQuantity); + assert (argumentAndQuantity == null || argumentAndQuantity.first > 0): "Illegal args and quantity: " + argumentAndQuantity; myArgumentAndQuantity = argumentAndQuantity; myShortNames.addAll(shortNames); myLongNames.addAll(longNames); diff --git a/python/src/com/jetbrains/commandInterface/command/SimpleCommand.java b/commandInterface/src/com/intellij/commandInterface/command/SimpleCommand.java similarity index 84% rename from python/src/com/jetbrains/commandInterface/command/SimpleCommand.java rename to commandInterface/src/com/intellij/commandInterface/command/SimpleCommand.java index dd758d926adc..35cbd1413d4c 100644 --- a/python/src/com/jetbrains/commandInterface/command/SimpleCommand.java +++ b/commandInterface/src/com/intellij/commandInterface/command/SimpleCommand.java @@ -1,19 +1,5 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.command; +// 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.commandInterface.command; import com.intellij.execution.ui.ConsoleView; import com.intellij.openapi.module.Module; diff --git a/python/src/com/jetbrains/commandInterface/command/UnknownArgumentsInfo.java b/commandInterface/src/com/intellij/commandInterface/command/UnknownArgumentsInfo.java similarity index 53% rename from python/src/com/jetbrains/commandInterface/command/UnknownArgumentsInfo.java rename to commandInterface/src/com/intellij/commandInterface/command/UnknownArgumentsInfo.java index fce1fb291f32..38c6d1ff8e62 100644 --- a/python/src/com/jetbrains/commandInterface/command/UnknownArgumentsInfo.java +++ b/commandInterface/src/com/intellij/commandInterface/command/UnknownArgumentsInfo.java @@ -1,19 +1,5 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.command; +// 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.commandInterface.command; import com.intellij.openapi.util.Pair; import org.jetbrains.annotations.NotNull; diff --git a/commandInterface/src/com/intellij/commandInterface/command/package-info.java b/commandInterface/src/com/intellij/commandInterface/command/package-info.java new file mode 100644 index 000000000000..87c37a6b7a24 --- /dev/null +++ b/commandInterface/src/com/intellij/commandInterface/command/package-info.java @@ -0,0 +1,13 @@ +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. + +/** + *

Command with arguments and options.

+ *

+ * Each {@link com.intellij.commandInterface.command.Command} may have one or more positional {@link com.intellij.commandInterface.command.Argument arguments} + * and several {@link com.intellij.commandInterface.command.Option options} (with arguments as well). + * You need to implemenet {@link com.intellij.commandInterface.command.Command} first. + *

+ * + * @author Ilya.Kazakevich + */ +package com.intellij.commandInterface.command; \ No newline at end of file diff --git a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineArgumentReference.java b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineArgumentReference.java similarity index 67% rename from python/src/com/jetbrains/commandInterface/commandLine/CommandLineArgumentReference.java rename to commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineArgumentReference.java index b08ca786c2c3..7db5c985d951 100644 --- a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineArgumentReference.java +++ b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineArgumentReference.java @@ -1,26 +1,12 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.commandLine; +// 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.commandInterface.commandLine; import com.intellij.codeInsight.lookup.LookupElementBuilder; import com.intellij.psi.PsiElement; -import com.jetbrains.commandInterface.command.Argument; -import com.jetbrains.commandInterface.command.Help; -import com.jetbrains.commandInterface.command.Option; -import com.jetbrains.commandInterface.commandLine.psi.CommandLineArgument; +import com.intellij.commandInterface.command.Argument; +import com.intellij.commandInterface.command.Help; +import com.intellij.commandInterface.command.Option; +import com.intellij.commandInterface.commandLine.psi.CommandLineArgument; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineCommandReference.java b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineCommandReference.java similarity index 58% rename from python/src/com/jetbrains/commandInterface/commandLine/CommandLineCommandReference.java rename to commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineCommandReference.java index 889d8e6e21e9..20956f88b1be 100644 --- a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineCommandReference.java +++ b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineCommandReference.java @@ -1,26 +1,12 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.commandLine; +// 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.commandInterface.commandLine; import com.intellij.codeInsight.lookup.LookupElementBuilder; import com.intellij.psi.PsiElement; -import com.jetbrains.commandInterface.command.Command; -import com.jetbrains.commandInterface.command.Help; -import com.jetbrains.commandInterface.commandLine.psi.CommandLineCommand; -import com.jetbrains.commandInterface.commandLine.psi.CommandLineFile; +import com.intellij.commandInterface.command.Command; +import com.intellij.commandInterface.command.Help; +import com.intellij.commandInterface.commandLine.psi.CommandLineCommand; +import com.intellij.commandInterface.commandLine.psi.CommandLineFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineDocumentationProvider.java b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineDocumentationProvider.java similarity index 82% rename from python/src/com/jetbrains/commandInterface/commandLine/CommandLineDocumentationProvider.java rename to commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineDocumentationProvider.java index 9f9f246517e4..37a1e2afd428 100644 --- a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineDocumentationProvider.java +++ b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineDocumentationProvider.java @@ -1,20 +1,20 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -package com.jetbrains.commandInterface.commandLine; +// 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.commandInterface.commandLine; +import com.intellij.commandInterface.command.Command; +import com.intellij.commandInterface.command.Help; +import com.intellij.commandInterface.command.Option; import com.intellij.lang.documentation.DocumentationProvider; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.util.PsiTreeUtil; -import com.jetbrains.commandInterface.command.Command; -import com.jetbrains.commandInterface.command.Help; -import com.jetbrains.commandInterface.command.Option; -import com.jetbrains.commandInterface.commandLine.psi.CommandLineArgument; -import com.jetbrains.commandInterface.commandLine.psi.CommandLineCommand; -import com.jetbrains.commandInterface.commandLine.psi.CommandLineOption; -import com.jetbrains.commandInterface.commandLine.psi.CommandLineVisitor; -import com.jetbrains.python.psi.PyUtil; +import com.intellij.commandInterface.commandLine.psi.CommandLineArgument; +import com.intellij.commandInterface.commandLine.psi.CommandLineCommand; +import com.intellij.commandInterface.commandLine.psi.CommandLineOption; +import com.intellij.commandInterface.commandLine.psi.CommandLineVisitor; +import com.intellij.util.ObjectUtils; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -89,7 +89,7 @@ public final class CommandLineDocumentationProvider implements DocumentationProv return null; } - final CommandLineElement commandLineElement = PyUtil.as(element, CommandLineElement.class); + final CommandLineElement commandLineElement = ObjectUtils.tryCast(element, CommandLineElement.class); if (commandLineElement == null) { return null; } diff --git a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineElement.java b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineElement.java similarity index 61% rename from python/src/com/jetbrains/commandInterface/commandLine/CommandLineElement.java rename to commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineElement.java index af4111c60f57..531a6d328819 100644 --- a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineElement.java +++ b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineElement.java @@ -1,27 +1,13 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.commandLine; +// 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.commandInterface.commandLine; +import com.intellij.commandInterface.command.Command; import com.intellij.extapi.psi.ASTWrapperPsiElement; import com.intellij.lang.ASTNode; import com.intellij.psi.PsiReference; import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry; import com.intellij.psi.util.PsiTreeUtil; -import com.jetbrains.commandInterface.command.Command; -import com.jetbrains.commandInterface.commandLine.psi.CommandLineFile; +import com.intellij.commandInterface.commandLine.psi.CommandLineFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineElementManipulator.java b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineElementManipulator.java new file mode 100644 index 000000000000..fcccd41a411b --- /dev/null +++ b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineElementManipulator.java @@ -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.commandInterface.commandLine; + +import com.intellij.openapi.util.TextRange; +import com.intellij.psi.AbstractElementManipulator; +import org.jetbrains.annotations.NotNull; + +/** + * Manipulator to support reference injection. Will fail with out of it. + * + * @author Ilya.Kazakevich + */ +public final class CommandLineElementManipulator extends AbstractElementManipulator { + + @Override + public CommandLineElement handleContentChange(@NotNull final CommandLineElement element, + @NotNull final TextRange range, + final String newContent) { + return null; + } +} diff --git a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineElementReference.java b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineElementReference.java similarity index 61% rename from python/src/com/jetbrains/commandInterface/commandLine/CommandLineElementReference.java rename to commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineElementReference.java index 939c34b88f43..b690c36ebf2b 100644 --- a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineElementReference.java +++ b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineElementReference.java @@ -1,25 +1,11 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.commandLine; +// 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.commandInterface.commandLine; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiReferenceBase; import com.intellij.psi.util.PsiTreeUtil; -import com.jetbrains.commandInterface.command.Command; -import com.jetbrains.commandInterface.commandLine.psi.CommandLineFile; +import com.intellij.commandInterface.command.Command; +import com.intellij.commandInterface.commandLine.psi.CommandLineFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineElementType.java b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineElementType.java new file mode 100644 index 000000000000..ccb83614bb43 --- /dev/null +++ b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineElementType.java @@ -0,0 +1,17 @@ +// 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.commandInterface.commandLine; + +import com.intellij.psi.tree.IElementType; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; + +/** + * Command line element type to be used in parser + * + * @author Ilya.Kazakevich + */ +final class CommandLineElementType extends IElementType { + CommandLineElementType(@NotNull @NonNls final String debugName) { + super(debugName, CommandLineLanguage.INSTANCE); + } +} diff --git a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineFileType.java b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineFileType.java similarity index 56% rename from python/src/com/jetbrains/commandInterface/commandLine/CommandLineFileType.java rename to commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineFileType.java index 8f693eb03ec6..06cf0b86f559 100644 --- a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineFileType.java +++ b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineFileType.java @@ -1,19 +1,5 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.commandLine; +// 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.commandInterface.commandLine; import com.intellij.openapi.fileTypes.LanguageFileType; import org.jetbrains.annotations.NotNull; diff --git a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineInspection.java b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineInspection.java similarity index 69% rename from python/src/com/jetbrains/commandInterface/commandLine/CommandLineInspection.java rename to commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineInspection.java index 509945d997c9..f537bd55dd2e 100644 --- a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineInspection.java +++ b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineInspection.java @@ -1,29 +1,15 @@ -/* - * Copyright 2000-2019 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.commandLine; +// 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.commandInterface.commandLine; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.LocalInspectionToolSession; import com.intellij.codeInspection.ProblemsHolder; +import com.intellij.commandInterface.CommandInterfaceBundle; +import com.intellij.commandInterface.command.Command; +import com.intellij.commandInterface.commandLine.psi.*; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.util.PsiTreeUtil; -import com.jetbrains.commandInterface.command.Command; -import com.jetbrains.commandInterface.commandLine.psi.*; -import com.jetbrains.python.PyBundle; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -83,7 +69,7 @@ public final class CommandLineInspection extends LocalInspectionTool { return; } } - myHolder.registerProblem(o, PyBundle.message("commandLine.inspection.badCommand")); + myHolder.registerProblem(o, CommandInterfaceBundle.message("commandLine.inspection.badCommand")); } @Override @@ -91,7 +77,7 @@ public final class CommandLineInspection extends LocalInspectionTool { super.visitOption(o); final ValidationResult validationResult = getValidationResult(o); if (validationResult != null && validationResult.isBadValue(o)) { - myHolder.registerProblem(o, PyBundle.message("commandLine.inspection.badOption")); + myHolder.registerProblem(o, CommandInterfaceBundle.message("commandLine.inspection.badOption")); } } @@ -102,10 +88,10 @@ public final class CommandLineInspection extends LocalInspectionTool { final ValidationResult validationResult = getValidationResult(o); if (validationResult != null) { if (validationResult.isBadValue(o)) { - myHolder.registerProblem(o, PyBundle.message("commandLine.inspection.badArgument")); + myHolder.registerProblem(o, CommandInterfaceBundle.message("commandLine.inspection.badArgument")); } else if (validationResult.isExcessArgument(o)) { - myHolder.registerProblem(o, PyBundle.message("commandLine.inspection.excessArgument")); + myHolder.registerProblem(o, CommandInterfaceBundle.message("commandLine.inspection.excessArgument")); } } } diff --git a/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineLanguage.java b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineLanguage.java new file mode 100644 index 000000000000..96c93b57ecfd --- /dev/null +++ b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineLanguage.java @@ -0,0 +1,25 @@ +// 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.commandInterface.commandLine; + +import com.intellij.lang.Language; +import com.intellij.openapi.fileTypes.LanguageFileType; +import org.jetbrains.annotations.NotNull; + +/** + * Command line language itself + *
my_command --option=value foo
+ * @author Ilya.Kazakevich + */ +public final class CommandLineLanguage extends Language { + public static final CommandLineLanguage INSTANCE = new CommandLineLanguage(); + + private CommandLineLanguage() { + super("CommandLine"); + } + + @NotNull + @Override + public LanguageFileType getAssociatedFileType() { + return CommandLineFileType.INSTANCE; + } +} diff --git a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineOptionReference.java b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineOptionReference.java similarity index 62% rename from python/src/com/jetbrains/commandInterface/commandLine/CommandLineOptionReference.java rename to commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineOptionReference.java index 4cde3b456fd7..3859ccc2e7ed 100644 --- a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineOptionReference.java +++ b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineOptionReference.java @@ -1,24 +1,10 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.commandLine; +// 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.commandInterface.commandLine; import com.intellij.codeInsight.lookup.LookupElementBuilder; import com.intellij.psi.PsiElement; -import com.jetbrains.commandInterface.command.Option; -import com.jetbrains.commandInterface.commandLine.psi.CommandLineOption; +import com.intellij.commandInterface.command.Option; +import com.intellij.commandInterface.commandLine.psi.CommandLineOption; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineParserDefinition.java b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineParserDefinition.java similarity index 80% rename from python/src/com/jetbrains/commandInterface/commandLine/CommandLineParserDefinition.java rename to commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineParserDefinition.java index 0c919b2ec1fb..7ec363a49b7d 100644 --- a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineParserDefinition.java +++ b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineParserDefinition.java @@ -1,5 +1,5 @@ -// 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. -package com.jetbrains.commandInterface.commandLine; +// 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.commandInterface.commandLine; import com.intellij.lang.ASTNode; import com.intellij.lang.ParserDefinition; @@ -13,8 +13,10 @@ import com.intellij.psi.PsiFile; import com.intellij.psi.TokenType; import com.intellij.psi.tree.IFileElementType; import com.intellij.psi.tree.TokenSet; -import com.jetbrains.commandInterface.commandLine.CommandLineElementTypes.Factory; -import com.jetbrains.commandInterface.commandLine.psi.CommandLineFile; +import com.intellij.commandInterface.commandLine.CommandLineElementTypes.Factory; +import com.intellij.commandInterface.commandLine.CommandLineParser; +import com.intellij.commandInterface.commandLine._CommandLineLexer; +import com.intellij.commandInterface.commandLine.psi.CommandLineFile; import org.jetbrains.annotations.NotNull; /** diff --git a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineParserUtil.java b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineParserUtil.java similarity index 60% rename from python/src/com/jetbrains/commandInterface/commandLine/CommandLineParserUtil.java rename to commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineParserUtil.java index a78509f10709..ef889f257b6e 100644 --- a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineParserUtil.java +++ b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineParserUtil.java @@ -1,25 +1,11 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.commandLine; +// 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.commandInterface.commandLine; +import com.intellij.commandInterface.CommandInterfaceBundle; import com.intellij.lang.PsiBuilder; import com.intellij.lang.parser.GeneratedParserUtilBase; import com.intellij.psi.TokenType; import com.intellij.psi.tree.IElementType; -import com.jetbrains.python.PyBundle; import org.jetbrains.annotations.NotNull; /** @@ -46,7 +32,7 @@ final class CommandLineParserUtil extends GeneratedParserUtilBase { if (tokenType == CommandLineElementTypes.EQ) { if (leftElement.equals(CommandLineElementTypes.LONG_OPTION_NAME_TOKEN)) { if (rightElement == null || TokenType.WHITE_SPACE.equals(rightElement)) { - b.error(PyBundle.message("command.line.parser.error.message")); + b.error(CommandInterfaceBundle.message("command.line.parser.error.message")); } b.advanceLexer(); } diff --git a/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLinePart.java b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLinePart.java new file mode 100644 index 000000000000..8f58a8d40969 --- /dev/null +++ b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLinePart.java @@ -0,0 +1,27 @@ +// 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.commandInterface.commandLine; + +import com.intellij.psi.PsiElement; +import com.intellij.commandInterface.command.Command; +import com.intellij.commandInterface.commandLine.psi.CommandLineFile; +import org.jetbrains.annotations.Nullable; + +/** + * Any part of commandline from file till any element + * + * @author Ilya.Kazakevich + */ +public interface CommandLinePart extends PsiElement { + /** + * @return command associated with this command line (if any) + */ + @Nullable + Command findRealCommand(); + + /** + * @return command line file where this part sits + */ + @SuppressWarnings("ClassReferencesSubclass") // Although referencing child is bad idea, this hierarchy is coupled tightly and considered to be solid part + @Nullable + CommandLineFile getCommandLineFile(); +} diff --git a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineReferenceContributor.java b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineReferenceContributor.java similarity index 67% rename from python/src/com/jetbrains/commandInterface/commandLine/CommandLineReferenceContributor.java rename to commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineReferenceContributor.java index fdd52994884d..41de49137b97 100644 --- a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineReferenceContributor.java +++ b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineReferenceContributor.java @@ -1,24 +1,10 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.commandLine; +// 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.commandInterface.commandLine; import com.intellij.patterns.PlatformPatterns; import com.intellij.psi.*; import com.intellij.util.ProcessingContext; -import com.jetbrains.commandInterface.commandLine.psi.*; +import com.intellij.commandInterface.commandLine.psi.*; import org.jetbrains.annotations.NotNull; /** diff --git a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineSyntaxHighlighter.java b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineSyntaxHighlighter.java similarity index 85% rename from python/src/com/jetbrains/commandInterface/commandLine/CommandLineSyntaxHighlighter.java rename to commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineSyntaxHighlighter.java index d051ac7ec1be..7c26fc5b4f5d 100644 --- a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineSyntaxHighlighter.java +++ b/commandInterface/src/com/intellij/commandInterface/commandLine/CommandLineSyntaxHighlighter.java @@ -1,5 +1,5 @@ -// Copyright 2000-2019 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. -package com.jetbrains.commandInterface.commandLine; +// 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.commandInterface.commandLine; import com.intellij.lexer.FlexAdapter; import com.intellij.lexer.Lexer; @@ -7,6 +7,8 @@ import com.intellij.openapi.editor.DefaultLanguageHighlighterColors; import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.fileTypes.SyntaxHighlighter; import com.intellij.psi.tree.IElementType; +import com.intellij.commandInterface.commandLine.CommandLineElementTypes; +import com.intellij.commandInterface.commandLine._CommandLineLexer; import org.jetbrains.annotations.NotNull; import java.util.HashMap; diff --git a/python/src/com/jetbrains/commandInterface/commandLine/LookupWithIndentsBuilder.java b/commandInterface/src/com/intellij/commandInterface/commandLine/LookupWithIndentsBuilder.java similarity index 86% rename from python/src/com/jetbrains/commandInterface/commandLine/LookupWithIndentsBuilder.java rename to commandInterface/src/com/intellij/commandInterface/commandLine/LookupWithIndentsBuilder.java index 0e3ef7b515aa..2c2277f17f26 100644 --- a/python/src/com/jetbrains/commandInterface/commandLine/LookupWithIndentsBuilder.java +++ b/commandInterface/src/com/intellij/commandInterface/commandLine/LookupWithIndentsBuilder.java @@ -1,19 +1,5 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.commandLine; +// 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.commandInterface.commandLine; import com.intellij.codeInsight.completion.PrioritizedLookupElement; import com.intellij.codeInsight.lookup.LookupElement; diff --git a/python/src/com/jetbrains/commandInterface/commandLine/ValidationResult.java b/commandInterface/src/com/intellij/commandInterface/commandLine/ValidationResult.java similarity index 66% rename from python/src/com/jetbrains/commandInterface/commandLine/ValidationResult.java rename to commandInterface/src/com/intellij/commandInterface/commandLine/ValidationResult.java index fcacd0bd7b1d..70097955ee74 100644 --- a/python/src/com/jetbrains/commandInterface/commandLine/ValidationResult.java +++ b/commandInterface/src/com/intellij/commandInterface/commandLine/ValidationResult.java @@ -1,26 +1,12 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.commandLine; +// 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.commandInterface.commandLine; import com.intellij.openapi.util.Pair; import com.intellij.psi.PsiElement; -import com.jetbrains.commandInterface.command.Argument; -import com.jetbrains.commandInterface.command.Option; -import com.jetbrains.commandInterface.commandLine.psi.CommandLineArgument; -import com.jetbrains.commandInterface.commandLine.psi.CommandLineOption; +import com.intellij.commandInterface.command.Argument; +import com.intellij.commandInterface.command.Option; +import com.intellij.commandInterface.commandLine.psi.CommandLineArgument; +import com.intellij.commandInterface.commandLine.psi.CommandLineOption; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/python/src/com/jetbrains/commandInterface/commandLine/command_line.bnf b/commandInterface/src/com/intellij/commandInterface/commandLine/command_line.bnf similarity index 74% rename from python/src/com/jetbrains/commandInterface/commandLine/command_line.bnf rename to commandInterface/src/com/intellij/commandInterface/commandLine/command_line.bnf index 26cba405f22b..af0ec77cf62e 100644 --- a/python/src/com/jetbrains/commandInterface/commandLine/command_line.bnf +++ b/commandInterface/src/com/intellij/commandInterface/commandLine/command_line.bnf @@ -1,3 +1,5 @@ +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. + /*TODO:Add generation to ant*/ // This file is used to auto-generate lexer and parser for gnu command line language @@ -6,20 +8,20 @@ { // All 3 elements should extend this class - mixin("option|argument|command")="com.jetbrains.commandInterface.commandLine.CommandLineElement" + mixin("option|argument|command")="com.intellij.commandInterface.commandLine.CommandLineElement" // And implement this interface - implements("option|argument|command")="com.jetbrains.commandInterface.commandLine.CommandLinePart" + implements("option|argument|command")="com.intellij.commandInterface.commandLine.CommandLinePart" - parserClass = 'com.jetbrains.commandInterface.commandLine.CommandLineParser' - parserUtilClass="com.jetbrains.commandInterface.commandLine.CommandLineParserUtil" - psiImplUtilClass="com.jetbrains.commandInterface.commandLine.psi.impl.CommandLinePsiImplUtils" - psiPackage = 'com.jetbrains.commandInterface.commandLine.psi' - psiImplPackage = 'com.jetbrains.commandInterface.commandLine.psi.impl' + parserClass = 'com.intellij.commandInterface.commandLine.CommandLineParser' + parserUtilClass="com.intellij.commandInterface.commandLine.CommandLineParserUtil" + psiImplUtilClass="com.intellij.commandInterface.commandLine.psi.impl.CommandLinePsiImplUtils" + psiPackage = 'com.intellij.commandInterface.commandLine.psi' + psiImplPackage = 'com.intellij.commandInterface.commandLine.psi.impl' - elementTypeHolderClass = 'com.jetbrains.commandInterface.commandLine.CommandLineElementTypes' + elementTypeHolderClass = 'com.intellij.commandInterface.commandLine.CommandLineElementTypes' psiClassPrefix = "CommandLine" psiVisitorName = "CommandLineVisitor" - elementTypeClass = 'com.jetbrains.commandInterface.commandLine.CommandLineElementType' + elementTypeClass = 'com.intellij.commandInterface.commandLine.CommandLineElementType' //TODO: I would suggest making this pattern negative rather than positive in order to support all the characters like ? and others diff --git a/commandInterface/src/com/intellij/commandInterface/commandLine/package-info.java b/commandInterface/src/com/intellij/commandInterface/commandLine/package-info.java new file mode 100644 index 000000000000..17ea5f6e28f6 --- /dev/null +++ b/commandInterface/src/com/intellij/commandInterface/commandLine/package-info.java @@ -0,0 +1,27 @@ +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. + +/** + *

GNU command line language PSI

+ *

Command line language

+ *

+ * GNU command line language syntax + * based on POSIX syntax. + *

+ *   my_command --option --option-2=argument positional_argument -s
+ * 
+ *

+ *

PSI

+ *

Generation based on Grammar-Kit, see .bnf file, do not edit parser nor lexer manually. + * When parsed, {@link com.intellij.commandInterface.commandLine.psi.CommandLineFile} is root element for + * {@link com.intellij.commandInterface.commandLine.CommandLineLanguage}. + * Warning: always fill {@link com.intellij.commandInterface.commandLine.psi.CommandLineFile#setCommandsAndDefaultExecutor(java.util.List, CommandExecutor)} + * if possible. + *

+ *

Extension points

+ *

This package has a a lot of extension points (language, inspection etc). Make sure all of them are registered

+ * + * @author Ilya.Kazakevich + */ +package com.intellij.commandInterface.commandLine; + +import com.intellij.commandInterface.command.CommandExecutor; \ No newline at end of file diff --git a/python/src/com/jetbrains/commandInterface/commandLine/psi/CommandLineFile.java b/commandInterface/src/com/intellij/commandInterface/commandLine/psi/CommandLineFile.java similarity index 76% rename from python/src/com/jetbrains/commandInterface/commandLine/psi/CommandLineFile.java rename to commandInterface/src/com/intellij/commandInterface/commandLine/psi/CommandLineFile.java index 3d4edc5101fe..d0c748344d49 100644 --- a/python/src/com/jetbrains/commandInterface/commandLine/psi/CommandLineFile.java +++ b/commandInterface/src/com/intellij/commandInterface/commandLine/psi/CommandLineFile.java @@ -1,29 +1,18 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.commandLine.psi; +// 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.commandInterface.commandLine.psi; +import com.intellij.commandInterface.command.Command; +import com.intellij.commandInterface.commandLine.CommandLineLanguage; +import com.intellij.commandInterface.commandLine.CommandLinePart; +import com.intellij.commandInterface.commandLine.ValidationResult; import com.intellij.extapi.psi.PsiFileBase; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.util.Key; import com.intellij.psi.FileViewProvider; import com.intellij.psi.util.PsiTreeUtil; -import com.jetbrains.commandInterface.command.Command; -import com.jetbrains.commandInterface.commandLine.CommandLineLanguage; -import com.jetbrains.commandInterface.commandLine.CommandLinePart; -import com.jetbrains.commandInterface.commandLine.ValidationResult; +import com.intellij.commandInterface.commandLine.psi.CommandLineArgument; +import com.intellij.commandInterface.commandLine.psi.CommandLineCommand; +import com.intellij.commandInterface.commandLine.psi.CommandLineOption; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/python/src/com/jetbrains/commandInterface/commandLine/psi/ValidationResultImpl.java b/commandInterface/src/com/intellij/commandInterface/commandLine/psi/ValidationResultImpl.java similarity index 88% rename from python/src/com/jetbrains/commandInterface/commandLine/psi/ValidationResultImpl.java rename to commandInterface/src/com/intellij/commandInterface/commandLine/psi/ValidationResultImpl.java index 7c3997dd1bb3..054ec17c6b7b 100644 --- a/python/src/com/jetbrains/commandInterface/commandLine/psi/ValidationResultImpl.java +++ b/commandInterface/src/com/intellij/commandInterface/commandLine/psi/ValidationResultImpl.java @@ -1,27 +1,16 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.commandLine.psi; +// 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.commandInterface.commandLine.psi; +import com.intellij.commandInterface.commandLine.ValidationResult; import com.intellij.openapi.util.Pair; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiWhiteSpace; -import com.jetbrains.commandInterface.command.Argument; -import com.jetbrains.commandInterface.command.Command; -import com.jetbrains.commandInterface.command.Option; -import com.jetbrains.commandInterface.commandLine.ValidationResult; +import com.intellij.commandInterface.command.Argument; +import com.intellij.commandInterface.command.Command; +import com.intellij.commandInterface.command.Option; +import com.intellij.commandInterface.commandLine.psi.CommandLineArgument; +import com.intellij.commandInterface.commandLine.psi.CommandLineOption; +import com.intellij.commandInterface.commandLine.psi.CommandLineVisitor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/python/src/com/jetbrains/commandInterface/commandLine/psi/impl/CommandLinePsiImplUtils.java b/commandInterface/src/com/intellij/commandInterface/commandLine/psi/impl/CommandLinePsiImplUtils.java similarity index 78% rename from python/src/com/jetbrains/commandInterface/commandLine/psi/impl/CommandLinePsiImplUtils.java rename to commandInterface/src/com/intellij/commandInterface/commandLine/psi/impl/CommandLinePsiImplUtils.java index 747eb84eb6bb..2f40feb2a8d8 100644 --- a/python/src/com/jetbrains/commandInterface/commandLine/psi/impl/CommandLinePsiImplUtils.java +++ b/commandInterface/src/com/intellij/commandInterface/commandLine/psi/impl/CommandLinePsiImplUtils.java @@ -1,30 +1,16 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.commandLine.psi.impl; +// 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.commandInterface.commandLine.psi.impl; +import com.intellij.commandInterface.commandLine.CommandLinePart; +import com.intellij.commandInterface.commandLine.ValidationResult; import com.intellij.psi.PsiElement; -import com.jetbrains.commandInterface.command.Argument; -import com.jetbrains.commandInterface.command.Help; -import com.jetbrains.commandInterface.command.Option; -import com.jetbrains.commandInterface.commandLine.CommandLinePart; -import com.jetbrains.commandInterface.commandLine.ValidationResult; -import com.jetbrains.commandInterface.commandLine.psi.CommandLineArgument; -import com.jetbrains.commandInterface.commandLine.psi.CommandLineFile; -import com.jetbrains.commandInterface.commandLine.psi.CommandLineOption; -import com.jetbrains.python.psi.PyUtil; +import com.intellij.commandInterface.command.Argument; +import com.intellij.commandInterface.command.Help; +import com.intellij.commandInterface.command.Option; +import com.intellij.commandInterface.commandLine.psi.CommandLineArgument; +import com.intellij.commandInterface.commandLine.psi.CommandLineFile; +import com.intellij.commandInterface.commandLine.psi.CommandLineOption; +import com.intellij.util.ObjectUtils; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -59,7 +45,7 @@ final class CommandLinePsiImplUtils { @Nullable static CommandLineArgument findArgument(@NotNull final CommandLineOption option) { if (option.getText().endsWith("=")) { - return PyUtil.as(option.getNextSibling(), CommandLineArgument.class); + return ObjectUtils.tryCast(option.getNextSibling(), CommandLineArgument.class); } return null; } diff --git a/commandInterface/src/com/intellij/commandInterface/commandLine/psi/impl/package-info.java b/commandInterface/src/com/intellij/commandInterface/commandLine/psi/impl/package-info.java new file mode 100644 index 000000000000..bec952905ced --- /dev/null +++ b/commandInterface/src/com/intellij/commandInterface/commandLine/psi/impl/package-info.java @@ -0,0 +1,10 @@ +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. + +/** + * Gnu command line language PSI implementation. + * Do not use this package directly, consider using interfaces from {@link com.intellij.commandInterface.commandLine.psi} instead. + * Warning: most files in this package is autogenerated. Do not touch them directly. + * + * @author Ilya.Kazakevich + */ +package com.intellij.commandInterface.commandLine.psi.impl; \ No newline at end of file diff --git a/commandInterface/src/com/intellij/commandInterface/commandLine/psi/package-info.java b/commandInterface/src/com/intellij/commandInterface/commandLine/psi/package-info.java new file mode 100644 index 000000000000..acc1f7757d79 --- /dev/null +++ b/commandInterface/src/com/intellij/commandInterface/commandLine/psi/package-info.java @@ -0,0 +1,9 @@ +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. + +/** + * Gnu command line public PSI interfaces: Command, option, argument etc. + * + * Warning: most files in this package is autogenerated. Do not touch them directly. + * @author Ilya.Kazakevich + */ +package com.intellij.commandInterface.commandLine.psi; \ No newline at end of file diff --git a/commandInterface/src/com/intellij/commandInterface/package-info.java b/commandInterface/src/com/intellij/commandInterface/package-info.java new file mode 100644 index 000000000000..285e62e1526d --- /dev/null +++ b/commandInterface/src/com/intellij/commandInterface/package-info.java @@ -0,0 +1,41 @@ +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. + +/** + *

Command-line interface

+ *

What is the purpose of this package?

+ *

+ * This package is based on ideas of command-line with command, positional arguments, options and their arguments. + * Initial idea is taken from POSIX + * and enhanced by GNU. + * It also supported by Python in optparse package. + * Command-line is something like + *

my_command positional_argument -s --long-option --another-long-option=arg1 arg2 some_other_arg
+ * and this package helps you to parse command lines, highlight errors, display a console-like interface and execute commands. + *

+ *

What this package consists of?

+ *

+ * This package has 2 subpackages: + *

    + *
  1. {@link com.intellij.commandInterface.command} contains classes to describe commands, arguments and options. + * It is up to you where to obtain list of available commands, but you should implement {@link com.intellij.commandInterface.command.Command} + * first, and create list of it with arguments and options. See package info for more details
  2. + *
  3. {@link com.intellij.commandInterface.commandLine} is language based on + * GNU command line representation. + * It has PSI, so it parses command lines into tree of PsiElements. But this package is not only for parsing: + * If you provide list of + * {@link com.intellij.commandInterface.command.Command commands} to {@link com.intellij.commandInterface.commandLine.psi.CommandLineFile} + * (see {@link com.intellij.commandInterface.commandLine.psi.CommandLineFile#setCommands(java.util.List)}}}), it will inject references + * (to provide autocompletion) and activate inspection to validate options and arguments.
  4. + * + *
+ *

+ *

How to use this package?

+ *
    + *
  1. Implement {@link com.intellij.commandInterface.command.Command}
  2. + *
  3. Create list of {@link com.intellij.commandInterface.command.Command commands}
  4. + *
+ * + * @author Ilya.Kazakevich + */ +package com.intellij.commandInterface; + diff --git a/platform/build-scripts/src/org/jetbrains/intellij/build/python/PythonCommunityPluginModules.kt b/platform/build-scripts/src/org/jetbrains/intellij/build/python/PythonCommunityPluginModules.kt index f45133f692e0..10a9adcdb498 100644 --- a/platform/build-scripts/src/org/jetbrains/intellij/build/python/PythonCommunityPluginModules.kt +++ b/platform/build-scripts/src/org/jetbrains/intellij/build/python/PythonCommunityPluginModules.kt @@ -25,6 +25,7 @@ object PythonCommunityPluginModules { "intellij.python.grazie", "intellij.python.markdown", "intellij.python.reStructuredText", + "intellij.commandInterface", "intellij.python.sdk", "intellij.python.featuresTrainer", "intellij.jupyter.core" diff --git a/python/intellij.python.community.impl.iml b/python/intellij.python.community.impl.iml index f7ad4f98c0fb..0d03490f0616 100644 --- a/python/intellij.python.community.impl.iml +++ b/python/intellij.python.community.impl.iml @@ -145,5 +145,6 @@ +
\ No newline at end of file diff --git a/python/pluginResources/messages/PyBundle.properties b/python/pluginResources/messages/PyBundle.properties index fdf73ece1321..7262d9025e17 100644 --- a/python/pluginResources/messages/PyBundle.properties +++ b/python/pluginResources/messages/PyBundle.properties @@ -554,12 +554,6 @@ remote.interpreter.remote.server.permissions=Failed to browse the remote server. remote.interpreter.accessing.remote.interpreter.progress.title=Accessing Remote Interpreter remote.interpreter.feature.is.not.available=Remote interpreter feature is not available -# CommandLine -commandLine.inspection.name=Incorrect CLI syntax -commandLine.inspection.badCommand=Bad or unknown command. Ensure this command exists. -commandLine.inspection.badOption=Bad or unknown option. Ensure this option exists. -commandLine.inspection.badArgument=Argument cannot have this value. Use autocompletion to check the list of possible values. -commandLine.inspection.excessArgument=Excess argument or argument is not possible here # What to display of user entered junk commandLine.commandNotFound={0}: command not found @@ -1167,7 +1161,6 @@ integrated.tools.configurable.restructuredtext=reStructuredText integrated.tools.configurable.packaging=Packaging integrated.tools.configurable.testing=Testing integrated.tools.configurable.pipenv=Pipenv -command.line.parser.error.message=Space between an argument and its value is unexpected python.package.installation.notification.message={0} will be installed on the selected interpreter python.package.and.packaging.tools.installation.notification.message=Python packaging tools and {0} will be installed on the selected interpreter diff --git a/python/src/META-INF/command-line-plugin.xml b/python/src/META-INF/command-line-plugin.xml deleted file mode 100644 index d578e2b6e6fe..000000000000 --- a/python/src/META-INF/command-line-plugin.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - diff --git a/python/src/com/jetbrains/commandInterface/console/ArgumentHintLayer.java b/python/src/com/intellij/python/community/impl/commandInterfaceConsole/ArgumentHintLayer.java similarity index 81% rename from python/src/com/jetbrains/commandInterface/console/ArgumentHintLayer.java rename to python/src/com/intellij/python/community/impl/commandInterfaceConsole/ArgumentHintLayer.java index 488670dc6140..afa8dd937fec 100644 --- a/python/src/com/jetbrains/commandInterface/console/ArgumentHintLayer.java +++ b/python/src/com/intellij/python/community/impl/commandInterfaceConsole/ArgumentHintLayer.java @@ -1,19 +1,5 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.console; +// 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.python.community.impl.commandInterfaceConsole; import com.intellij.codeInsight.template.impl.TemplateColors; import com.intellij.execution.process.ConsoleHighlighter; @@ -25,9 +11,9 @@ import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.util.NlsSafe; import com.intellij.openapi.util.Pair; import com.intellij.psi.PsiFile; -import com.jetbrains.commandInterface.command.Argument; -import com.jetbrains.commandInterface.commandLine.ValidationResult; -import com.jetbrains.commandInterface.commandLine.psi.CommandLineFile; +import com.intellij.commandInterface.command.Argument; +import com.intellij.commandInterface.commandLine.ValidationResult; +import com.intellij.commandInterface.commandLine.psi.CommandLineFile; import org.jetbrains.annotations.NotNull; import java.awt.*; diff --git a/python/src/com/jetbrains/commandInterface/console/CommandConsole.java b/python/src/com/intellij/python/community/impl/commandInterfaceConsole/CommandConsole.java similarity index 97% rename from python/src/com/jetbrains/commandInterface/console/CommandConsole.java rename to python/src/com/intellij/python/community/impl/commandInterfaceConsole/CommandConsole.java index 025760532a83..04e247a277cb 100644 --- a/python/src/com/jetbrains/commandInterface/console/CommandConsole.java +++ b/python/src/com/intellij/python/community/impl/commandInterfaceConsole/CommandConsole.java @@ -1,5 +1,5 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -package com.jetbrains.commandInterface.console; +// 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.python.community.impl.commandInterfaceConsole; import com.intellij.execution.console.LanguageConsoleBuilder; import com.intellij.execution.console.LanguageConsoleImpl; @@ -20,8 +20,8 @@ import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Disposer; import com.intellij.testFramework.LightVirtualFile; import com.intellij.util.Consumer; -import com.jetbrains.commandInterface.commandLine.CommandLineLanguage; -import com.jetbrains.commandInterface.commandLine.psi.CommandLineFile; +import com.intellij.commandInterface.commandLine.CommandLineLanguage; +import com.intellij.commandInterface.commandLine.psi.CommandLineFile; import com.jetbrains.python.PythonPluginDisposable; import com.jetbrains.python.psi.PyUtil; import kotlin.jvm.functions.Function1; diff --git a/python/src/com/jetbrains/commandInterface/console/CommandLineConsoleApi.kt b/python/src/com/intellij/python/community/impl/commandInterfaceConsole/CommandLineConsoleApi.kt similarity index 86% rename from python/src/com/jetbrains/commandInterface/console/CommandLineConsoleApi.kt rename to python/src/com/intellij/python/community/impl/commandInterfaceConsole/CommandLineConsoleApi.kt index 477835b1a5f9..367d3dc5d11d 100644 --- a/python/src/com/jetbrains/commandInterface/console/CommandLineConsoleApi.kt +++ b/python/src/com/intellij/python/community/impl/commandInterfaceConsole/CommandLineConsoleApi.kt @@ -1,19 +1,5 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.console +// 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.python.community.impl.commandInterfaceConsole import com.intellij.execution.console.LanguageConsoleBuilder import com.intellij.execution.console.LanguageConsoleView @@ -24,8 +10,8 @@ import com.intellij.openapi.wm.ToolWindowManager.Companion.getInstance import com.intellij.ui.content.Content import com.intellij.ui.content.impl.ContentImpl import com.intellij.util.concurrency.annotations.RequiresEdt -import com.jetbrains.commandInterface.command.Command -import com.jetbrains.commandInterface.command.CommandExecutor +import com.intellij.commandInterface.command.Command +import com.intellij.commandInterface.command.CommandExecutor import org.jetbrains.annotations.Nls import org.jetbrains.plugins.terminal.TerminalToolWindowFactory diff --git a/python/src/com/jetbrains/commandInterface/console/CommandModeConsumer.java b/python/src/com/intellij/python/community/impl/commandInterfaceConsole/CommandModeConsumer.java similarity index 78% rename from python/src/com/jetbrains/commandInterface/console/CommandModeConsumer.java rename to python/src/com/intellij/python/community/impl/commandInterfaceConsole/CommandModeConsumer.java index 4c6338951c5a..afec455dda03 100644 --- a/python/src/com/jetbrains/commandInterface/console/CommandModeConsumer.java +++ b/python/src/com/intellij/python/community/impl/commandInterfaceConsole/CommandModeConsumer.java @@ -1,29 +1,15 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.console; +// 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.python.community.impl.commandInterfaceConsole; import com.intellij.execution.console.LanguageConsoleImpl; import com.intellij.execution.ui.ConsoleViewContentType; import com.intellij.openapi.module.Module; import com.intellij.psi.PsiFileFactory; import com.intellij.util.Consumer; -import com.jetbrains.commandInterface.command.Command; -import com.jetbrains.commandInterface.command.CommandExecutor; -import com.jetbrains.commandInterface.commandLine.CommandLineLanguage; -import com.jetbrains.commandInterface.commandLine.psi.CommandLineFile; +import com.intellij.commandInterface.command.Command; +import com.intellij.commandInterface.command.CommandExecutor; +import com.intellij.commandInterface.commandLine.CommandLineLanguage; +import com.intellij.commandInterface.commandLine.psi.CommandLineFile; import com.jetbrains.python.PyBundle; import com.jetbrains.python.psi.PyUtil; import org.jetbrains.annotations.NotNull; diff --git a/python/src/com/jetbrains/commandInterface/console/ConsoleStopProcessAction.java b/python/src/com/intellij/python/community/impl/commandInterfaceConsole/ConsoleStopProcessAction.java similarity index 89% rename from python/src/com/jetbrains/commandInterface/console/ConsoleStopProcessAction.java rename to python/src/com/intellij/python/community/impl/commandInterfaceConsole/ConsoleStopProcessAction.java index c9889cd6f7a8..be4a8e4cbc93 100644 --- a/python/src/com/jetbrains/commandInterface/console/ConsoleStopProcessAction.java +++ b/python/src/com/intellij/python/community/impl/commandInterfaceConsole/ConsoleStopProcessAction.java @@ -1,5 +1,5 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -package com.jetbrains.commandInterface.console; +// 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.python.community.impl.commandInterfaceConsole; import com.intellij.execution.actions.StopProcessAction; import com.intellij.openapi.actionSystem.AnActionEvent; diff --git a/python/src/com/jetbrains/commandInterface/console/ConsoleWithProcess.java b/python/src/com/intellij/python/community/impl/commandInterfaceConsole/ConsoleWithProcess.java similarity index 83% rename from python/src/com/jetbrains/commandInterface/console/ConsoleWithProcess.java rename to python/src/com/intellij/python/community/impl/commandInterfaceConsole/ConsoleWithProcess.java index fbc7836a817d..bfb8b14bc3b9 100644 --- a/python/src/com/jetbrains/commandInterface/console/ConsoleWithProcess.java +++ b/python/src/com/intellij/python/community/impl/commandInterfaceConsole/ConsoleWithProcess.java @@ -1,5 +1,5 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -package com.jetbrains.commandInterface.console; +// 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.python.community.impl.commandInterfaceConsole; import com.intellij.execution.process.ProcessHandler; import com.intellij.execution.ui.ConsoleView; diff --git a/python/src/com/jetbrains/commandInterface/console/PanelWithActions.java b/python/src/com/intellij/python/community/impl/commandInterfaceConsole/PanelWithActions.java similarity index 97% rename from python/src/com/jetbrains/commandInterface/console/PanelWithActions.java rename to python/src/com/intellij/python/community/impl/commandInterfaceConsole/PanelWithActions.java index 69c470a08bd1..2857305ed0b8 100644 --- a/python/src/com/jetbrains/commandInterface/console/PanelWithActions.java +++ b/python/src/com/intellij/python/community/impl/commandInterfaceConsole/PanelWithActions.java @@ -1,5 +1,5 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -package com.jetbrains.commandInterface.console; +// 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.python.community.impl.commandInterfaceConsole; import com.intellij.execution.runners.AbstractConsoleRunnerWithHistory; import com.intellij.ide.actions.CloseAction; diff --git a/python/src/com/jetbrains/commandInterface/console/ProcessModeConsumer.java b/python/src/com/intellij/python/community/impl/commandInterfaceConsole/ProcessModeConsumer.java similarity index 53% rename from python/src/com/jetbrains/commandInterface/console/ProcessModeConsumer.java rename to python/src/com/intellij/python/community/impl/commandInterfaceConsole/ProcessModeConsumer.java index c46d5c7e544f..2944b21ab914 100644 --- a/python/src/com/jetbrains/commandInterface/console/ProcessModeConsumer.java +++ b/python/src/com/intellij/python/community/impl/commandInterfaceConsole/ProcessModeConsumer.java @@ -1,19 +1,5 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.console; +// 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.python.community.impl.commandInterfaceConsole; import com.intellij.execution.console.ProcessBackedConsoleExecuteActionHandler; import com.intellij.execution.process.ProcessHandler; diff --git a/python/src/com/intellij/python/community/impl/commandInterfaceConsole/package-info.java b/python/src/com/intellij/python/community/impl/commandInterfaceConsole/package-info.java new file mode 100644 index 000000000000..125ceb379c0a --- /dev/null +++ b/python/src/com/intellij/python/community/impl/commandInterfaceConsole/package-info.java @@ -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. + +/** + *

Command line console

+ *

+ * Package to display command line console on the Terminal ToolWindow. It supports history, execution, syntax highlighting and so on. + * Entry point is {@link com.intellij.python.community.impl.commandInterfaceConsole.CommandLineConsoleApiKt}. + *

+ *

+ *

Technical details

+ *

+ * This package uses {@link com.intellij.python.community.impl.commandInterfaceConsole.CommandConsole} and it can work in 2 modes: "command-mode" + * to accept, highlight and execute commands, and in "process-mode" to pass stdin/stdout to process it execute. + * See class documentation for details. + *

+ * + * @author Ilya.Kazakevich + * @see com.intellij.python.community.impl.commandInterfaceConsole.CommandLineConsoleApiKt + */ +package com.intellij.python.community.impl.commandInterfaceConsole; \ No newline at end of file diff --git a/python/src/com/jetbrains/commandInterface/command/ArgumentType.java b/python/src/com/jetbrains/commandInterface/command/ArgumentType.java deleted file mode 100644 index c1ca9fb105c6..000000000000 --- a/python/src/com/jetbrains/commandInterface/command/ArgumentType.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.command; - -/** - * Argument type to be used with {@link Argument} - * @author Ilya.Kazakevich - */ -public enum ArgumentType { - /** - * String (actually, anything) - */ - STRING, - /** - * Integer or long - */ - INTEGER -} diff --git a/python/src/com/jetbrains/commandInterface/command/NoArgumentsInfo.java b/python/src/com/jetbrains/commandInterface/command/NoArgumentsInfo.java deleted file mode 100644 index e620365526c0..000000000000 --- a/python/src/com/jetbrains/commandInterface/command/NoArgumentsInfo.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.command; - -import com.intellij.openapi.util.Pair; -import org.jetbrains.annotations.Nullable; - -/** - * TODO: Redundant?! - * Case when command has no arguments (for sure!) - * - * @author Ilya.Kazakevich - */ -public final class NoArgumentsInfo implements ArgumentsInfo { - /** - * Instance to use when command has no arguments - */ - public static final ArgumentsInfo INSTANCE = new NoArgumentsInfo(); - - private NoArgumentsInfo() { - } - - @Nullable - @Override - public Pair getArgument(final int argumentPosition) { - return null; - } -} diff --git a/python/src/com/jetbrains/commandInterface/command/package-info.java b/python/src/com/jetbrains/commandInterface/command/package-info.java deleted file mode 100644 index 96fa66c46a77..000000000000 --- a/python/src/com/jetbrains/commandInterface/command/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - *

Command with arguments and options.

- *

- * Each {@link com.jetbrains.commandInterface.command.Command} may have one or more positional {@link com.jetbrains.commandInterface.command.Argument arguments} - * and several {@link com.jetbrains.commandInterface.command.Option options} (with arguments as well). - * You need to implemenet {@link com.jetbrains.commandInterface.command.Command} first. - *

- * - * @author Ilya.Kazakevich - */ -package com.jetbrains.commandInterface.command; \ No newline at end of file diff --git a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineElementManipulator.java b/python/src/com/jetbrains/commandInterface/commandLine/CommandLineElementManipulator.java deleted file mode 100644 index e97ed2cbb39c..000000000000 --- a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineElementManipulator.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.commandLine; - -import com.intellij.openapi.util.TextRange; -import com.intellij.psi.AbstractElementManipulator; -import org.jetbrains.annotations.NotNull; - -/** - * Manipulator to support reference injection. Will fail with out of it. - * - * @author Ilya.Kazakevich - */ -public final class CommandLineElementManipulator extends AbstractElementManipulator { - - @Override - public CommandLineElement handleContentChange(@NotNull final CommandLineElement element, - @NotNull final TextRange range, - final String newContent) { - return null; - } -} diff --git a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineElementType.java b/python/src/com/jetbrains/commandInterface/commandLine/CommandLineElementType.java deleted file mode 100644 index 2cb1bee8db18..000000000000 --- a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineElementType.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.commandLine; - -import com.intellij.psi.tree.IElementType; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; - -/** - * Command line element type to be used in parser - * - * @author Ilya.Kazakevich - */ -final class CommandLineElementType extends IElementType { - CommandLineElementType(@NotNull @NonNls final String debugName) { - super(debugName, CommandLineLanguage.INSTANCE); - } -} diff --git a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineLanguage.java b/python/src/com/jetbrains/commandInterface/commandLine/CommandLineLanguage.java deleted file mode 100644 index d1e15bd80d07..000000000000 --- a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineLanguage.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.commandLine; - -import com.intellij.lang.Language; -import com.intellij.openapi.fileTypes.LanguageFileType; -import org.jetbrains.annotations.NotNull; - -/** - * Command line language itself - *
my_command --option=value foo
- * @author Ilya.Kazakevich - */ -public final class CommandLineLanguage extends Language { - public static final CommandLineLanguage INSTANCE = new CommandLineLanguage(); - - private CommandLineLanguage() { - super("CommandLine"); - } - - @NotNull - @Override - public LanguageFileType getAssociatedFileType() { - return CommandLineFileType.INSTANCE; - } -} diff --git a/python/src/com/jetbrains/commandInterface/commandLine/CommandLinePart.java b/python/src/com/jetbrains/commandInterface/commandLine/CommandLinePart.java deleted file mode 100644 index 719b1b1f5245..000000000000 --- a/python/src/com/jetbrains/commandInterface/commandLine/CommandLinePart.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.commandLine; - -import com.intellij.psi.PsiElement; -import com.jetbrains.commandInterface.command.Command; -import com.jetbrains.commandInterface.commandLine.psi.CommandLineFile; -import org.jetbrains.annotations.Nullable; - -/** - * Any part of commandline from file till any element - * - * @author Ilya.Kazakevich - */ -public interface CommandLinePart extends PsiElement { - /** - * @return command associated with this command line (if any) - */ - @Nullable - Command findRealCommand(); - - /** - * @return command line file where this part sits - */ - @SuppressWarnings("ClassReferencesSubclass") // Although referencing child is bad idea, this hierarchy is coupled tightly and considered to be solid part - @Nullable - CommandLineFile getCommandLineFile(); -} diff --git a/python/src/com/jetbrains/commandInterface/commandLine/_CommandLineLexer.flex b/python/src/com/jetbrains/commandInterface/commandLine/_CommandLineLexer.flex deleted file mode 100644 index 3d3b476d0543..000000000000 --- a/python/src/com/jetbrains/commandInterface/commandLine/_CommandLineLexer.flex +++ /dev/null @@ -1,62 +0,0 @@ -package com.jetbrains.commandInterface.commandLine; - -import com.intellij.lexer.FlexLexer; -import com.intellij.psi.tree.IElementType; - -import static com.intellij.psi.TokenType.BAD_CHARACTER; -import static com.intellij.psi.TokenType.WHITE_SPACE; -import static com.jetbrains.commandInterface.commandLine.CommandLineElementTypes.*; - -%% - -%{ - public _CommandLineLexer() { - this((java.io.Reader)null); - } -%} - -%public -%class _CommandLineLexer -%implements FlexLexer -%function advance -%type IElementType -%unicode - -EOL=\R -WHITE_SPACE=\s+ - -SPACE=[ \t\n\x0B\f\r]+ -LITERAL_STARTS_FROM_LETTER=[:letter:]([a-zA-Z_0-9]|:|\\|"/"|\.|-|\!|\*)* -LITERAL_STARTS_FROM_DIGIT=[:digit:]([a-zA-Z_0-9]|:|\\|"/"|\.|-|\!|\*)* -LITERAL_STARTS_FROM_SYMBOL=([/\~\.!*]([a-zA-Z_0-9]|:|\\|"/"|\.|-|\!|\*)*) -SPACED_LITERAL_STARTS_FROM_LETTER=\"[:letter:]([a-zA-Z_0-9]|:|\\|"/"|\.|-|[ \t\n\x0B\f\r]|\!|\*)*\" -SPACED_LITERAL_STARTS_FROM_DIGIT=\"[:digit:]([a-zA-Z_0-9]|:|\\|"/"|\.|-|[ \t\n\x0B\f\r]|\!|\*)*\" -SPACED_LITERAL_STARTS_FROM_SYMBOL=\"([/\~\.!*]([a-zA-Z_0-9]|:|\\|"/"|\.|-|[ \t\n\x0B\f\r]|\!|\*)*)\" -SINGLE_Q_SPACED_LITERAL_STARTS_FROM_LETTER='[:letter:]([a-zA-Z_0-9]|:|\\|"/"|\.|-|[ \t\n\x0B\f\r]|\!|\*)*' -SINGLE_Q_SPACED_LITERAL_STARTS_FROM_DIGIT='[:digit:]([a-zA-Z_0-9]|:|\\|"/"|\.|-|[ \t\n\x0B\f\r]|\!|\*)*' -SINGLE_Q_SPACED_LITERAL_STARTS_FROM_SYMBOL='([/\~\.!*]([a-zA-Z_0-9]|:|\\|"/"|\.|-|[ \t\n\x0B\f\r]|\!|\*)*)' -SHORT_OPTION_NAME_TOKEN=-[:letter:] -LONG_OPTION_NAME_TOKEN=--[:letter:](-|[a-zA-Z_0-9])* - -%% - { - {WHITE_SPACE} { return WHITE_SPACE; } - - "=" { return EQ; } - - {SPACE} { return SPACE; } - {LITERAL_STARTS_FROM_LETTER} { return LITERAL_STARTS_FROM_LETTER; } - {LITERAL_STARTS_FROM_DIGIT} { return LITERAL_STARTS_FROM_DIGIT; } - {LITERAL_STARTS_FROM_SYMBOL} { return LITERAL_STARTS_FROM_SYMBOL; } - {SPACED_LITERAL_STARTS_FROM_LETTER} { return SPACED_LITERAL_STARTS_FROM_LETTER; } - {SPACED_LITERAL_STARTS_FROM_DIGIT} { return SPACED_LITERAL_STARTS_FROM_DIGIT; } - {SPACED_LITERAL_STARTS_FROM_SYMBOL} { return SPACED_LITERAL_STARTS_FROM_SYMBOL; } - {SINGLE_Q_SPACED_LITERAL_STARTS_FROM_LETTER} { return SINGLE_Q_SPACED_LITERAL_STARTS_FROM_LETTER; } - {SINGLE_Q_SPACED_LITERAL_STARTS_FROM_DIGIT} { return SINGLE_Q_SPACED_LITERAL_STARTS_FROM_DIGIT; } - {SINGLE_Q_SPACED_LITERAL_STARTS_FROM_SYMBOL} { return SINGLE_Q_SPACED_LITERAL_STARTS_FROM_SYMBOL; } - {SHORT_OPTION_NAME_TOKEN} { return SHORT_OPTION_NAME_TOKEN; } - {LONG_OPTION_NAME_TOKEN} { return LONG_OPTION_NAME_TOKEN; } - -} - -[^] { return BAD_CHARACTER; } diff --git a/python/src/com/jetbrains/commandInterface/commandLine/package-info.java b/python/src/com/jetbrains/commandInterface/commandLine/package-info.java deleted file mode 100644 index b9018d67f986..000000000000 --- a/python/src/com/jetbrains/commandInterface/commandLine/package-info.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - *

GNU command line language PSI

- *

Command line language

- *

- * GNU command line language syntax - * based on POSIX syntax. - *

- *   my_command --option --option-2=argument positional_argument -s
- * 
- *

- *

PSI

- *

Generation based on Grammar-Kit, see .bnf file, do not edit parser nor lexer manually. - * When parsed, {@link com.jetbrains.commandInterface.commandLine.psi.CommandLineFile} is root element for - * {@link com.jetbrains.commandInterface.commandLine.CommandLineLanguage}. - * Warning: always fill {@link com.jetbrains.commandInterface.commandLine.psi.CommandLineFile#setCommandsAndDefaultExecutor(java.util.List, com.jetbrains.commandInterface.command.CommandExecutor)} - * if possible. - *

- *

Extension points

- *

This package has a a lot of extension points (language, inspection etc). Make sure all of them are registered

- * - * @author Ilya.Kazakevich - */ -package com.jetbrains.commandInterface.commandLine; \ No newline at end of file diff --git a/python/src/com/jetbrains/commandInterface/commandLine/psi/impl/package-info.java b/python/src/com/jetbrains/commandInterface/commandLine/psi/impl/package-info.java deleted file mode 100644 index 2a9821b009da..000000000000 --- a/python/src/com/jetbrains/commandInterface/commandLine/psi/impl/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Gnu command line language PSI implementation. - * Do not use this package directly, consider using interfaces from {@link com.jetbrains.commandInterface.commandLine.psi} instead. - * Warning: most files in this package is autogenerated. Do not touch them directly. - * - * @author Ilya.Kazakevich - */ -package com.jetbrains.commandInterface.commandLine.psi.impl; \ No newline at end of file diff --git a/python/src/com/jetbrains/commandInterface/commandLine/psi/package-info.java b/python/src/com/jetbrains/commandInterface/commandLine/psi/package-info.java deleted file mode 100644 index de61f34cdcaa..000000000000 --- a/python/src/com/jetbrains/commandInterface/commandLine/psi/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Gnu command line public PSI interfaces: Command, option, argument etc. - * - * Warning: most files in this package is autogenerated. Do not touch them directly. - * @author Ilya.Kazakevich - */ -package com.jetbrains.commandInterface.commandLine.psi; \ No newline at end of file diff --git a/python/src/com/jetbrains/commandInterface/console/package-info.java b/python/src/com/jetbrains/commandInterface/console/package-info.java deleted file mode 100644 index 7f08dd3099e9..000000000000 --- a/python/src/com/jetbrains/commandInterface/console/package-info.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - *

Command line console

- *

- * Package to display command line console on the Terminal ToolWindow. It supports history, execution, syntax highlighting and so on. - * Entry point is {@link com.jetbrains.commandInterface.console.CommandLineConsoleApiKt}. - *

- *

- *

Technical details

- *

- * This package uses {@link com.jetbrains.commandInterface.console.CommandConsole} and it can work in 2 modes: "command-mode" - * to accept, highlight and execute commands, and in "process-mode" to pass stdin/stdout to process it execute. - * See class documentation for details. - *

- * - * @author Ilya.Kazakevich - * @see com.jetbrains.commandInterface.console.CommandLineConsoleApiKt - */ -package com.jetbrains.commandInterface.console; \ No newline at end of file diff --git a/python/src/com/jetbrains/commandInterface/package-info.java b/python/src/com/jetbrains/commandInterface/package-info.java deleted file mode 100644 index 944cf27843fd..000000000000 --- a/python/src/com/jetbrains/commandInterface/package-info.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - *

Command-line interface

- *

What is the purpose of this package?

- *

- * This package is based on ideas of command-line with command, positional arguments, options and their arguments. - * Initial idea is taken from POSIX - * and enhanced by GNU. - * It also supported by Python in optparse package. - * Command-line is something like - *

my_command positional_argument -s --long-option --another-long-option=arg1 arg2 some_other_arg
- * and this package helps you to parse command lines, highlight errors, display a console-like interface and execute commands. - *

- *

What this package consists of?

- *

- * This package has 3 subpackages: - *

    - *
  1. {@link com.jetbrains.commandInterface.command} contains classes to describe commands, arguments and options. - * It is up to you where to obtain list of available commands, but you should implement {@link com.jetbrains.commandInterface.command.Command} - * first, and create list of it with arguments and options. See package info for more details
  2. - *
  3. {@link com.jetbrains.commandInterface.commandLine} is language based on - * GNU command line representation. - * It has PSI, so it parses command lines into tree of PsiElements. But this package is not only for parsing: - * If you provide list of - * {@link com.jetbrains.commandInterface.command.Command commands} to {@link com.jetbrains.commandInterface.commandLine.psi.CommandLineFile} - * (see {@link com.jetbrains.commandInterface.commandLine.psi.CommandLineFile#setCommandsAndDefaultExecutor(java.util.List, com.jetbrains.commandInterface.command.CommandExecutor)}}), it will inject references - * (to provide autocompletion) and activate inspection to validate options and arguments.
  4. - *
  5. {@link com.jetbrains.commandInterface.console} displays console-like interface at the bottom of the screen to give user - * ability to wotk with your command-line.
  6. - *
- *

- *

How to use this package?

- *
    - *
  1. Implement {@link com.jetbrains.commandInterface.command.Command}
  2. - *
  3. Create list of {@link com.jetbrains.commandInterface.command.Command commands}
  4. - *
  5. Provide it to {@link com.jetbrains.commandInterface.console.CommandLineConsoleApi#createConsole(com.intellij.openapi.module.Module, java.lang.String, java.util.List)}
  6. - *
- * @author Ilya.Kazakevich - */ -package com.jetbrains.commandInterface; \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/commandInterface/commandLine/CommandLineArgsTest.java b/python/testSrc/com/intellij/commandInterface/commandLine/CommandLineArgsTest.java similarity index 73% rename from python/testSrc/com/jetbrains/commandInterface/commandLine/CommandLineArgsTest.java rename to python/testSrc/com/intellij/commandInterface/commandLine/CommandLineArgsTest.java index 3a29a409b235..cb9e2ff3244f 100644 --- a/python/testSrc/com/jetbrains/commandInterface/commandLine/CommandLineArgsTest.java +++ b/python/testSrc/com/intellij/commandInterface/commandLine/CommandLineArgsTest.java @@ -1,23 +1,9 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.commandLine; +// 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.commandInterface.commandLine; +import com.intellij.commandInterface.command.Argument; +import com.intellij.commandInterface.commandLine.psi.CommandLineFile; import com.intellij.openapi.util.Pair; -import com.jetbrains.commandInterface.command.Argument; -import com.jetbrains.commandInterface.commandLine.psi.CommandLineFile; import com.jetbrains.python.fixtures.PyTestCase; import org.jetbrains.annotations.NotNull; import org.junit.Assert; diff --git a/python/testSrc/com/jetbrains/commandInterface/commandLine/CommandLineInspectionTest.java b/python/testSrc/com/intellij/commandInterface/commandLine/CommandLineInspectionTest.java similarity index 65% rename from python/testSrc/com/jetbrains/commandInterface/commandLine/CommandLineInspectionTest.java rename to python/testSrc/com/intellij/commandInterface/commandLine/CommandLineInspectionTest.java index b991fa02ec18..f70e13c7c6aa 100644 --- a/python/testSrc/com/jetbrains/commandInterface/commandLine/CommandLineInspectionTest.java +++ b/python/testSrc/com/intellij/commandInterface/commandLine/CommandLineInspectionTest.java @@ -1,22 +1,8 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.commandLine; +// 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.commandInterface.commandLine; +import com.intellij.commandInterface.commandLine.psi.CommandLineFile; import com.intellij.psi.PsiFile; -import com.jetbrains.commandInterface.commandLine.psi.CommandLineFile; import com.jetbrains.python.fixtures.PyTestCase; import org.junit.Assert; diff --git a/python/testSrc/com/jetbrains/commandInterface/commandLine/CommandLineParserTest.java b/python/testSrc/com/intellij/commandInterface/commandLine/CommandLineParserTest.java similarity index 61% rename from python/testSrc/com/jetbrains/commandInterface/commandLine/CommandLineParserTest.java rename to python/testSrc/com/intellij/commandInterface/commandLine/CommandLineParserTest.java index 43a1789cd648..9abd42dfa671 100644 --- a/python/testSrc/com/jetbrains/commandInterface/commandLine/CommandLineParserTest.java +++ b/python/testSrc/com/intellij/commandInterface/commandLine/CommandLineParserTest.java @@ -1,24 +1,10 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.commandLine; +// 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.commandInterface.commandLine; +import com.intellij.commandInterface.commandLine.psi.CommandLineArgument; +import com.intellij.commandInterface.commandLine.psi.CommandLineFile; import com.intellij.testFramework.ParsingTestCase; -import com.jetbrains.commandInterface.commandLine.psi.CommandLineArgument; -import com.jetbrains.commandInterface.commandLine.psi.CommandLineFile; import org.junit.Assert; diff --git a/python/testSrc/com/jetbrains/commandInterface/commandLine/CommandLineSuggestionTest.java b/python/testSrc/com/intellij/commandInterface/commandLine/CommandLineSuggestionTest.java similarity index 97% rename from python/testSrc/com/jetbrains/commandInterface/commandLine/CommandLineSuggestionTest.java rename to python/testSrc/com/intellij/commandInterface/commandLine/CommandLineSuggestionTest.java index db1796e52a3b..0d698cc75c0b 100644 --- a/python/testSrc/com/jetbrains/commandInterface/commandLine/CommandLineSuggestionTest.java +++ b/python/testSrc/com/intellij/commandInterface/commandLine/CommandLineSuggestionTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.jetbrains.commandInterface.commandLine; +package com.intellij.commandInterface.commandLine; import com.intellij.codeInsight.lookup.LookupElement; import com.jetbrains.python.fixtures.PyTestCase; diff --git a/python/testSrc/com/jetbrains/commandInterface/commandLine/CommandTestTools.java b/python/testSrc/com/intellij/commandInterface/commandLine/CommandTestTools.java similarity index 77% rename from python/testSrc/com/jetbrains/commandInterface/commandLine/CommandTestTools.java rename to python/testSrc/com/intellij/commandInterface/commandLine/CommandTestTools.java index 0473ebda6579..20ce7478f84c 100644 --- a/python/testSrc/com/jetbrains/commandInterface/commandLine/CommandTestTools.java +++ b/python/testSrc/com/intellij/commandInterface/commandLine/CommandTestTools.java @@ -1,26 +1,12 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.commandInterface.commandLine; +// 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.commandInterface.commandLine; +import com.intellij.commandInterface.command.*; +import com.intellij.commandInterface.commandLine.psi.CommandLineFile; import com.intellij.openapi.Disposable; import com.intellij.openapi.util.Pair; import com.intellij.testFramework.fixtures.CodeInsightTestFixture; import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl; -import com.jetbrains.commandInterface.command.*; -import com.jetbrains.commandInterface.commandLine.psi.CommandLineFile; import com.jetbrains.python.PythonTestUtil; import org.easymock.EasyMock; import org.jetbrains.annotations.NotNull; @@ -60,8 +46,8 @@ final class CommandTestTools { final Pair, Boolean> argument = Pair.create(Collections.singletonList("available_argument"), true); options.add(new Option(Pair.create(1, new Argument(new Help("option argument"), argument)), new Help(""), - Collections.emptyList(), - Collections.singletonList("--available-option"))); + Collections.emptyList(), + Collections.singletonList("--available-option"))); options.add(new Option(null, new Help(""), diff --git a/python/testSrc/com/jetbrains/env/CommandBasedProcessRunner.java b/python/testSrc/com/jetbrains/env/CommandBasedProcessRunner.java index 85cfd14794a9..ea7ee853177e 100644 --- a/python/testSrc/com/jetbrains/env/CommandBasedProcessRunner.java +++ b/python/testSrc/com/jetbrains/env/CommandBasedProcessRunner.java @@ -19,8 +19,8 @@ import com.intellij.execution.process.ProcessListener; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.Sdk; -import com.jetbrains.commandInterface.command.Command; -import com.jetbrains.commandInterface.command.SimpleCommand; +import com.intellij.commandInterface.command.Command; +import com.intellij.commandInterface.command.SimpleCommand; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -33,7 +33,7 @@ import java.util.List; * * @author Ilya.Kazakevich * @see PyProcessWithConsoleTestTask - * @see com.jetbrains.commandInterface.command + * @see com.intellij.commandInterface.command */ public class CommandBasedProcessRunner extends ProcessWithConsoleRunner { @NotNull diff --git a/python/testSrc/intellij.python.community.tests.iml b/python/testSrc/intellij.python.community.tests.iml index 0d0dd0fc065e..93cdbaddb099 100644 --- a/python/testSrc/intellij.python.community.tests.iml +++ b/python/testSrc/intellij.python.community.tests.iml @@ -51,5 +51,6 @@ +
\ No newline at end of file