23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 |
25 |
26 package com.sun.tools.javac.util; |
26 package com.sun.tools.javac.util; |
27 |
27 |
|
28 import com.sun.tools.javac.code.Lint.LintCategory; |
28 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; |
29 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; |
|
30 import java.util.EnumSet; |
29 |
31 |
30 /** |
32 /** |
31 * An interface to support optional warnings, needed for support of |
33 * An interface to support optional warnings, needed for support of |
32 * unchecked conversions and unchecked casts. |
34 * unchecked conversions and unchecked casts. |
33 * |
35 * |
38 */ |
40 */ |
39 public class Warner { |
41 public class Warner { |
40 public static final Warner noWarnings = new Warner(); |
42 public static final Warner noWarnings = new Warner(); |
41 |
43 |
42 private DiagnosticPosition pos = null; |
44 private DiagnosticPosition pos = null; |
43 public boolean warned = false; |
45 protected boolean warned = false; |
44 public boolean unchecked = false; |
46 private EnumSet<LintCategory> nonSilentLintSet = EnumSet.noneOf(LintCategory.class); |
|
47 private EnumSet<LintCategory> silentLintSet = EnumSet.noneOf(LintCategory.class); |
45 |
48 |
46 public DiagnosticPosition pos() { |
49 public DiagnosticPosition pos() { |
47 return pos; |
50 return pos; |
48 } |
51 } |
49 |
52 |
50 public void warnUnchecked() { |
53 public void warn(LintCategory lint) { |
51 warned = true; |
54 nonSilentLintSet.add(lint); |
52 unchecked = true; |
|
53 } |
55 } |
54 public void silentUnchecked() { |
56 |
55 unchecked = true; |
57 public void silentWarn(LintCategory lint) { |
|
58 silentLintSet.add(lint); |
56 } |
59 } |
57 |
60 |
58 public Warner(DiagnosticPosition pos) { |
61 public Warner(DiagnosticPosition pos) { |
59 this.pos = pos; |
62 this.pos = pos; |
60 } |
63 } |
61 |
64 |
|
65 public boolean hasSilentLint(LintCategory lint) { |
|
66 return silentLintSet.contains(lint); |
|
67 } |
|
68 |
|
69 public boolean hasNonSilentLint(LintCategory lint) { |
|
70 return nonSilentLintSet.contains(lint); |
|
71 } |
|
72 |
|
73 public boolean hasLint(LintCategory lint) { |
|
74 return hasSilentLint(lint) || |
|
75 hasNonSilentLint(lint); |
|
76 } |
|
77 |
|
78 public void clear() { |
|
79 nonSilentLintSet.clear(); |
|
80 silentLintSet.clear(); |
|
81 this.warned = false; |
|
82 } |
|
83 |
62 public Warner() { |
84 public Warner() { |
63 this(null); |
85 this(null); |
64 } |
86 } |
65 } |
87 } |