Skip to content

Commit

Permalink
fixed files form Closure #29
Browse files Browse the repository at this point in the history
  • Loading branch information
tdurieux committed Mar 7, 2017
1 parent 33095a0 commit 791990e
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ private boolean isVarInlineForbidden(Var var) {
*/
private boolean isInlinableObject(List<Reference> refs) {
boolean ret = false;
Set<String> validProperties = Sets.newHashSet();
for (Reference ref : refs) {
Node name = ref.getNode();
Node parent = ref.getParent();
Expand All @@ -178,6 +179,14 @@ private boolean isInlinableObject(List<Reference> refs) {
// We short-circuit this problem by bailing out if we see a reference
// to a property that isn't defined on the object literal. This
// isn't a perfect algorithm, but it should catch most cases.
String propName = parent.getLastChild().getString();
if (!validProperties.contains(propName)) {
if (NodeUtil.isVarOrSimpleAssignLhs(parent, gramps)) {
validProperties.add(propName);
} else {
return false;
}
}
continue;
}

Expand Down Expand Up @@ -213,6 +222,7 @@ private boolean isInlinableObject(List<Reference> refs) {
return false;
}

validProperties.add(child.getString());

Node childVal = child.getFirstChild();
// Check if childVal is the parent of any of the passed in
Expand Down

0 comments on commit 791990e

Please sign in to comment.