11package liquidjava .diagnostics ;
22
33import java .util .ArrayList ;
4- import java .util .HashMap ;
5-
64import liquidjava .diagnostics .errors .LJError ;
75import liquidjava .diagnostics .warnings .LJWarning ;
8- import liquidjava .processor .context .PlacementInCode ;
96
107/**
11- * Singleton class to store diagnostics information (errors, warnings, translation map ) during the verification process
8+ * Singleton class to store diagnostics (errors and warnings ) during the verification process
129 *
1310 * @see LJError
1411 * @see LJWarning
1512 */
1613public class LJDiagnostics {
17- private static LJDiagnostics instance ;
14+ public static final LJDiagnostics diagnostics = new LJDiagnostics () ;
1815
1916 private ArrayList <LJError > errors ;
2017 private ArrayList <LJWarning > warnings ;
21- private HashMap <String , PlacementInCode > translationMap ;
2218
2319 private LJDiagnostics () {
2420 this .errors = new ArrayList <>();
2521 this .warnings = new ArrayList <>();
26- this .translationMap = new HashMap <>();
27- }
28-
29- public static LJDiagnostics getInstance () {
30- if (instance == null )
31- instance = new LJDiagnostics ();
32- return instance ;
33- }
34-
35- public static LJDiagnostics add (LJError error ) {
36- LJDiagnostics instance = getInstance ();
37- instance .addError (error );
38- return instance ;
39- }
40-
41- public static LJDiagnostics add (LJWarning warning ) {
42- LJDiagnostics instance = getInstance ();
43- instance .addWarning (warning );
44- return instance ;
4522 }
4623
47- public static LJDiagnostics add (HashMap <String , PlacementInCode > map ) {
48- LJDiagnostics instance = getInstance ();
49- instance .setTranslationMap (map );
50- return instance ;
51- }
52-
53- public void addError (LJError error ) {
24+ public void add (LJError error ) {
5425 this .errors .add (error );
5526 }
5627
57- public void addWarning (LJWarning warning ) {
28+ public void add (LJWarning warning ) {
5829 this .warnings .add (warning );
5930 }
6031
61- public void setTranslationMap (HashMap <String , PlacementInCode > map ) {
62- this .translationMap = map ;
63- }
64-
6532 public boolean foundError () {
6633 return !this .errors .isEmpty ();
6734 }
@@ -78,10 +45,6 @@ public ArrayList<LJWarning> getWarnings() {
7845 return this .warnings ;
7946 }
8047
81- public HashMap <String , PlacementInCode > getTranslationMap () {
82- return this .translationMap ;
83- }
84-
8548 public LJError getError () {
8649 return foundError () ? this .errors .get (0 ) : null ;
8750 }
@@ -93,7 +56,6 @@ public LJWarning getWarning() {
9356 public void clear () {
9457 this .errors .clear ();
9558 this .warnings .clear ();
96- this .translationMap .clear ();
9759 }
9860
9961 @ Override
0 commit comments