Search in sources :

Example 6 with Argument

use of com.jetbrains.commandInterface.command.Argument in project intellij-community by JetBrains.

the class CommandLineArgumentReference method getVariants.

@NotNull
@Override
public Object[] getVariants() {
    final LookupWithIndentsBuilder builder = new LookupWithIndentsBuilder();
    final Argument argument = getElement().findRealArgument();
    final Option argumentOption = getElement().findOptionForOptionArgument();
    final Collection<String> argumentValues = (argument != null ? argument.getAvailableValues() : null);
    // priority is used to display args before options
    if (argumentValues != null) {
        for (final String value : argumentValues) {
            final Help help = getElement().findBestHelp();
            final String helpText = (help != null ? help.getHelpString() : null);
            builder.addElement(LookupElementBuilder.create(value).withBoldness(true), helpText, 1);
        }
    }
    final ValidationResult validationResult = getValidationResult();
    if (validationResult == null) {
        return EMPTY_ARRAY;
    }
    if (argumentOption == null) {
        // If not option argument
        for (final Option option : validationResult.getUnusedOptions()) {
            for (final String value : option.getAllNames()) {
                builder.addElement(LookupElementBuilder.create(value), option.getHelp().getHelpString(), 0);
            }
        }
    }
    return builder.getResult();
}
Also used : Help(com.jetbrains.commandInterface.command.Help) CommandLineArgument(com.jetbrains.commandInterface.commandLine.psi.CommandLineArgument) Argument(com.jetbrains.commandInterface.command.Argument) Option(com.jetbrains.commandInterface.command.Option) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Argument (com.jetbrains.commandInterface.command.Argument)6 Option (com.jetbrains.commandInterface.command.Option)3 CommandLineArgument (com.jetbrains.commandInterface.commandLine.psi.CommandLineArgument)2 EditorImpl (com.intellij.openapi.editor.impl.EditorImpl)1 CaretRectangle (com.intellij.openapi.editor.impl.EditorImpl.CaretRectangle)1 Help (com.jetbrains.commandInterface.command.Help)1 CommandLineFile (com.jetbrains.commandInterface.commandLine.psi.CommandLineFile)1 CommandLineOption (com.jetbrains.commandInterface.commandLine.psi.CommandLineOption)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1