Skip to content

Commit 124c2aa

Browse files
zbranieckistasm
authored andcommitted
Backport Remove tags (#110)
(cherry picked from commit ca5f604)
1 parent beabada commit 124c2aa

23 files changed

+43
-575
lines changed

fluent-syntax/src/ast.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,12 @@ export class Entry extends SyntaxNode {
4040
}
4141

4242
export class Message extends Entry {
43-
constructor(id, value = null, attributes = [], tags = [], comment = null) {
43+
constructor(id, value = null, attributes = [], comment = null) {
4444
super();
4545
this.type = 'Message';
4646
this.id = id;
4747
this.value = value;
4848
this.attributes = attributes;
49-
this.tags = tags;
5049
this.comment = comment;
5150
}
5251
}
@@ -159,14 +158,6 @@ export class Attribute extends SyntaxNode {
159158
}
160159
}
161160

162-
export class Tag extends SyntaxNode {
163-
constructor(name) {
164-
super();
165-
this.type = 'Tag';
166-
this.name = name;
167-
}
168-
}
169-
170161
export class Variant extends SyntaxNode {
171162
constructor(key, value, def = false) {
172163
super();

fluent-syntax/src/errors.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ function getErrorMessage(code, args) {
3939
return 'Expected one of the variants to be marked as default (*)';
4040
case 'E0011':
4141
return 'Expected at least one variant after "->"';
42-
case 'E0012':
43-
return 'Tags cannot be added to messages with attributes';
4442
case 'E0013':
4543
return 'Expected variant key';
4644
case 'E0014':

fluent-syntax/src/ftlstream.js

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ export class FTLParserStream extends ParserStream {
205205

206206
if (this.currentPeekIs('}') ||
207207
this.currentPeekIs('.') ||
208-
this.currentPeekIs('#') ||
209208
this.currentPeekIs('[') ||
210209
this.currentPeekIs('*')) {
211210
this.resetPeek();
@@ -216,33 +215,6 @@ export class FTLParserStream extends ParserStream {
216215
return true;
217216
}
218217

219-
isPeekNextLineTagStart() {
220-
if (!this.currentPeekIs('\n')) {
221-
return false;
222-
}
223-
224-
this.peek();
225-
226-
this.peekBlankLines();
227-
228-
const ptr = this.getPeekIndex();
229-
230-
this.peekInlineWS();
231-
232-
if (this.getPeekIndex() - ptr === 0) {
233-
this.resetPeek();
234-
return false;
235-
}
236-
237-
if (this.currentPeekIs('#')) {
238-
this.resetPeek();
239-
return true;
240-
}
241-
242-
this.resetPeek();
243-
return false;
244-
}
245-
246218
skipToNextEntryStart() {
247219
while (this.ch) {
248220
if (this.currentIs('\n') && !this.peekCharIs('\n')) {

fluent-syntax/src/parser.js

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default class FluentParser {
4242

4343
// Poor man's decorators.
4444
[
45-
'getComment', 'getSection', 'getMessage', 'getAttribute', 'getTag',
45+
'getComment', 'getSection', 'getMessage', 'getAttribute',
4646
'getIdentifier', 'getVariant', 'getSymbol', 'getNumber', 'getPattern',
4747
'getTextElement', 'getPlaceable', 'getExpression',
4848
'getSelectorExpression', 'getCallArg', 'getString', 'getLiteral',
@@ -189,7 +189,6 @@ export default class FluentParser {
189189

190190
let pattern;
191191
let attrs;
192-
let tags;
193192

194193
if (ps.currentIs('=')) {
195194
ps.next();
@@ -203,18 +202,11 @@ export default class FluentParser {
203202
attrs = this.getAttributes(ps);
204203
}
205204

206-
if (ps.isPeekNextLineTagStart()) {
207-
if (attrs !== undefined) {
208-
throw new ParseError('E0012');
209-
}
210-
tags = this.getTags(ps);
211-
}
212-
213205
if (pattern === undefined && attrs === undefined) {
214206
throw new ParseError('E0005', id.name);
215207
}
216208

217-
return new AST.Message(id, pattern, attrs, tags, comment);
209+
return new AST.Message(id, pattern, attrs, comment);
218210
}
219211

220212
getAttribute(ps) {
@@ -251,28 +243,6 @@ export default class FluentParser {
251243
return attrs;
252244
}
253245

254-
getTag(ps) {
255-
ps.expectChar('#');
256-
const symb = this.getSymbol(ps);
257-
return new AST.Tag(symb);
258-
}
259-
260-
getTags(ps) {
261-
const tags = [];
262-
263-
while (true) {
264-
ps.expectIndent();
265-
266-
const tag = this.getTag(ps);
267-
tags.push(tag);
268-
269-
if (!ps.isPeekNextLineTagStart()) {
270-
break;
271-
}
272-
}
273-
return tags;
274-
}
275-
276246
getIdentifier(ps) {
277247
let name = '';
278248

fluent-syntax/src/serializer.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,6 @@ function serializeMessage(message) {
9292
parts.push(serializeValue(message.value));
9393
}
9494

95-
for (const tag of message.tags) {
96-
parts.push(serializeTag(tag));
97-
}
98-
9995
for (const attribute of message.attributes) {
10096
parts.push(serializeAttribute(attribute));
10197
}
@@ -105,12 +101,6 @@ function serializeMessage(message) {
105101
}
106102

107103

108-
function serializeTag(tag) {
109-
const name = serializeSymbol(tag.name);
110-
return `\n #${name}`;
111-
}
112-
113-
114104
function serializeAttribute(attribute) {
115105
const id = serializeIdentifier(attribute.id);
116106
const value = indent(serializeValue(attribute.value));

fluent-syntax/test/entry_test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ suite('Parse entry', function() {
1919
"end": 9,
2020
"type": "Span"
2121
},
22-
"tags": [],
2322
"value": {
2423
"elements": [
2524
{
@@ -72,7 +71,6 @@ suite('Serialize entry', function() {
7271
"end": 9,
7372
"type": "Span"
7473
},
75-
"tags": [],
7674
"value": {
7775
"elements": [
7876
{

fluent-syntax/test/fixtures_behavior/second_tag_starts_from_nl.ftl

Lines changed: 0 additions & 4 deletions
This file was deleted.

fluent-syntax/test/fixtures_behavior/tag_and_attribute_together.ftl

Lines changed: 0 additions & 4 deletions
This file was deleted.

fluent-syntax/test/fixtures_behavior/tag_starts_from_nl.ftl

Lines changed: 0 additions & 3 deletions
This file was deleted.

fluent-syntax/test/fixtures_structure/elements_indent.ftl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,3 @@ foo = Foo
44
bar = Bar
55
.attr1 = Bar Attr 1
66
.attr2 = Bar Attr 2
7-
8-
baz = Baz
9-
#tag
10-
11-
qux = Qux
12-
#tag1
13-
#tag2

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy