author | jjg |
Thu, 10 Jun 2010 16:08:01 -0700 | |
changeset 5847 | 1908176fd6e3 |
parent 5520 | 86e4b9a9da40 |
permissions | -rw-r--r-- |
2984
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
1 |
/* |
5520 | 2 |
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. |
2984
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
4 |
* |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2984
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2984
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
10 |
* |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
15 |
* accompanied this code). |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
16 |
* |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
20 |
* |
5520 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2984
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
24 |
*/ |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
25 |
package com.sun.tools.javac.util; |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
26 |
|
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
27 |
import java.util.Set; |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
28 |
import java.util.Locale; |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
29 |
import javax.tools.Diagnostic; |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
30 |
|
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
31 |
import com.sun.tools.javac.api.DiagnosticFormatter; |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
32 |
import com.sun.tools.javac.api.DiagnosticFormatter.Configuration; |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
33 |
import com.sun.tools.javac.api.DiagnosticFormatter.Configuration.DiagnosticPart; |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
34 |
import com.sun.tools.javac.api.DiagnosticFormatter.Configuration.MultilineLimit; |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
35 |
import com.sun.tools.javac.api.DiagnosticFormatter.PositionKind; |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
36 |
|
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
37 |
/** |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
38 |
* A delegated diagnostic formatter delegates all formatting |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
39 |
* actions to an underlying formatter (aka the delegated formatter). |
3380
a6c2bcab0fec
6865399: some javac files are missing Sun internal API comment
jjg
parents:
2984
diff
changeset
|
40 |
* |
5847
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
41 |
* <p><b>This is NOT part of any supported API. |
3380
a6c2bcab0fec
6865399: some javac files are missing Sun internal API comment
jjg
parents:
2984
diff
changeset
|
42 |
* If you write code that depends on this, you do so at your own risk. |
a6c2bcab0fec
6865399: some javac files are missing Sun internal API comment
jjg
parents:
2984
diff
changeset
|
43 |
* This code and its internal interfaces are subject to change or |
a6c2bcab0fec
6865399: some javac files are missing Sun internal API comment
jjg
parents:
2984
diff
changeset
|
44 |
* deletion without notice.</b> |
2984
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
45 |
*/ |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
46 |
public class ForwardingDiagnosticFormatter<D extends Diagnostic<?>, F extends DiagnosticFormatter<D>> |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
47 |
implements DiagnosticFormatter<D> { |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
48 |
|
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
49 |
/** |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
50 |
* The delegated formatter |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
51 |
*/ |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
52 |
protected F formatter; |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
53 |
|
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
54 |
/* |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
55 |
* configuration object used by this formatter |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
56 |
*/ |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
57 |
protected ForwardingConfiguration configuration; |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
58 |
|
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
59 |
public ForwardingDiagnosticFormatter(F formatter) { |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
60 |
this.formatter = formatter; |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
61 |
this.configuration = new ForwardingConfiguration(formatter.getConfiguration()); |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
62 |
} |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
63 |
|
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
64 |
/** |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
65 |
* Returns the underlying delegated formatter |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
66 |
* @return delegate formatter |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
67 |
*/ |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
68 |
public F getDelegatedFormatter() { |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
69 |
return formatter; |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
70 |
} |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
71 |
|
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
72 |
public Configuration getConfiguration() { |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
73 |
return configuration; |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
74 |
} |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
75 |
|
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
76 |
public boolean displaySource(D diag) { |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
77 |
return formatter.displaySource(diag); |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
78 |
} |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
79 |
|
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
80 |
public String format(D diag, Locale l) { |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
81 |
return formatter.format(diag, l); |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
82 |
} |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
83 |
|
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
84 |
public String formatKind(D diag, Locale l) { |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
85 |
return formatter.formatKind(diag, l); |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
86 |
} |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
87 |
|
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
88 |
public String formatMessage(D diag, Locale l) { |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
89 |
return formatter.formatMessage(diag, l); |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
90 |
} |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
91 |
|
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
92 |
public String formatPosition(D diag, PositionKind pk, Locale l) { |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
93 |
return formatter.formatPosition(diag, pk, l); |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
94 |
} |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
95 |
|
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
96 |
public String formatSource(D diag, boolean fullname, Locale l) { |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
97 |
return formatter.formatSource(diag, fullname, l); |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
98 |
} |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
99 |
|
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
100 |
/** |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
101 |
* A delegated formatter configuration delegates all configurations settings |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
102 |
* to an underlying configuration object (aka the delegated configuration). |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
103 |
*/ |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
104 |
public static class ForwardingConfiguration implements DiagnosticFormatter.Configuration { |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
105 |
|
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
106 |
/** The configurationr object to which the forwarding configuration delegates some settings */ |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
107 |
protected Configuration configuration; |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
108 |
|
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
109 |
public ForwardingConfiguration(Configuration configuration) { |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
110 |
this.configuration = configuration; |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
111 |
} |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
112 |
|
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
113 |
/** |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
114 |
* Returns the underlying delegated configuration. |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
115 |
* @return delegated configuration |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
116 |
*/ |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
117 |
public Configuration getDelegatedConfiguration() { |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
118 |
return configuration; |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
119 |
} |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
120 |
|
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
121 |
public int getMultilineLimit(MultilineLimit limit) { |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
122 |
return configuration.getMultilineLimit(limit); |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
123 |
} |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
124 |
|
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
125 |
public Set<DiagnosticPart> getVisible() { |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
126 |
return configuration.getVisible(); |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
127 |
} |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
128 |
|
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
129 |
public void setMultilineLimit(MultilineLimit limit, int value) { |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
130 |
configuration.setMultilineLimit(limit, value); |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
131 |
} |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
132 |
|
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
133 |
public void setVisible(Set<DiagnosticPart> diagParts) { |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
134 |
configuration.setVisible(diagParts); |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
135 |
} |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
136 |
} |
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
diff
changeset
|
137 |
} |