Changeset 9930 in josm for trunk/src/org


Ignore:
Timestamp:
2016-03-05T16:25:52+01:00 (9 years ago)
Author:
simon04
Message:

Search: fix string representation of boolean connectives (parentheses)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java

    r9701 r9930  
    453453        @Override
    454454        public String toString() {
    455             return lhs + " && " + rhs;
     455            return (lhs instanceof BinaryMatch && !(lhs instanceof And) ? "(" + lhs + ")" : lhs) + " && "
     456                    + (rhs instanceof BinaryMatch && !(rhs instanceof And) ? "(" + rhs + ")" : rhs);
    456457        }
    457458    }
     
    477478        @Override
    478479        public String toString() {
    479             return lhs + " || " + rhs;
     480            return (lhs instanceof BinaryMatch && !(lhs instanceof Or) ? "(" + lhs + ")" : lhs) + " || "
     481                    + (rhs instanceof BinaryMatch && !(rhs instanceof Or) ? "(" + rhs + ")" : rhs);
    480482        }
    481483    }
     
    501503        @Override
    502504        public String toString() {
    503             return lhs + " ^ " + rhs;
     505            return (lhs instanceof BinaryMatch && !(lhs instanceof Xor) ? "(" + lhs + ")" : lhs) + " ^ "
     506                    + (rhs instanceof BinaryMatch && !(rhs instanceof Xor) ? "(" + rhs + ")" : rhs);
    504507        }
    505508    }
Note: See TracChangeset for help on using the changeset viewer.