                      #(call-method %1 (str 'set method) %2)
                      node replacements))
 
+(s/defn -maybe-set-operands!
+  [node replacements & methods]
+  (->> methods
+       (map #(-maybe-set-operand! %1 node replacements))
+       doall
+       (some identity)))
+
 (s/defn -replace-identifier!
   "If this node is capable of causing syntax ambiguities,
    try replacing parts of it to observe the ambiguity"
   [node :- IASTNode replacements :- {s/Str IASTNode}]
   (condp instance? node
-    IASTIfStatement                (-maybe-set-operand! "ConditionExpression"  node replacements)
-    IASTForStatement               (-maybe-set-operand! "ConditionExpression"  node replacements)
-    IASTWhileStatement             (-maybe-set-operand! "Condition"  node replacements)
-    IASTDoStatement                (-maybe-set-operand! "Condition"  node replacements)
-    IASTEqualsInitializer          (-maybe-set-operand! "InitializerClause"  node replacements)
-    IASTFunctionCallExpression     (-maybe-set-args!               node replacements)
-    IASTCastExpression             (-maybe-set-operand! "Operand"  node replacements)
-    IASTUnaryExpression            (-maybe-set-operand! "Operand"  node replacements)
-
-    IASTBinaryExpression           (let [op1 (-maybe-set-operand! "Operand1" node replacements)
-                                         op2 (-maybe-set-operand! "Operand2" node replacements)]
-                                     (or op1 op2))
-    IASTArraySubscriptExpression   (let [op1 (-maybe-set-operand! "Argument" node replacements)
-                                         op2 (-maybe-set-operand! "ArrayExpression" node replacements)]
-                                     (or op1 op2))
+    IASTFunctionCallExpression   (-maybe-set-args!      node replacements)
+    IASTExpressionList           (-maybe-set-expr-list! node replacements)
+    IASTIfStatement              (-maybe-set-operands!  node replacements "ConditionExpression")
+    IASTForStatement             (-maybe-set-operands!  node replacements "ConditionExpression")
+    IASTWhileStatement           (-maybe-set-operands!  node replacements "Condition")
+    IASTDoStatement              (-maybe-set-operands!  node replacements "Condition")
+    IASTEqualsInitializer        (-maybe-set-operands!  node replacements "InitializerClause")
+    IASTCastExpression           (-maybe-set-operands!  node replacements "Operand")
+    IASTUnaryExpression          (-maybe-set-operands!  node replacements "Operand")
+    IASTBinaryExpression         (-maybe-set-operands!  node replacements "Operand1" "Operand2")
+    IASTArraySubscriptExpression (-maybe-set-operands!  node replacements "Argument" "ArrayExpression")
+    IASTFieldReference           (-maybe-set-operands!  node replacements "FieldOwner" "FieldName")
+    IASTConditionalExpression    (-maybe-set-operands!  node replacements "LogicalConditionExpression"
+                                                         "PositiveResultExpression" "NegativeResultExpression")
+
       nil))
 
 (s/defn parse-macro

(s/defn -maybe-set-value!
  [getter setter node replacements]
  (when-let* [operand     (getter node)
              _           (instance? IASTIdExpression operand)
              replacement (-> operand .getName str replacements)
              _           (instance? IASTExpression replacement)
              ]
       (doto node
         (setter (.copy replacement)))))

(s/defn -maybe-set-args!
  [node :- IASTFunctionCallExpression replacements]

(in-ns 'atom-finder.classifier)
(import '(org.eclipse.cdt.core.dom.ast IASTNode IASTName IASTIdExpression IASTBinaryExpression IASTUnaryExpression IASTExpressionStatement IASTPreprocessorFunctionStyleMacroDefinition IASTDoStatement IASTLiteralExpression IASTPreprocessorMacroExpansion cpp.ICPPASTTemplateId IASTCastExpression IASTFunctionCallExpression IASTEqualsInitializer IASTIfStatement IASTWhileStatement IASTForStatement IASTDoStatement IASTArraySubscriptExpression IASTExpressionList IASTFieldReference)
        '(org.eclipse.cdt.internal.core.parser.scanner ASTFunctionStyleMacroDefinition ASTMacroDefinition)
        '(org.eclipse.cdt.internal.core.dom.parser.cpp CPPASTUnaryExpression CPPASTExpressionList)
        )

;; ExpressionWriter adds superfluous parens to cast statements.
