-
-
Notifications
You must be signed in to change notification settings - Fork 124
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
Filter out DataBinding expressions when extracting resources from xml files #543
Filter out DataBinding expressions when extracting resources from xml files #543
Conversation
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.
Thank you for this contribution! Very much appreciated. Only one change I'd like to see.
|
||
import com.autonomousapps.advice.Advice | ||
|
||
class DataBindingWithExpressionsProject( |
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.
Please rewrite this fixture to use a similar style to AttrResWithNullProject
from the spec just above your new one. This is the first style of fixture used in this project and... I hate it. I'd like to eliminate it entirely at some point.
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.
Sure, not a problem. Please check my latest commit with an updated DataBindingWithExpressionsProject
implementation.
* | ||
* Will return `null` if the map entry doesn't match an expected pattern. | ||
*/ | ||
fun from(mapEntry: Map.Entry<String, String>): AttrRef? { | ||
if (mapEntry.isId()) return null | ||
if (mapEntry.isToolsAttr()) return null | ||
if (mapEntry.isDataBindingExpression()) return null |
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.
Thank you for updating this in both locations!
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.
LGTM!
I've tried running
buildHealth
with0.79.0
version of the plugin and got the same exception as in #531 and #542. The only difference that it has nothing to do with@null
in my case and is actually caused by data binding expressions likebinding:subtitle="@{model.subtitle}"
.The fix from #534 actually prevents the exception in my case, but it doesn't cover all databinding related scenarios. For example, expressions like
binding:outlineRadius="@{@dimen/radius_normal}"
are still parsed as a validAttrRef(type = "{@dimen", id = "radius_normal}")
object.This PR introduces the following changes:
AttrRef.from
now always returnsnull
for all data binding expressions.ResSpec.groovy
runs one more case which is specially dedicated to data binding expressions.