Package org.jline.builtins
Class Completers.TreeCompleter
- java.lang.Object
-
- org.jline.builtins.Completers.TreeCompleter
-
- All Implemented Interfaces:
org.jline.reader.Completer
- Enclosing class:
- Completers
public static class Completers.TreeCompleter extends java.lang.Object implements org.jline.reader.Completer
A completer that supports hierarchical command structures.This completer allows defining a tree of command nodes, where each node can have its own completer and child nodes. It's useful for implementing command hierarchies where different completions are available at different levels of the command structure.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Completers.TreeCompleter.Node
Represents a node in the completion tree.
-
Constructor Summary
Constructors Constructor Description TreeCompleter(java.util.List<Completers.TreeCompleter.Node> nodes)
Creates a new TreeCompleter with the specified list of nodes.TreeCompleter(Completers.TreeCompleter.Node... nodes)
Creates a new TreeCompleter with the specified nodes.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
complete(org.jline.reader.LineReader reader, org.jline.reader.ParsedLine line, java.util.List<org.jline.reader.Candidate> candidates)
Completes the current input line using the tree structure.static Completers.TreeCompleter.Node
node(java.lang.Object... objs)
Creates a new node for the completion tree.
-
-
-
Constructor Detail
-
TreeCompleter
public TreeCompleter(Completers.TreeCompleter.Node... nodes)
Creates a new TreeCompleter with the specified nodes.- Parameters:
nodes
- the root nodes of the completion tree
-
TreeCompleter
public TreeCompleter(java.util.List<Completers.TreeCompleter.Node> nodes)
Creates a new TreeCompleter with the specified list of nodes.- Parameters:
nodes
- the list of root nodes of the completion tree
-
-
Method Detail
-
node
public static Completers.TreeCompleter.Node node(java.lang.Object... objs)
Creates a new node for the completion tree.This method accepts various types of objects and constructs a node based on their types:
- String objects are converted to Candidate objects
- Candidate objects are used directly
- Node objects are added as child nodes
- Completer objects are used as the node's completer
- Parameters:
objs
- the objects to include in the node- Returns:
- a new Node instance
- Throws:
java.lang.IllegalArgumentException
- if the objects cannot form a valid node
-
complete
public void complete(org.jline.reader.LineReader reader, org.jline.reader.ParsedLine line, java.util.List<org.jline.reader.Candidate> candidates)
Completes the current input line using the tree structure.Delegates to the RegexCompleter which handles the tree structure.
- Specified by:
complete
in interfaceorg.jline.reader.Completer
- Parameters:
reader
- the line readerline
- the parsed command linecandidates
- the list to add completion candidates to
-
-