in plc4go/tools/plc4xbrowser/ui/commands.go [666:697]
func (c Command) Completions(currentCommandText string) (entries []string) {
if c.Name == rootCommandIndicator && len(currentCommandText) == 0 {
// We don't return anything here to not pollute the command text by default
return
}
if c.acceptsCurrentText(currentCommandText) {
currentCommandPrefix := c.currentCommandPrefix()
doesCommandTextTargetSubCommand := c.doesCommandTextTargetSubCommand(currentCommandPrefix)
if c.hasDirectExecution() && !doesCommandTextTargetSubCommand {
if c.parameterSuggestions != nil {
preparedForParameters := c.prepareForParameters(currentCommandText)
for _, parameterSuggestion := range c.parameterSuggestions(preparedForParameters) {
entries = append(entries, currentCommandPrefix+parameterSuggestion)
}
} else {
entries = append(entries, c.Name)
}
}
if doesCommandTextTargetSubCommand {
remainder := c.prepareForSubCommand(currentCommandText)
for _, command := range c.subCommands {
for _, subCommandCompletions := range command.Completions(remainder) {
entries = append(entries, currentCommandPrefix+subCommandCompletions)
}
}
}
} else if strings.HasPrefix(c.Name, currentCommandText) {
// Suggest ourselves if we start with the current letter
entries = append(entries, c.Name)
}
return
}