Search in sources :

Example 1 with Help

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

the class CommandLineDocumentationProvider method generateDoc.

@Nullable
@Override
public String generateDoc(final PsiElement element, @Nullable final PsiElement originalElement) {
    final Help help = findHelp(element);
    if (help == null) {
        return null;
    }
    final String helpText = help.getHelpString();
    // For some reason we can't return empty sting (leads to "fetching doc" string)
    return (StringUtil.isEmptyOrSpaces(helpText) ? null : helpText);
}
Also used : Help(com.jetbrains.commandInterface.command.Help) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with Help

use of com.jetbrains.commandInterface.command.Help 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)

Example 3 with Help

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

the class CommandLineCommandReference method getVariants.

@NotNull
@Override
public Object[] getVariants() {
    final CommandLineFile file = getCommandLineFile();
    if (file == null) {
        return EMPTY_ARRAY;
    }
    final List<Command> commands = file.getCommands();
    if (commands == null) {
        return EMPTY_ARRAY;
    }
    final LookupWithIndentsBuilder result = new LookupWithIndentsBuilder();
    for (final Command command : commands) {
        final LookupElementBuilder lookupElementBuilder = LookupElementBuilder.create(command.getName());
        final Help help = command.getHelp(true);
        result.addElement(lookupElementBuilder, (help != null ? help.getHelpString() : null));
    }
    return result.getResult();
}
Also used : Help(com.jetbrains.commandInterface.command.Help) Command(com.jetbrains.commandInterface.command.Command) CommandLineCommand(com.jetbrains.commandInterface.commandLine.psi.CommandLineCommand) CommandLineFile(com.jetbrains.commandInterface.commandLine.psi.CommandLineFile) LookupElementBuilder(com.intellij.codeInsight.lookup.LookupElementBuilder) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with Help

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

the class CommandLineDocumentationProvider method getUrlFor.

@Override
public List<String> getUrlFor(final PsiElement element, final PsiElement originalElement) {
    final Help help = findHelp(element);
    if (help == null) {
        return null;
    }
    final String externalHelpUrl = help.getExternalHelpUrl();
    if (externalHelpUrl != null) {
        return Collections.singletonList(externalHelpUrl);
    }
    return null;
}
Also used : Help(com.jetbrains.commandInterface.command.Help)

Aggregations

Help (com.jetbrains.commandInterface.command.Help)4 NotNull (org.jetbrains.annotations.NotNull)2 LookupElementBuilder (com.intellij.codeInsight.lookup.LookupElementBuilder)1 Argument (com.jetbrains.commandInterface.command.Argument)1 Command (com.jetbrains.commandInterface.command.Command)1 Option (com.jetbrains.commandInterface.command.Option)1 CommandLineArgument (com.jetbrains.commandInterface.commandLine.psi.CommandLineArgument)1 CommandLineCommand (com.jetbrains.commandInterface.commandLine.psi.CommandLineCommand)1 CommandLineFile (com.jetbrains.commandInterface.commandLine.psi.CommandLineFile)1 Nullable (org.jetbrains.annotations.Nullable)1