src/share/classes/com/sun/tools/javac/tree/Pretty.java

changeset 1486
7d2f628f04f1
parent 1436
f6f1fd261f57
child 1510
7873d37f5b37
     1.1 --- a/src/share/classes/com/sun/tools/javac/tree/Pretty.java	Thu Jan 10 14:09:33 2013 -0800
     1.2 +++ b/src/share/classes/com/sun/tools/javac/tree/Pretty.java	Thu Jan 10 15:48:46 2013 -0800
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -154,12 +154,13 @@
    1.11          }
    1.12          //we need to (i) replace all line terminators with a space and (ii) remove
    1.13          //occurrences of 'missing' in the Pretty output (generated when types are missing)
    1.14 -        String res = s.toString().replaceAll("\\s+", " ").replaceAll("/\\*missing\\*/", "");
    1.15 +        String res = s.toString().trim().replaceAll("\\s+", " ").replaceAll("/\\*missing\\*/", "");
    1.16          if (res.length() < maxLength) {
    1.17              return res;
    1.18          } else {
    1.19 -            int split = (maxLength - trimSequence.length()) * 2 / 3;
    1.20 -            return res.substring(0, split) + trimSequence + res.substring(split);
    1.21 +            int head = (maxLength - trimSequence.length()) * 2 / 3;
    1.22 +            int tail = maxLength - trimSequence.length() - head;
    1.23 +            return res.substring(0, head) + trimSequence + res.substring(res.length() - tail);
    1.24          }
    1.25      }
    1.26  

mercurial