Skip to content

Commit 66a6719

Browse files
authored
Remove tags (#37)
1 parent 199ad93 commit 66a6719

File tree

6 files changed

+3
-95
lines changed

6 files changed

+3
-95
lines changed

src/resolve.rs

-22
Original file line numberDiff line numberDiff line change
@@ -98,28 +98,6 @@ impl ResolveValue for ast::Expression {
9898
expression: None,
9999
ref variants,
100100
} => select_default(variants).and_then(|variant| variant.value.to_value(env)),
101-
ast::Expression::SelectExpression {
102-
expression: Some(box ast::Expression::MessageReference { ref id }),
103-
ref variants,
104-
} => {
105-
let tags = env.ctx
106-
.get_message(&id.name)
107-
.and_then(|message| message.tags.as_ref());
108-
109-
if let Some(tags) = tags {
110-
for variant in variants {
111-
if let ast::VarKey::Symbol(ref symbol) = variant.key {
112-
for tag in tags.iter() {
113-
if symbol.name == tag.name.name {
114-
return variant.value.to_value(env);
115-
}
116-
}
117-
}
118-
}
119-
}
120-
121-
select_default(variants).and_then(|variant| variant.value.to_value(env))
122-
}
123101
ast::Expression::SelectExpression {
124102
ref expression,
125103
ref variants,

src/syntax/ast.rs

-6
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ pub struct Message {
2222
pub id: Identifier,
2323
pub value: Option<Pattern>,
2424
pub attributes: Option<Vec<Attribute>>,
25-
pub tags: Option<Vec<Tag>>,
2625
pub comment: Option<Comment>,
2726
}
2827

@@ -80,11 +79,6 @@ pub struct Attribute {
8079
pub value: Pattern,
8180
}
8281

83-
#[derive(Debug, PartialEq)]
84-
pub struct Tag {
85-
pub name: Symbol,
86-
}
87-
8882
#[derive(Debug, PartialEq)]
8983
pub struct Variant {
9084
pub key: VarKey,

src/syntax/ftlstream.rs

+2-27
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ pub trait FTLParserStream<I> {
1919
fn is_peek_next_line_variant_start(&mut self) -> bool;
2020
fn is_peek_next_line_attribute_start(&mut self) -> bool;
2121
fn is_peek_next_line_pattern(&mut self) -> bool;
22-
fn is_peek_next_line_tag_start(&mut self) -> bool;
2322
fn skip_to_next_entry_start(&mut self);
2423
fn take_id_start(&mut self) -> Result<char>;
2524
fn take_id_char(&mut self) -> Option<char>;
@@ -183,8 +182,8 @@ where
183182
return false;
184183
}
185184

186-
if self.current_peek_is('}') || self.current_peek_is('.') || self.current_peek_is('#')
187-
|| self.current_peek_is('[') || self.current_peek_is('*')
185+
if self.current_peek_is('}') || self.current_peek_is('.') || self.current_peek_is('[')
186+
|| self.current_peek_is('*')
188187
{
189188
self.reset_peek();
190189
return false;
@@ -194,30 +193,6 @@ where
194193
true
195194
}
196195

197-
fn is_peek_next_line_tag_start(&mut self) -> bool {
198-
if !self.current_peek_is('\n') {
199-
return false;
200-
}
201-
self.peek();
202-
203-
let ptr = self.get_peek_index();
204-
205-
self.peek_line_ws();
206-
207-
if self.get_peek_index() - ptr == 0 {
208-
self.reset_peek();
209-
return false;
210-
}
211-
212-
if self.current_peek_is('#') {
213-
self.reset_peek();
214-
return true;
215-
}
216-
217-
self.reset_peek();
218-
false
219-
}
220-
221196
fn skip_to_next_entry_start(&mut self) {
222197
while let Some(_) = self.next() {
223198
if self.current_is('\n') && !self.peek_char_is('\n')

src/syntax/parser.rs

-32
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,6 @@ where
170170
None
171171
};
172172

173-
let tags = if ps.is_peek_next_line_tag_start() {
174-
if attributes.is_some() {
175-
return error!(ErrorKind::Generic);
176-
}
177-
Some(get_tags(ps)?)
178-
} else {
179-
None
180-
};
181-
182173
if pattern.is_none() && attributes.is_none() {
183174
return error!(ErrorKind::MissingField {
184175
entry_id: id.name,
@@ -190,7 +181,6 @@ where
190181
id,
191182
value: pattern,
192183
attributes,
193-
tags,
194184
comment,
195185
}))
196186
}
@@ -232,28 +222,6 @@ where
232222
Ok(attributes)
233223
}
234224

235-
fn get_tags<I>(ps: &mut ParserStream<I>) -> Result<Vec<ast::Tag>>
236-
where
237-
I: Iterator<Item = char>,
238-
{
239-
let mut tags = vec![];
240-
loop {
241-
ps.expect_char('\n')?;
242-
ps.skip_line_ws();
243-
244-
ps.expect_char('#')?;
245-
246-
let symbol = get_symbol(ps)?;
247-
248-
tags.push(ast::Tag { name: symbol });
249-
250-
if !ps.is_peek_next_line_tag_start() {
251-
break;
252-
}
253-
}
254-
Ok(tags)
255-
}
256-
257225
fn get_identifier<I>(ps: &mut ParserStream<I>) -> Result<ast::Identifier>
258226
where
259227
I: Iterator<Item = char>,

tests/fixtures/parser/ftl/07-tags.ftl

-8
This file was deleted.

tests/resolve_select_expression.rs

+1
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ baz-unknown =
240240
}
241241

242242
#[test]
243+
#[ignore]
243244
fn select_expression_message_selector() {
244245
let mut ctx = MessageContext::new(&["x-testing"]);
245246

0 commit comments

Comments
 (0)