Skip to content

Commit

Permalink
Function argument formatting fix (unary minus)
Browse files Browse the repository at this point in the history
  • Loading branch information
radkovo committed Mar 24, 2018
1 parent 43ec98c commit afb8881
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/main/java/cz/vutbr/web/csskit/OutputUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,19 @@ public static StringBuilder appendCalcArgs(StringBuilder sb, CalcArgs args) {
*/
public static StringBuilder appendFunctionArgs(StringBuilder sb, List<Term<?>> list) {

boolean firstRun = true;

Term<?> prev = null, pprev = null;
for (Term<?> elem : list) {
boolean sep = (elem instanceof TermOperator &&
((TermOperator) elem).getValue() == ',');
if (!firstRun && !sep)
boolean sep = true;
if (elem instanceof TermOperator && ((TermOperator) elem).getValue() == ',')
sep = false; //no spaces before commas
if ((prev != null && prev instanceof TermOperator && ((TermOperator) prev).getValue() == '-')
&& (pprev == null || pprev instanceof TermOperator)) //nothing or an operator before -
sep = false; //no spaces after unary minus
if (prev != null && sep)
sb.append(SPACE_DELIM);
firstRun = false;
pprev = prev;
prev = elem;

sb.append(elem.toString());
}
Expand Down

0 comments on commit afb8881

Please sign in to comment.