-
Notifications
You must be signed in to change notification settings - Fork 28
fixes bug 1451450, parse VariantExpressions with a MessageReference inside #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…nside This switches the props of VariantExpression from having a string `id` to a `MessageReference` `of`
@@ -235,7 +235,7 @@ def serialize_attribute_expression(expr): | |||
|
|||
def serialize_variant_expression(expr): | |||
return "{}[{}]".format( | |||
serialize_identifier(expr.id), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change this to serialize_expression(expr.of)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow-up for this landed.
fluent/syntax/ast.py
Outdated
super(VariantExpression, self).__init__(**kwargs) | ||
self.id = id | ||
self.of = of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Pike, @zbraniecki - do you have opinions on what we should call this? It should fit both MessageReference
(now) as well as as ExternalArgument
(later).
I looked up a few examples: a.b
parses as Attribute(value=Name(id="a"), attr="b")
in Python and as MemberExpression(object=Identifier(name="a"), property=Identifier(name="b"))
in JavaScript.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no strong opinion, I prefer both Python and JS naming scheme over of
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest object
as it's generic enough to fit a wide range of expressions. Another idea: how about reference
, or ref
?
-
-term[varname]
would parse asVariantExpression(ref=MessageReference(id=Identifier(name="-term")), key=VariantName(name="varname"))
. -
$arg[varname]
would parse asVariantExpression(ref=ExternalArgument(id=Identifier(name="-term")), key=VariantName(name="varname"))
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ref
works for me.
@Pike - I think we should also do this for |
Actually, I think that'd make it harder to do attribute checks. There's a profound semantic difference between |
Sorry, I didn't make it clear. By "the same reasons" I meant the fact that we'll need to support For compare-locales it sounds like we should have a separate check for symmetrical In fact, perhaps we should consider introducing |
I took a look at I'd rather not block fixing the term variant fix we have in Firefox today by having to do full attribute support. |
OK, I see. I'm a bit worried about this fix then. I think it's a sound design for |
I really liked https://github.com/estools/esquery when doing my js ast jazz for the react editors, I've contemplated doing something similar. I also found traverse to be pretty excessive, i.e., it goes to each number in spans, which I don't need in compare-locales checks at all ;-) |
Let's decide what the name of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me with the s/of/ref
change.
This switches the props of VariantExpression from having a
string
id
to aMessageReference
of
https://bugzilla.mozilla.org/show_bug.cgi?id=1451450