aboutsummaryrefslogtreecommitdiff
path: root/azalea-brigadier/src/context
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-02-01 00:12:46 -0600
committermat <github@matdoes.dev>2022-02-01 00:12:46 -0600
commitd9e52f8d965473517ddf6f11f9ac3be9aa14e14d (patch)
treed29b0e3184df0973ba07927a572814e4594f9e9e /azalea-brigadier/src/context
parent30a86e1de5d8bf302f05d091b0a7b4cc6721d911 (diff)
downloadazalea-drasl-d9e52f8d965473517ddf6f11f9ac3be9aa14e14d.tar.xz
b
Diffstat (limited to 'azalea-brigadier/src/context')
-rw-r--r--azalea-brigadier/src/context/command_context.rs4
-rw-r--r--azalea-brigadier/src/context/command_context_builder.rs21
-rw-r--r--azalea-brigadier/src/context/parsed_command_node.rs8
-rw-r--r--azalea-brigadier/src/context/suggestion_context.rs4
4 files changed, 20 insertions, 17 deletions
diff --git a/azalea-brigadier/src/context/command_context.rs b/azalea-brigadier/src/context/command_context.rs
index 4f0b4d49..8db1487f 100644
--- a/azalea-brigadier/src/context/command_context.rs
+++ b/azalea-brigadier/src/context/command_context.rs
@@ -4,7 +4,7 @@ use super::{
};
use crate::{
arguments::argument_type::ArgumentType, command::Command, redirect_modifier::RedirectModifier,
- tree::command_node::CommandNode,
+ tree::command_node::CommandNodeTrait,
};
use std::{any::Any, collections::HashMap};
@@ -13,7 +13,7 @@ pub struct CommandContext<'a, S> {
input: String,
command: &'a dyn Command<S>,
arguments: HashMap<String, ParsedArgument<Box<dyn Any>>>,
- root_node: &'a dyn CommandNode<S>,
+ root_node: &'a dyn CommandNodeTrait<S>,
nodes: Vec<ParsedCommandNode<S>>,
range: StringRange,
child: Option<&'a CommandContext<'a, S>>,
diff --git a/azalea-brigadier/src/context/command_context_builder.rs b/azalea-brigadier/src/context/command_context_builder.rs
index 95da4064..969f9cfd 100644
--- a/azalea-brigadier/src/context/command_context_builder.rs
+++ b/azalea-brigadier/src/context/command_context_builder.rs
@@ -1,10 +1,10 @@
-use std::{any::Any, collections::HashMap};
-
use crate::{
arguments::argument_type::ArgumentType, command::Command,
command_dispatcher::CommandDispatcher, redirect_modifier::RedirectModifier,
- tree::command_node::CommandNode,
+ tree::command_node::CommandNodeTrait,
};
+use std::fmt::Debug;
+use std::{any::Any, collections::HashMap};
use super::{
command_context::CommandContext, parsed_argument::ParsedArgument,
@@ -27,12 +27,12 @@ use super::{
#[derive(Clone)]
pub struct CommandContextBuilder<'a, S> {
arguments: HashMap<String, ParsedArgument<Box<dyn Any>>>,
- root_node: &'a dyn CommandNode<S>,
+ root_node: &'a dyn CommandNodeTrait<S>,
nodes: Vec<ParsedCommandNode<S>>,
dispatcher: CommandDispatcher<'a, S>,
source: S,
command: Box<dyn Command<S>>,
- child: Option<CommandContextBuilder<'a, S>>,
+ child: Box<Option<CommandContextBuilder<'a, S>>>,
range: StringRange,
modifier: Option<Box<dyn RedirectModifier<S>>>,
forks: bool,
@@ -45,11 +45,14 @@ pub struct CommandContextBuilder<'a, S> {
// this.range = StringRange.at(start);
// }
-impl<S> CommandContextBuilder<'_, S> {
+impl<S> CommandContextBuilder<'_, S>
+where
+ ,
+{
pub fn new(
dispatcher: CommandDispatcher<S>,
source: S,
- root_node: dyn CommandNode<S>,
+ root_node: dyn CommandNodeTrait<S>,
start: usize,
) -> Self {
Self {
@@ -70,7 +73,7 @@ impl<S> CommandContextBuilder<'_, S> {
&self.source
}
- pub fn root_node(&self) -> &dyn CommandNode<S> {
+ pub fn root_node(&self) -> &dyn CommandNodeTrait<S> {
&self.root_node
}
@@ -88,7 +91,7 @@ impl<S> CommandContextBuilder<'_, S> {
self
}
- pub fn with_node(mut self, node: dyn CommandNode<S>, range: StringRange) -> Self {
+ pub fn with_node(mut self, node: dyn CommandNodeTrait<S>, range: StringRange) -> Self {
self.nodes.push(ParsedCommandNode::new(node, range));
self.range = StringRange::encompassing(&self.range, &range);
self.modifier = node.redirect_modifier();
diff --git a/azalea-brigadier/src/context/parsed_command_node.rs b/azalea-brigadier/src/context/parsed_command_node.rs
index 16c6ed8b..21d1b2e9 100644
--- a/azalea-brigadier/src/context/parsed_command_node.rs
+++ b/azalea-brigadier/src/context/parsed_command_node.rs
@@ -1,17 +1,17 @@
use super::string_range::StringRange;
-use crate::tree::command_node::CommandNode;
+use crate::tree::command_node::CommandNodeTrait;
pub struct ParsedCommandNode<S> {
- node: Box<dyn CommandNode<S>>,
+ node: Box<dyn CommandNodeTrait<S>>,
range: StringRange,
}
impl<S> ParsedCommandNode<S> {
- fn new(node: dyn CommandNode<S>, range: StringRange) -> Self {
+ fn new(node: dyn CommandNodeTrait<S>, range: StringRange) -> Self {
Self { node, range }
}
- fn node(&self) -> &dyn CommandNode<S> {
+ fn node(&self) -> &dyn CommandNodeTrait<S> {
&self.node
}
diff --git a/azalea-brigadier/src/context/suggestion_context.rs b/azalea-brigadier/src/context/suggestion_context.rs
index 252cb6ed..51a053c1 100644
--- a/azalea-brigadier/src/context/suggestion_context.rs
+++ b/azalea-brigadier/src/context/suggestion_context.rs
@@ -1,6 +1,6 @@
-use crate::tree::command_node::CommandNode;
+use crate::tree::command_node::CommandNodeTrait;
pub struct SuggestionContext<'a, S> {
- parent: &'a dyn CommandNode<S>,
+ parent: &'a dyn CommandNodeTrait<S>,
start_pos: usize,
}