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

changeset 1486
7d2f628f04f1
parent 1436
f6f1fd261f57
child 1510
7873d37f5b37
equal deleted inserted replaced
1485:d462da465da6 1486:7d2f628f04f1
1 /* 1 /*
2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this 7 * published by the Free Software Foundation. Oracle designates this
152 // never to throw any IOExceptions 152 // never to throw any IOExceptions
153 throw new AssertionError(e); 153 throw new AssertionError(e);
154 } 154 }
155 //we need to (i) replace all line terminators with a space and (ii) remove 155 //we need to (i) replace all line terminators with a space and (ii) remove
156 //occurrences of 'missing' in the Pretty output (generated when types are missing) 156 //occurrences of 'missing' in the Pretty output (generated when types are missing)
157 String res = s.toString().replaceAll("\\s+", " ").replaceAll("/\\*missing\\*/", ""); 157 String res = s.toString().trim().replaceAll("\\s+", " ").replaceAll("/\\*missing\\*/", "");
158 if (res.length() < maxLength) { 158 if (res.length() < maxLength) {
159 return res; 159 return res;
160 } else { 160 } else {
161 int split = (maxLength - trimSequence.length()) * 2 / 3; 161 int head = (maxLength - trimSequence.length()) * 2 / 3;
162 return res.substring(0, split) + trimSequence + res.substring(split); 162 int tail = maxLength - trimSequence.length() - head;
163 return res.substring(0, head) + trimSequence + res.substring(res.length() - tail);
163 } 164 }
164 } 165 }
165 166
166 String lineSep = System.getProperty("line.separator"); 167 String lineSep = System.getProperty("line.separator");
167 168

mercurial