intial version
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.jtidy / src / net / sourceforge / phpdt / tidy / w3c / Report.java
1 /*
2  * @(#)Report.java   1.11 2000/08/16
3  *
4  */
5
6 package net.sourceforge.phpdt.tidy.w3c;
7
8 /**
9  *
10  * Error/informational message reporter.
11  *
12  * You should only need to edit the file TidyMessages.properties
13  * to localize HTML tidy.
14  *
15  * (c) 1998-2000 (W3C) MIT, INRIA, Keio University
16  * Derived from <a href="http://www.w3.org/People/Raggett/tidy">
17  * HTML Tidy Release 4 Aug 2000</a>
18  *
19  * @author  Dave Raggett <dsr@w3.org>
20  * @author  Andy Quick <ac.quick@sympatico.ca> (translation to Java)
21  * @version 1.0, 1999/05/22
22  * @version 1.0.1, 1999/05/29
23  * @version 1.1, 1999/06/18 Java Bean
24  * @version 1.2, 1999/07/10 Tidy Release 7 Jul 1999
25  * @version 1.3, 1999/07/30 Tidy Release 26 Jul 1999
26  * @version 1.4, 1999/09/04 DOM support
27  * @version 1.5, 1999/10/23 Tidy Release 27 Sep 1999
28  * @version 1.6, 1999/11/01 Tidy Release 22 Oct 1999
29  * @version 1.7, 1999/12/06 Tidy Release 30 Nov 1999
30  * @version 1.8, 2000/01/22 Tidy Release 13 Jan 2000
31  * @version 1.9, 2000/06/03 Tidy Release 30 Apr 2000
32  * @version 1.10, 2000/07/22 Tidy Release 8 Jul 2000
33  * @version 1.11, 2000/08/16 Tidy Release 4 Aug 2000
34  */
35
36 import java.io.PrintWriter;
37 import java.text.MessageFormat;
38 import java.util.Hashtable;
39 import java.util.MissingResourceException;
40 import java.util.ResourceBundle;
41
42 import net.sourceforge.phpdt.tidy.JTidyConsole;
43 import net.sourceforge.phpdt.tidy.JtidyPlugin;
44 import org.eclipse.core.resources.IMarker;
45 import org.eclipse.core.runtime.CoreException;
46 import org.eclipse.ui.texteditor.MarkerUtilities;
47
48 public class Report {
49
50         /* used to point to Web Accessibility Guidelines */
51         public static final String ACCESS_URL = "http://www.w3.org/WAI/GL";
52
53         public static final String RELEASE_DATE = "4th August 2000";
54
55         public static String currentFile;
56         /* sasdjb 01May00 for GNU Emacs error parsing */
57
58         /* error codes for entities */
59
60         public static final short MISSING_SEMICOLON = 1;
61         public static final short UNKNOWN_ENTITY = 2;
62         public static final short UNESCAPED_AMPERSAND = 3;
63
64         /* error codes for element messages */
65
66         public static final short MISSING_ENDTAG_FOR = 1;
67         public static final short MISSING_ENDTAG_BEFORE = 2;
68         public static final short DISCARDING_UNEXPECTED = 3;
69         public static final short NESTED_EMPHASIS = 4;
70         public static final short NON_MATCHING_ENDTAG = 5;
71         public static final short TAG_NOT_ALLOWED_IN = 6;
72         public static final short MISSING_STARTTAG = 7;
73         public static final short UNEXPECTED_ENDTAG = 8;
74         public static final short USING_BR_INPLACE_OF = 9;
75         public static final short INSERTING_TAG = 10;
76         public static final short SUSPECTED_MISSING_QUOTE = 11;
77         public static final short MISSING_TITLE_ELEMENT = 12;
78         public static final short DUPLICATE_FRAMESET = 13;
79         public static final short CANT_BE_NESTED = 14;
80         public static final short OBSOLETE_ELEMENT = 15;
81         public static final short PROPRIETARY_ELEMENT = 16;
82         public static final short UNKNOWN_ELEMENT = 17;
83         public static final short TRIM_EMPTY_ELEMENT = 18;
84         public static final short COERCE_TO_ENDTAG = 19;
85         public static final short ILLEGAL_NESTING = 20;
86         public static final short NOFRAMES_CONTENT = 21;
87         public static final short CONTENT_AFTER_BODY = 22;
88         public static final short INCONSISTENT_VERSION = 23;
89         public static final short MALFORMED_COMMENT = 24;
90         public static final short BAD_COMMENT_CHARS = 25;
91         public static final short BAD_XML_COMMENT = 26;
92         public static final short BAD_CDATA_CONTENT = 27;
93         public static final short INCONSISTENT_NAMESPACE = 28;
94         public static final short DOCTYPE_AFTER_TAGS = 29;
95         public static final short MALFORMED_DOCTYPE = 30;
96         public static final short UNEXPECTED_END_OF_FILE = 31;
97         public static final short DTYPE_NOT_UPPER_CASE = 32;
98         public static final short TOO_MANY_ELEMENTS = 33;
99
100         /* error codes used for attribute messages */
101
102         public static final short UNKNOWN_ATTRIBUTE = 1;
103         public static final short MISSING_ATTRIBUTE = 2;
104         public static final short MISSING_ATTR_VALUE = 3;
105         public static final short BAD_ATTRIBUTE_VALUE = 4;
106         public static final short UNEXPECTED_GT = 5;
107         public static final short PROPRIETARY_ATTR_VALUE = 6;
108         public static final short REPEATED_ATTRIBUTE = 7;
109         public static final short MISSING_IMAGEMAP = 8;
110         public static final short XML_ATTRIBUTE_VALUE = 9;
111         public static final short UNEXPECTED_QUOTEMARK = 10;
112         public static final short ID_NAME_MISMATCH = 11;
113
114         /* accessibility flaws */
115
116         public static final short MISSING_IMAGE_ALT = 1;
117         public static final short MISSING_LINK_ALT = 2;
118         public static final short MISSING_SUMMARY = 4;
119         public static final short MISSING_IMAGE_MAP = 8;
120         public static final short USING_FRAMES = 16;
121         public static final short USING_NOFRAMES = 32;
122
123         /* presentation flaws */
124
125         public static final short USING_SPACER = 1;
126         public static final short USING_LAYER = 2;
127         public static final short USING_NOBR = 4;
128         public static final short USING_FONT = 8;
129         public static final short USING_BODY = 16;
130
131         /* character encoding errors */
132         public static final short WINDOWS_CHARS = 1;
133         public static final short NON_ASCII = 2;
134         public static final short FOUND_UTF16 = 4;
135
136         private static short optionerrors;
137
138         private static ResourceBundle res = null;
139
140         static {
141                 try { 
142                         res = ResourceBundle.getBundle("net/sourceforge/phpdt/tidy/w3c/TidyMessages");
143                 } catch (MissingResourceException e) {
144                         throw new Error(e.toString());
145                 }
146         }
147
148         //  public static void tidyPrint(PrintWriter p, String msg) {
149         //    p.print(msg);
150         //  }
151
152 //      public static void tidyPrint(char c) {
153 //              // p.println(msg);
154 //      //      JTidyConsole.print(new String(c));
155 //      }
156         
157         public static void tidyPrint(String msg) {
158                 // p.println(msg);
159                 JTidyConsole.print(msg);
160         }
161
162         public static void tidyPrintln(String msg) {
163                 // p.println(msg);
164                 JTidyConsole.println(msg);
165         }
166
167         public static void tidyPrintln() {
168                 JTidyConsole.println("");
169         }
170
171         public static void showVersion(PrintWriter p) {
172                 tidyPrintln("Java HTML Tidy release date: " + RELEASE_DATE);
173                 tidyPrintln("See http://www.w3.org/People/Raggett for details");
174         }
175
176         //  public static void tag(Lexer lexer, Node tag) {
177         //    if (tag != null) {
178         //      if (tag.type == Node.StartTag)
179         //        tidyPrint(lexer.errout, "<" + tag.element + ">");
180         //      else if (tag.type == Node.EndTag)
181         //        tidyPrint(lexer.errout, "</" + tag.element + ">");
182         //      else if (tag.type == Node.DocTypeTag)
183         //        tidyPrint(lexer.errout, "<!DOCTYPE>");
184         //      else if (tag.type == Node.TextNode)
185         //        tidyPrint(lexer.errout, "plain text");
186         //      else
187         //        tidyPrint(lexer.errout, tag.element);
188         //    }
189         //  }
190
191         public static void tag(StringBuffer errorMessage, Node tag) {
192                 if (tag != null) {
193                         if (tag.type == Node.StartTag) {
194                                 //     tidyPrint(lexer.errout, "<" + tag.element + ">");
195                                 errorMessage.append("<" + tag.element + ">");
196                         } else if (tag.type == Node.EndTag) {
197                                 //     tidyPrint(lexer.errout, "</" + tag.element + ">");
198                                 errorMessage.append("</" + tag.element + ">");
199                         } else if (tag.type == Node.DocTypeTag) {
200                                 //     tidyPrint(lexer.errout, "<!DOCTYPE>");
201                                 errorMessage.append("</" + tag.element + ">");
202                         } else if (tag.type == Node.TextNode) {
203                                 //     tidyPrint(lexer.errout, "plain text");
204                                 errorMessage.append("plain text");
205                         } else {
206                                 //     tidyPrint(lexer.errout, tag.element);
207                                 errorMessage.append(tag.element);
208                         }
209                 }
210         }
211
212         /* lexer is not defined when this is called */
213         public static void unknownOption(String option) {
214                 optionerrors++;
215                 try {
216                         System.err.println(
217                                 MessageFormat.format(
218                                         res.getString("unknown_option"),
219                                         new Object[] { option }));
220                 } catch (MissingResourceException e) {
221                         System.err.println(e.toString());
222                 }
223         }
224
225         /* lexer is not defined when this is called */
226         public static void badArgument(String option) {
227                 optionerrors++;
228                 try {
229                         System.err.println(
230                                 MessageFormat.format(
231                                         res.getString("bad_argument"),
232                                         new Object[] { option }));
233                 } catch (MissingResourceException e) {
234                         System.err.println(e.toString());
235                 }
236         }
237
238         //  public static void position(Lexer lexer) {
239         //    try {
240         //      /* Change formatting to be parsable by GNU Emacs */
241         //      if (lexer.configuration.Emacs) {
242         //        tidyPrint(
243         //          lexer.errout,
244         //          MessageFormat.format(
245         //            res.getString("emacs_format"),
246         //            new Object[] { currentFile, new Integer(lexer.lines), new Integer(lexer.columns)}));
247         //        tidyPrint(lexer.errout, " ");
248         //      } else /* traditional format */ {
249         //        tidyPrint(
250         //          lexer.errout,
251         //          MessageFormat.format(res.getString("line_column"), new Object[] { new Integer(lexer.lines), new Integer(lexer.columns)}));
252         //      }
253         //    } catch (MissingResourceException e) {
254         //      lexer.errout.tidyPrintln(e.toString());
255         //    }
256         //  }
257
258         public static void encodingError(Lexer lexer, short code, int c) {
259                 lexer.warnings++;
260
261                 if (lexer.configuration.ShowWarnings) {
262                         //    position(lexer);
263
264                         if (code == WINDOWS_CHARS) {
265                                 lexer.badChars |= WINDOWS_CHARS;
266                                 try {
267                                         Hashtable attributes = new Hashtable();
268                                         StringBuffer errorMessage =
269                                                 new StringBuffer("Column " + lexer.columns + ": ");
270                                         MarkerUtilities.setLineNumber(attributes, lexer.lines);
271                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("illegal_char"), new Object[] { new Integer(c)}));
272                                         errorMessage.append(
273                                                 MessageFormat.format(
274                                                         res.getString("illegal_char"),
275                                                         new Object[] { new Integer(c)}));
276                                         attributes.put(
277                                                 IMarker.SEVERITY,
278                                                 new Integer(IMarker.SEVERITY_ERROR));
279                                         attributes.put(JtidyPlugin.MARKER_NAME, Boolean.TRUE);
280                                         // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING));
281                                         // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
282                                         try {
283                                                 MarkerUtilities.setMessage(
284                                                         attributes,
285                                                         errorMessage.toString());
286                                                 MarkerUtilities.createMarker(
287                                                         lexer.getIFile(),
288                                                         attributes,
289                                                         IMarker.PROBLEM);
290                                         } catch (CoreException e) {
291                                         }
292                                 } catch (MissingResourceException e) {
293                                         tidyPrintln(e.toString());
294                                 }
295                         }
296
297                         tidyPrintln();
298                 }
299         }
300
301         public static void entityError(
302                 Lexer lexer,
303                 short code,
304                 String entity,
305                 int c) {
306                 lexer.warnings++;
307
308                 if (lexer.configuration.ShowWarnings) {
309                         //  position(lexer);
310                         Hashtable attributes = new Hashtable();
311                         StringBuffer errorMessage =
312                                 new StringBuffer("Column " + lexer.columns + ": ");
313                         MarkerUtilities.setLineNumber(attributes, lexer.lines);
314
315                         if (code == MISSING_SEMICOLON) {
316                                 try {
317                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("missing_semicolon"), new Object[] { entity }));
318                                         errorMessage.append(
319                                                 MessageFormat.format(
320                                                         res.getString("missing_semicolon"),
321                                                         new Object[] { entity }));
322                                 } catch (MissingResourceException e) {
323                                         tidyPrintln(e.toString());
324                                 }
325                         } else if (code == UNKNOWN_ENTITY) {
326                                 try {
327                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("unknown_entity"), new Object[] { entity }));
328                                         errorMessage.append(
329                                                 MessageFormat.format(
330                                                         res.getString("unknown_entity"),
331                                                         new Object[] { entity }));
332                                 } catch (MissingResourceException e) {
333                                         tidyPrintln(e.toString());
334                                 }
335                         } else if (code == UNESCAPED_AMPERSAND) {
336                                 try {
337                                         // tidyPrint(lexer.errout, res.getString("unescaped_ampersand"));
338                                         errorMessage.append(res.getString("unescaped_ampersand"));
339                                 } catch (MissingResourceException e) {
340                                         tidyPrintln(e.toString());
341                                 }
342                         }
343                         attributes.put(
344                                 IMarker.SEVERITY,
345                                 new Integer(IMarker.SEVERITY_ERROR));
346                         attributes.put(JtidyPlugin.MARKER_NAME, Boolean.TRUE);
347                         // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING));
348                         // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
349                         try {
350                                 MarkerUtilities.setMessage(attributes, errorMessage.toString());
351                                 MarkerUtilities.createMarker(
352                                         lexer.getIFile(),
353                                         attributes,
354                                         IMarker.PROBLEM);
355                         } catch (CoreException e) {
356                         }
357                         tidyPrintln();
358                 }
359         }
360
361         public static void attrError(
362                 Lexer lexer,
363                 Node node,
364                 String attr,
365                 short code) {
366                 lexer.warnings++;
367
368                 /* keep quiet after 6 errors */
369                 if (lexer.errors > 6)
370                         return;
371
372                 Hashtable attributes = new Hashtable();
373                 StringBuffer errorMessage =
374                         new StringBuffer("Column " + lexer.columns + ": ");
375
376                 if (lexer.configuration.ShowWarnings) {
377                         /* on end of file adjust reported position to end of input */
378                         if (code == UNEXPECTED_END_OF_FILE) {
379                                 lexer.lines = lexer.in.curline;
380                                 lexer.columns = lexer.in.curcol;
381                         }
382
383                         //  position(lexer);
384
385                         MarkerUtilities.setLineNumber(attributes, lexer.lines);
386
387                         if (code == UNKNOWN_ATTRIBUTE) {
388                                 try {
389                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("unknown_attribute"), new Object[] { attr }));
390                                         errorMessage.append(
391                                                 MessageFormat.format(
392                                                         res.getString("unknown_attribute"),
393                                                         new Object[] { attr }));
394                                 } catch (MissingResourceException e) {
395                                         tidyPrintln(e.toString());
396                                 }
397                         } else if (code == MISSING_ATTRIBUTE) {
398                                 try {
399                                         // tidyPrint(lexer.errout, res.getString("warning"));
400                                         errorMessage.append(res.getString("warning"));
401                                         tag(errorMessage, node);
402                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("missing_attribute"), new Object[] { attr }));
403                                         errorMessage.append(
404                                                 MessageFormat.format(
405                                                         res.getString("missing_attribute"),
406                                                         new Object[] { attr }));
407                                 } catch (MissingResourceException e) {
408                                         tidyPrintln(e.toString());
409                                 }
410                         } else if (code == MISSING_ATTR_VALUE) {
411                                 try {
412                                         // tidyPrint(lexer.errout, res.getString("warning"));
413                                         errorMessage.append(res.getString("warning"));
414                                         tag(errorMessage, node);
415                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("missing_attr_value"), new Object[] { attr }));
416                                         errorMessage.append(
417                                                 MessageFormat.format(
418                                                         res.getString("missing_attr_value"),
419                                                         new Object[] { attr }));
420                                 } catch (MissingResourceException e) {
421                                         tidyPrintln(e.toString());
422                                 }
423                         } else if (code == MISSING_IMAGEMAP) {
424                                 try {
425                                         // tidyPrint(lexer.errout, res.getString("warning"));
426                                         errorMessage.append(res.getString("warning"));
427                                         tag(errorMessage, node);
428                                         // tidyPrint(lexer.errout, res.getString("missing_imagemap"));
429                                         errorMessage.append(res.getString("missing_imagemap"));
430                                 } catch (MissingResourceException e) {
431                                         tidyPrintln(e.toString());
432                                 }
433                                 lexer.badAccess |= MISSING_IMAGE_MAP;
434                         } else if (code == BAD_ATTRIBUTE_VALUE) {
435                                 try {
436                                         // tidyPrint(lexer.errout, res.getString("warning"));
437                                         errorMessage.append(res.getString("warning"));
438                                         tag(errorMessage, node);
439                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("bad_attribute_value"), new Object[] { attr }));
440                                         errorMessage.append(
441                                                 MessageFormat.format(
442                                                         res.getString("bad_attribute_value"),
443                                                         new Object[] { attr }));
444                                 } catch (MissingResourceException e) {
445                                         tidyPrintln(e.toString());
446                                 }
447                         } else if (code == XML_ATTRIBUTE_VALUE) {
448                                 try {
449                                         // tidyPrint(lexer.errout, res.getString("warning"));
450                                         errorMessage.append(res.getString("warning"));
451                                         tag(errorMessage, node);
452                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("xml_attribute_value"), new Object[] { attr }));
453                                         errorMessage.append(
454                                                 MessageFormat.format(
455                                                         res.getString("xml_attribute_value"),
456                                                         new Object[] { attr }));
457                                 } catch (MissingResourceException e) {
458                                         tidyPrintln(e.toString());
459                                 }
460                         } else if (code == UNEXPECTED_GT) {
461                                 try {
462                                         // tidyPrint(lexer.errout, res.getString("error"));
463                                         errorMessage.append(res.getString("error"));
464                                         tag(errorMessage, node);
465                                         // tidyPrint(lexer.errout, res.getString("unexpected_gt"));
466                                         errorMessage.append(res.getString("unexpected_gt"));
467                                 } catch (MissingResourceException e) {
468                                         tidyPrintln(e.toString());
469                                 }
470                                 lexer.errors++;
471                                 ;
472                         } else if (code == UNEXPECTED_QUOTEMARK) {
473                                 try {
474                                         // tidyPrint(lexer.errout, res.getString("warning"));
475                                         errorMessage.append(res.getString("warning"));
476                                         tag(errorMessage, node);
477                                         // tidyPrint(lexer.errout, res.getString("unexpected_quotemark"));
478                                         errorMessage.append(res.getString("unexpected_quotemark"));
479                                 } catch (MissingResourceException e) {
480                                         tidyPrintln(e.toString());
481                                 }
482                         } else if (code == REPEATED_ATTRIBUTE) {
483                                 try {
484                                         // tidyPrint(lexer.errout, res.getString("warning"));
485                                         errorMessage.append(res.getString("warning"));
486                                         tag(errorMessage, node);
487                                         // tidyPrint(lexer.errout, res.getString("repeated_attribute"));
488                                         errorMessage.append(res.getString("repeated_attribute"));
489                                 } catch (MissingResourceException e) {
490                                         tidyPrintln(e.toString());
491                                 }
492                         } else if (code == PROPRIETARY_ATTR_VALUE) {
493                                 try {
494                                         // tidyPrint(lexer.errout, res.getString("warning"));
495                                         errorMessage.append(res.getString("warning"));
496                                         tag(errorMessage, node);
497                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("proprietary_attr_value"), new Object[] { attr }));
498                                         errorMessage.append(
499                                                 MessageFormat.format(
500                                                         res.getString("proprietary_attr_value"),
501                                                         new Object[] { attr }));
502                                 } catch (MissingResourceException e) {
503                                         tidyPrintln(e.toString());
504                                 }
505                         } else if (code == UNEXPECTED_END_OF_FILE) {
506                                 try {
507                                         // tidyPrint(lexer.errout, res.getString("unexpected_end_of_file"));
508                                         errorMessage.append(
509                                                 res.getString("unexpected_end_of_file"));
510                                 } catch (MissingResourceException e) {
511                                         tidyPrintln(e.toString());
512                                 }
513                         } else if (code == ID_NAME_MISMATCH) {
514                                 try {
515                                         // tidyPrint(lexer.errout, res.getString("warning"));
516                                         errorMessage.append(res.getString("warning"));
517                                         tag(errorMessage, node);
518                                         // tidyPrint(lexer.errout, res.getString("id_name_mismatch"));
519                                         errorMessage.append(res.getString("id_name_mismatch"));
520                                 } catch (MissingResourceException e) {
521                                         tidyPrintln(e.toString());
522                                 }
523                         }
524
525                         // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR));
526                         attributes.put(
527                                 IMarker.SEVERITY,
528                                 new Integer(IMarker.SEVERITY_WARNING));
529                         // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
530                         attributes.put(JtidyPlugin.MARKER_NAME, Boolean.TRUE);
531                         try {
532                                 MarkerUtilities.setMessage(attributes, errorMessage.toString());
533                                 MarkerUtilities.createMarker(
534                                         lexer.getIFile(),
535                                         attributes,
536                                         IMarker.PROBLEM);
537                         } catch (CoreException e) {
538                         }
539                         tidyPrintln();
540                 } else if (code == UNEXPECTED_GT) {
541                         //   position(lexer);
542                         MarkerUtilities.setLineNumber(attributes, lexer.lines);
543                         try {
544                                 // tidyPrint(lexer.errout, res.getString("error"));
545                                 errorMessage.append(res.getString("error"));
546                                 tag(errorMessage, node);
547                                 // tidyPrint(lexer.errout, res.getString("unexpected_gt"));
548                                 errorMessage.append(res.getString("unexpected_gt"));
549                                 attributes.put(
550                                         IMarker.SEVERITY,
551                                         new Integer(IMarker.SEVERITY_ERROR));
552                                 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING));
553                                 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
554                                 attributes.put(JtidyPlugin.MARKER_NAME, Boolean.TRUE);
555                                 try {
556                                         MarkerUtilities.setMessage(
557                                                 attributes,
558                                                 errorMessage.toString());
559                                         MarkerUtilities.createMarker(
560                                                 lexer.getIFile(),
561                                                 attributes,
562                                                 IMarker.PROBLEM);
563                                 } catch (CoreException e) {
564                                 }
565                         } catch (MissingResourceException e) {
566                                 tidyPrintln(e.toString());
567                         }
568                         tidyPrintln();
569                         lexer.errors++;
570                         ;
571                 }
572
573         }
574
575         public static void warning(
576                 Lexer lexer,
577                 Node element,
578                 Node node,
579                 short code) {
580
581               
582                 TagTable tt = lexer.configuration.tt;
583
584                 lexer.warnings++;
585
586                 /* keep quiet after 6 errors */
587                 if (lexer.errors > 6)
588                         return;
589
590                 if (lexer.configuration.ShowWarnings) {
591
592                         /* on end of file adjust reported position to end of input */
593                         if (code == UNEXPECTED_END_OF_FILE) {
594                                 lexer.lines = lexer.in.curline;
595                                 lexer.columns = lexer.in.curcol;
596                         }
597
598                         //    position(lexer);
599                         Hashtable attributes = new Hashtable();
600                         StringBuffer errorMessage =
601                                 new StringBuffer("Column " + lexer.columns + ": ");
602
603                         MarkerUtilities.setLineNumber(attributes, lexer.lines);
604
605                         if (code == MISSING_ENDTAG_FOR) {
606                                 try {
607                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("missing_endtag_for"), new Object[] { element.element }));
608                                         errorMessage.append(
609                                                 MessageFormat.format(
610                                                         res.getString("missing_endtag_for"),
611                                                         new Object[] { element.element }));
612                                 } catch (MissingResourceException e) {
613                                         tidyPrintln(e.toString());
614                                 }
615                         } else if (code == MISSING_ENDTAG_BEFORE) {
616                                 try {
617                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("missing_endtag_before"), new Object[] { element.element }));
618                                         errorMessage.append(
619                                                 MessageFormat.format(
620                                                         res.getString("missing_endtag_before"),
621                                                         new Object[] { element.element }));
622
623                                 } catch (MissingResourceException e) {
624                                         tidyPrintln(e.toString());
625                                 }
626                                 tag(errorMessage, node);
627                         } else if (code == DISCARDING_UNEXPECTED) {
628                                 //REVISIT: DIscarding... message
629                                 //return;
630                                 //        try {
631                                 //          // tidyPrint(lexer.errout, res.getString("discarding_unexpected"));
632                                 //          errorMessage.append(res.getString("discarding_unexpected"));
633                                 //        } catch (MissingResourceException e) {
634                                 //          tidyPrintln(e.toString());
635                                 //        }
636                                 //        tag(errorMessage, lexer, node);
637                         } else if (code == NESTED_EMPHASIS) {
638                                 try {
639                                         // tidyPrint(lexer.errout, res.getString("nested_emphasis"));
640                                         errorMessage.append(res.getString("nested_emphasis"));
641                                 } catch (MissingResourceException e) {
642                                         tidyPrintln(e.toString());
643                                 }
644                                 tag(errorMessage, node);
645                         } else if (code == COERCE_TO_ENDTAG) {
646                                 try {
647                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("coerce_to_endtag"), new Object[] { element.element }));
648                                         errorMessage.append(
649                                                 MessageFormat.format(
650                                                         res.getString("coerce_to_endtag"),
651                                                         new Object[] { element.element }));
652                                 } catch (MissingResourceException e) {
653                                         tidyPrintln(e.toString());
654                                 }
655                         } else if (code == NON_MATCHING_ENDTAG) {
656                                 try {
657                                         // tidyPrint(lexer.errout, res.getString("non_matching_endtag_1"));
658                                         errorMessage.append(res.getString("non_matching_endtag_1"));
659                                 } catch (MissingResourceException e) {
660                                         tidyPrintln(e.toString());
661                                 }
662                                 tag(errorMessage, node);
663                                 try {
664                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("non_matching_endtag_2"), new Object[] { element.element }));
665                                         errorMessage.append(
666                                                 MessageFormat.format(
667                                                         res.getString("non_matching_endtag_2"),
668                                                         new Object[] { element.element }));
669                                 } catch (MissingResourceException e) {
670                                         tidyPrintln(e.toString());
671                                 }
672                         } else if (code == TAG_NOT_ALLOWED_IN) {
673                                 try {
674                                         // tidyPrint(lexer.errout, res.getString("warning"));
675                                         errorMessage.append(res.getString("warning"));
676                                 } catch (MissingResourceException e) {
677                                         tidyPrintln(e.toString());
678                                 }
679                                 tag(errorMessage, node);
680                                 try {
681                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("tag_not_allowed_in"), new Object[] { element.element }));
682                                         errorMessage.append(
683                                                 MessageFormat.format(
684                                                         res.getString("tag_not_allowed_in"),
685                                                         new Object[] { element.element }));
686                                 } catch (MissingResourceException e) {
687                                         tidyPrintln(e.toString());
688                                 }
689                         } else if (code == DOCTYPE_AFTER_TAGS) {
690                                 try {
691                                         // tidyPrint(lexer.errout, res.getString("doctype_after_tags"));
692                                         errorMessage.append(res.getString("doctype_after_tags"));
693                                 } catch (MissingResourceException e) {
694                                         tidyPrintln(e.toString());
695                                 }
696                         } else if (code == MISSING_STARTTAG) {
697                                 try {
698                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("missing_starttag"), new Object[] { node.element }));
699                                         errorMessage.append(
700                                                 MessageFormat.format(
701                                                         res.getString("missing_starttag"),
702                                                         new Object[] { node.element }));
703                                 } catch (MissingResourceException e) {
704                                         tidyPrintln(e.toString());
705                                 }
706                         } else if (code == UNEXPECTED_ENDTAG) {
707                                 try {
708                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("unexpected_endtag"), new Object[] { node.element }));
709                                         if (element != null)
710                                                 //            tidyPrint(
711                                                 //              lexer.errout,
712                                                 //              MessageFormat.format(res.getString("unexpected_endtag_suffix"), new Object[] { element.element }));
713                                                 errorMessage.append(
714                                                         MessageFormat.format(
715                                                                 res.getString("unexpected_endtag"),
716                                                                 new Object[] { node.element }));
717                                 } catch (MissingResourceException e) {
718                                         tidyPrintln(e.toString());
719                                 }
720                         } else if (code == TOO_MANY_ELEMENTS) {
721                                 try {
722                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("too_many_elements"), new Object[] { node.element }));
723                                         if (element != null)
724                                                 //            tidyPrint(
725                                                 //              lexer.errout,
726                                                 //              MessageFormat.format(res.getString("too_many_elements_suffix"), new Object[] { element.element }));
727                                                 errorMessage.append(
728                                                         MessageFormat.format(
729                                                                 res.getString("too_many_elements"),
730                                                                 new Object[] { node.element }));
731                                 } catch (MissingResourceException e) {
732                                         tidyPrintln(e.toString());
733                                 }
734                         } else if (code == USING_BR_INPLACE_OF) {
735                                 try {
736                                         // tidyPrint(lexer.errout, res.getString("using_br_inplace_of"));
737                                         errorMessage.append(res.getString("using_br_inplace_of"));
738                                 } catch (MissingResourceException e) {
739                                         tidyPrintln(e.toString());
740                                 }
741                                 tag(errorMessage, node);
742                         } else if (code == INSERTING_TAG) {
743                                 try {
744                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("inserting_tag"), new Object[] { node.element }));
745                                         errorMessage.append(
746                                                 MessageFormat.format(
747                                                         res.getString("inserting_tag"),
748                                                         new Object[] { node.element }));
749                                 } catch (MissingResourceException e) {
750                                         tidyPrintln(e.toString());
751                                 }
752                         } else if (code == CANT_BE_NESTED) {
753                                 try {
754                                         // tidyPrint(lexer.errout, res.getString("warning"));
755                                         errorMessage.append(res.getString("warning"));
756                                 } catch (MissingResourceException e) {
757                                         tidyPrintln(e.toString());
758                                 }
759                                 tag(errorMessage, node);
760                                 try {
761                                         // tidyPrint(lexer.errout, res.getString("cant_be_nested"));
762                                         errorMessage.append(res.getString("cant_be_nested"));
763                                 } catch (MissingResourceException e) {
764                                         tidyPrintln(e.toString());
765                                 }
766                         } else if (code == PROPRIETARY_ELEMENT) {
767                                 try {
768                                         // tidyPrint(lexer.errout, res.getString("warning"));
769                                         errorMessage.append(res.getString("warning"));
770                                 } catch (MissingResourceException e) {
771                                         tidyPrintln(e.toString());
772                                 }
773                                 tag(errorMessage, node);
774                                 try {
775                                         // tidyPrint(lexer.errout, res.getString("proprietary_element"));
776                                         errorMessage.append(res.getString("proprietary_element"));
777                                 } catch (MissingResourceException e) {
778                                         tidyPrintln(e.toString());
779                                 }
780
781                                 if (node.tag == tt.tagLayer)
782                                         lexer.badLayout |= USING_LAYER;
783                                 else if (node.tag == tt.tagSpacer)
784                                         lexer.badLayout |= USING_SPACER;
785                                 else if (node.tag == tt.tagNobr)
786                                         lexer.badLayout |= USING_NOBR;
787                         } else if (code == OBSOLETE_ELEMENT) {
788                                 try {
789                                         if (element.tag != null
790                                                 && (element.tag.model & Dict.CM_OBSOLETE) != 0) {
791                                                 // tidyPrint(lexer.errout, res.getString("obsolete_element"));
792                                                 errorMessage.append(res.getString("obsolete_element"));
793                                         } else {
794                                                 // tidyPrint(lexer.errout, res.getString("replacing_element"));
795                                                 errorMessage.append(res.getString("replacing_element"));
796                                         }
797
798                                 } catch (MissingResourceException e) {
799                                         tidyPrintln(e.toString());
800                                 }
801                                 tag(errorMessage, element);
802                                 try {
803                                         // tidyPrint(lexer.errout, res.getString("by"));
804                                         errorMessage.append(res.getString("by"));
805                                 } catch (MissingResourceException e) {
806                                         tidyPrintln(e.toString());
807                                 }
808                                 tag(errorMessage, node);
809                         } else if (code == TRIM_EMPTY_ELEMENT) {
810                                 try {
811                                         // tidyPrint(lexer.errout, res.getString("trim_empty_element"));
812                                         errorMessage.append(res.getString("trim_empty_element"));
813                                 } catch (MissingResourceException e) {
814                                         tidyPrintln(e.toString());
815                                 }
816                                 tag(errorMessage, element);
817                         } else if (code == MISSING_TITLE_ELEMENT) {
818                                 try {
819                                         // tidyPrint(lexer.errout, res.getString("missing_title_element"));
820                                         errorMessage.append(res.getString("missing_title_element"));
821                                 } catch (MissingResourceException e) {
822                                         tidyPrintln(e.toString());
823                                 }
824                         } else if (code == ILLEGAL_NESTING) {
825                                 try {
826                                         // tidyPrint(lexer.errout, res.getString("warning"));
827                                         errorMessage.append(res.getString("warning"));
828                                 } catch (MissingResourceException e) {
829                                         tidyPrintln(e.toString());
830                                 }
831                                 tag(errorMessage, element);
832                                 try {
833                                         // tidyPrint(lexer.errout, res.getString("illegal_nesting"));
834                                         errorMessage.append(res.getString("illegal_nesting"));
835                                 } catch (MissingResourceException e) {
836                                         tidyPrintln(e.toString());
837                                 }
838                         } else if (code == NOFRAMES_CONTENT) {
839                                 try {
840                                         // tidyPrint(lexer.errout, res.getString("warning"));
841                                         errorMessage.append(res.getString("warning"));
842                                 } catch (MissingResourceException e) {
843                                         tidyPrintln(e.toString());
844                                 }
845                                 tag(errorMessage, node);
846                                 try {
847                                         // tidyPrint(lexer.errout, res.getString("noframes_content"));
848                                         errorMessage.append(res.getString("noframes_content"));
849                                 } catch (MissingResourceException e) {
850                                         tidyPrintln(e.toString());
851                                 }
852                         } else if (code == INCONSISTENT_VERSION) {
853                                 try {
854                                         // tidyPrint(lexer.errout, res.getString("inconsistent_version"));
855                                         errorMessage.append(res.getString("inconsistent_version"));
856                                 } catch (MissingResourceException e) {
857                                         tidyPrintln(e.toString());
858                                 }
859                         } else if (code == MALFORMED_DOCTYPE) {
860                                 try {
861                                         // tidyPrint(lexer.errout, res.getString("malformed_doctype"));
862                                         errorMessage.append(res.getString("malformed_doctype"));
863                                 } catch (MissingResourceException e) {
864                                         tidyPrintln(e.toString());
865                                 }
866                         } else if (code == CONTENT_AFTER_BODY) {
867                                 try {
868                                         // tidyPrint(lexer.errout, res.getString("content_after_body"));
869                                         errorMessage.append(res.getString("content_after_body"));
870                                 } catch (MissingResourceException e) {
871                                         tidyPrintln(e.toString());
872                                 }
873                         } else if (code == MALFORMED_COMMENT) {
874                                 try {
875                                         // tidyPrint(lexer.errout, res.getString("malformed_comment"));
876                                         errorMessage.append(res.getString("malformed_comment"));
877                                 } catch (MissingResourceException e) {
878                                         tidyPrintln(e.toString());
879                                 }
880                         } else if (code == BAD_COMMENT_CHARS) {
881                                 try {
882                                         // tidyPrint(lexer.errout, res.getString("bad_comment_chars"));
883                                         errorMessage.append(res.getString("bad_comment_chars"));
884                                 } catch (MissingResourceException e) {
885                                         tidyPrintln(e.toString());
886                                 }
887                         } else if (code == BAD_XML_COMMENT) {
888                                 try {
889                                         // tidyPrint(lexer.errout, res.getString("bad_xml_comment"));
890                                         errorMessage.append(res.getString("bad_xml_comment"));
891                                 } catch (MissingResourceException e) {
892                                         tidyPrintln(e.toString());
893                                 }
894                         } else if (code == BAD_CDATA_CONTENT) {
895                                 try {
896                                         // tidyPrint(lexer.errout, res.getString("bad_cdata_content"));
897                                         errorMessage.append(res.getString("bad_cdata_content"));
898                                 } catch (MissingResourceException e) {
899                                         tidyPrintln(e.toString());
900                                 }
901                         } else if (code == INCONSISTENT_NAMESPACE) {
902                                 try {
903                                         // tidyPrint(lexer.errout, res.getString("inconsistent_namespace"));
904                                         errorMessage.append(
905                                                 res.getString("inconsistent_namespace"));
906                                 } catch (MissingResourceException e) {
907                                         tidyPrintln(e.toString());
908                                 }
909                         } else if (code == DTYPE_NOT_UPPER_CASE) {
910                                 try {
911                                         // tidyPrint(lexer.errout, res.getString("dtype_not_upper_case"));
912                                         errorMessage.append(res.getString("dtype_not_upper_case"));
913                                 } catch (MissingResourceException e) {
914                                         tidyPrintln(e.toString());
915                                 }
916                         } else if (code == UNEXPECTED_END_OF_FILE) {
917                                 try {
918                                         // tidyPrint(lexer.errout, res.getString("unexpected_end_of_file"));
919                                         errorMessage.append(
920                                                 res.getString("unexpected_end_of_file"));
921                                 } catch (MissingResourceException e) {
922                                         tidyPrintln(e.toString());
923                                 }
924                                 tag(errorMessage, element);
925                         }
926                         //       attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR));
927                         attributes.put(
928                                 IMarker.SEVERITY,
929                                 new Integer(IMarker.SEVERITY_WARNING));
930                         attributes.put(JtidyPlugin.MARKER_NAME, Boolean.TRUE);
931                         //  attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
932                         try {
933                                 MarkerUtilities.setMessage(attributes, errorMessage.toString());
934                                 MarkerUtilities.createMarker(
935                                         lexer.getIFile(),
936                                         attributes,
937                                         IMarker.PROBLEM);
938                         } catch (CoreException e) {
939                         }
940                         tidyPrintln();
941                 }
942         }
943
944         public static void error(
945                 Lexer lexer,
946                 Node element,
947                 Node node,
948                 short code) {
949                 lexer.warnings++;
950
951                 /* keep quiet after 6 errors */
952                 if (lexer.errors > 6)
953                         return;
954
955                 lexer.errors++;
956
957                 // position(lexer);
958
959                 Hashtable attributes = new Hashtable();
960                 StringBuffer errorMessage =
961                         new StringBuffer("Column " + lexer.columns + ": ");
962
963                 MarkerUtilities.setLineNumber(attributes, lexer.lines);
964
965                 if (code == SUSPECTED_MISSING_QUOTE) {
966                         try {
967                                 // tidyPrint(lexer.errout, res.getString("suspected_missing_quote"));
968                                 errorMessage.append(res.getString("suspected_missing_quote"));
969
970                         } catch (MissingResourceException e) {
971                                 tidyPrintln(e.toString());
972                         }
973                 } else if (code == DUPLICATE_FRAMESET) {
974                         try {
975                                 // tidyPrint(lexer.errout, res.getString("duplicate_frameset"));
976                                 errorMessage.append(res.getString("duplicate_frameset"));
977                         } catch (MissingResourceException e) {
978                                 tidyPrintln(e.toString());
979                         }
980                 } else if (code == UNKNOWN_ELEMENT) {
981                         try {
982                                 // tidyPrint(lexer.errout, res.getString("error"));
983                                 errorMessage.append(res.getString("error"));
984                         } catch (MissingResourceException e) {
985                                 tidyPrintln(e.toString());
986                         }
987                         tag(errorMessage, node);
988                         try {
989                                 // tidyPrint(lexer.errout, res.getString("unknown_element"));
990                                 errorMessage.append(res.getString("unknown_element"));
991                         } catch (MissingResourceException e) {
992                                 tidyPrintln(e.toString());
993                         }
994                 } else if (code == UNEXPECTED_ENDTAG) {
995                         try {
996                                 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("unexpected_endtag"), new Object[] { node.element }));
997                                 errorMessage.append(
998                                         MessageFormat.format(
999                                                 res.getString("unexpected_endtag"),
1000                                                 new Object[] { node.element }));
1001                                 if (element != null) {
1002                                         //          tidyPrint(
1003                                         //            lexer.errout,
1004                                         //            MessageFormat.format(res.getString("unexpected_endtag_suffix"), new Object[] { element.element }));
1005                                         //          errorMessage.append(MessageFormat.format(res.getString("unexpected_endtag_suffix"), new Object[] { element.element }));
1006                                 }
1007                         } catch (MissingResourceException e) {
1008                                 tidyPrintln(e.toString());
1009                         }
1010                 }
1011                 attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR));
1012                 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING));
1013                 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
1014                 attributes.put(JtidyPlugin.MARKER_NAME, Boolean.TRUE);
1015                 try {
1016                         MarkerUtilities.setMessage(attributes, errorMessage.toString());
1017                         MarkerUtilities.createMarker(
1018                                 lexer.getIFile(),
1019                                 attributes,
1020                                 IMarker.PROBLEM);
1021                 } catch (CoreException e) {
1022                 }
1023                 //   tidyPrintln(lexer.errout);
1024         }
1025
1026         public static void errorSummary(Lexer lexer) {
1027                 /* adjust badAccess to that its null if frames are ok */
1028                 if ((lexer.badAccess & (USING_FRAMES | USING_NOFRAMES)) != 0) {
1029                         if (!(((lexer.badAccess & USING_FRAMES) != 0)
1030                                 && ((lexer.badAccess & USING_NOFRAMES) == 0)))
1031                                 lexer.badAccess &= ~(USING_FRAMES | USING_NOFRAMES);
1032                 }
1033
1034                 Hashtable attributes = new Hashtable();
1035                 StringBuffer errorMessage =
1036                         new StringBuffer("Column " + lexer.columns + ": ");
1037
1038                 MarkerUtilities.setLineNumber(attributes, lexer.lines);
1039
1040                 if (lexer.badChars != 0) {
1041                         if ((lexer.badChars & WINDOWS_CHARS) != 0) {
1042                                 try {
1043                                         // tidyPrint(lexer.errout, res.getString("badchars_summary"));
1044                                         errorMessage.append(res.getString("badchars_summary"));
1045                                 } catch (MissingResourceException e) {
1046                                         tidyPrintln(e.toString());
1047                                 }
1048                         }
1049                 }
1050
1051                 if (lexer.badForm != 0) {
1052                         try {
1053                                 // tidyPrint(lexer.errout, res.getString("badform_summary"));
1054                                 errorMessage.append(res.getString("badform_summary"));
1055                         } catch (MissingResourceException e) {
1056                                 tidyPrintln(e.toString());
1057                         }
1058                 }
1059
1060                 if (lexer.badAccess != 0) {
1061                         if ((lexer.badAccess & MISSING_SUMMARY) != 0) {
1062                                 try {
1063                                         // tidyPrint(lexer.errout, res.getString("badaccess_missing_summary"));
1064                                         errorMessage.append(
1065                                                 res.getString("badaccess_missing_summary"));
1066                                 } catch (MissingResourceException e) {
1067                                         tidyPrintln(e.toString());
1068                                 }
1069                         }
1070
1071                         if ((lexer.badAccess & MISSING_IMAGE_ALT) != 0) {
1072                                 try {
1073                                         // tidyPrint(lexer.errout, res.getString("badaccess_missing_image_alt"));
1074                                         errorMessage.append(
1075                                                 res.getString("badaccess_missing_image_alt"));
1076                                 } catch (MissingResourceException e) {
1077                                         tidyPrintln(e.toString());
1078                                 }
1079                         }
1080
1081                         if ((lexer.badAccess & MISSING_IMAGE_MAP) != 0) {
1082                                 try {
1083                                         // tidyPrint(lexer.errout, res.getString("badaccess_missing_image_map"));
1084                                         errorMessage.append(
1085                                                 res.getString("badaccess_missing_image_map"));
1086                                 } catch (MissingResourceException e) {
1087                                         tidyPrintln(e.toString());
1088                                 }
1089                         }
1090
1091                         if ((lexer.badAccess & MISSING_LINK_ALT) != 0) {
1092                                 try {
1093                                         // tidyPrint(lexer.errout, res.getString("badaccess_missing_link_alt"));
1094                                         errorMessage.append(
1095                                                 res.getString("badaccess_missing_link_alt"));
1096                                 } catch (MissingResourceException e) {
1097                                         tidyPrintln(e.toString());
1098                                 }
1099                         }
1100
1101                         if (((lexer.badAccess & USING_FRAMES) != 0)
1102                                 && ((lexer.badAccess & USING_NOFRAMES) == 0)) {
1103                                 try {
1104                                         // tidyPrint(lexer.errout, res.getString("badaccess_frames"));
1105                                         errorMessage.append(res.getString("badaccess_frames"));
1106                                 } catch (MissingResourceException e) {
1107                                         tidyPrintln(e.toString());
1108                                 }
1109                         }
1110
1111                         try {
1112                                 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("badaccess_summary"), new Object[] { ACCESS_URL }));
1113                                 errorMessage.append(
1114                                         MessageFormat.format(
1115                                                 res.getString("badaccess_summary"),
1116                                                 new Object[] { ACCESS_URL }));
1117                         } catch (MissingResourceException e) {
1118                                 tidyPrintln(e.toString());
1119                         }
1120                 }
1121
1122                 if (lexer.badLayout != 0) {
1123                         if ((lexer.badLayout & USING_LAYER) != 0) {
1124                                 try {
1125                                         // tidyPrint(lexer.errout, res.getString("badlayout_using_layer"));
1126                                         errorMessage.append(res.getString("badlayout_using_layer"));
1127                                 } catch (MissingResourceException e) {
1128                                         tidyPrintln(e.toString());
1129                                 }
1130                         }
1131
1132                         if ((lexer.badLayout & USING_SPACER) != 0) {
1133                                 try {
1134                                         // tidyPrint(lexer.errout, res.getString("badlayout_using_spacer"));
1135                                         errorMessage.append(
1136                                                 res.getString("badlayout_using_spacer"));
1137                                 } catch (MissingResourceException e) {
1138                                         tidyPrintln(e.toString());
1139                                 }
1140                         }
1141
1142                         if ((lexer.badLayout & USING_FONT) != 0) {
1143                                 try {
1144                                         // tidyPrint(lexer.errout, res.getString("badlayout_using_font"));
1145                                         errorMessage.append(res.getString("badlayout_using_font"));
1146                                 } catch (MissingResourceException e) {
1147                                         tidyPrintln(e.toString());
1148                                 }
1149                         }
1150
1151                         if ((lexer.badLayout & USING_NOBR) != 0) {
1152                                 try {
1153                                         // tidyPrint(lexer.errout, res.getString("badlayout_using_nobr"));
1154                                         errorMessage.append(res.getString("badlayout_using_nobr"));
1155                                 } catch (MissingResourceException e) {
1156                                         tidyPrintln(e.toString());
1157                                 }
1158                         }
1159
1160                         if ((lexer.badLayout & USING_BODY) != 0) {
1161                                 try {
1162                                         // tidyPrint(lexer.errout, res.getString("badlayout_using_body"));
1163                                         errorMessage.append(res.getString("badlayout_using_body"));
1164                                 } catch (MissingResourceException e) {
1165                                         tidyPrintln(e.toString());
1166                                 }
1167                         }
1168                         attributes.put(
1169                                 IMarker.SEVERITY,
1170                                 new Integer(IMarker.SEVERITY_ERROR));
1171                         // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING));
1172                         // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
1173                         attributes.put(JtidyPlugin.MARKER_NAME, Boolean.TRUE);
1174                         try {
1175                                 MarkerUtilities.setMessage(attributes, errorMessage.toString());
1176                                 MarkerUtilities.createMarker(
1177                                         lexer.getIFile(),
1178                                         attributes,
1179                                         IMarker.PROBLEM);
1180                         } catch (CoreException e) {
1181                         }
1182                 }
1183         }
1184
1185         public static void unknownOption(PrintWriter errout, char c) {
1186                 try {
1187                         tidyPrintln(
1188                                 MessageFormat.format(
1189                                         res.getString("unrecognized_option"),
1190                                         new Object[] { new String(new char[] { c })
1191                         }));
1192                 } catch (MissingResourceException e) {
1193                         tidyPrintln(e.toString());
1194                 }
1195         }
1196
1197         public static void unknownFile(
1198                 PrintWriter errout,
1199                 String program,
1200                 String file) {
1201                 try {
1202                         tidyPrintln(
1203                                 MessageFormat.format(
1204                                         res.getString("unknown_file"),
1205                                         new Object[] { program, file }));
1206                 } catch (MissingResourceException e) {
1207                         tidyPrintln(e.toString());
1208                 }
1209         }
1210
1211         public static void needsAuthorIntervention(PrintWriter errout) {
1212                 try {
1213                         tidyPrintln(res.getString("needs_author_intervention"));
1214                 } catch (MissingResourceException e) {
1215                         tidyPrintln(e.toString());
1216                 }
1217         }
1218
1219         public static void missingBody(PrintWriter errout) {
1220                 try {
1221                         tidyPrintln(res.getString("missing_body"));
1222                 } catch (MissingResourceException e) {
1223                         tidyPrintln(e.toString());
1224                 }
1225         }
1226
1227         public static void reportNumberOfSlides(PrintWriter errout, int count) {
1228                 try {
1229                         tidyPrintln(
1230                                 MessageFormat.format(
1231                                         res.getString("slides_found"),
1232                                         new Object[] { new Integer(count)}));
1233                 } catch (MissingResourceException e) {
1234                         tidyPrintln(e.toString());
1235                 }
1236         }
1237
1238         public static void generalInfo(PrintWriter errout) {
1239                 try {
1240                         tidyPrintln(res.getString("general_info"));
1241                 } catch (MissingResourceException e) {
1242                         tidyPrintln(e.toString());
1243                 }
1244         }
1245
1246         public static void helloMessage(
1247                 PrintWriter errout,
1248                 String date,
1249                 String filename) {
1250                 currentFile = filename; /* for use with Gnu Emacs */
1251
1252                 try {
1253                         tidyPrintln(
1254                                 MessageFormat.format(
1255                                         res.getString("hello_message"),
1256                                         new Object[] { date, filename }));
1257                 } catch (MissingResourceException e) {
1258                         tidyPrintln(e.toString());
1259                 }
1260         }
1261
1262         public static void reportVersion(
1263                 PrintWriter errout,
1264                 Lexer lexer,
1265                 String filename,
1266                 Node doctype) {
1267                 int i, c;
1268                 int state = 0;
1269                 String vers = lexer.HTMLVersionName();
1270                 MutableInteger cc = new MutableInteger();
1271
1272                 try {
1273                         if (doctype != null) {
1274                                 tidyPrint(
1275                                         MessageFormat.format(
1276                                                 res.getString("doctype_given"),
1277                                                 new Object[] { filename }));
1278                 StringBuffer buf = new StringBuffer();
1279                                 for (i = doctype.start; i < doctype.end; ++i) {
1280                                         c = (int) doctype.textarray[i];
1281
1282                                         /* look for UTF-8 multibyte character */
1283                                         if (c < 0) {
1284                                                 i += PPrint.getUTF8(doctype.textarray, i, cc);
1285                                                 c = cc.value;
1286                                         }
1287
1288                                         if (c == (char) '"')
1289                                                 ++state;
1290                                         else if (state == 1) {
1291                                                 buf.append(c);
1292                                         // tidyPrint((char) c);
1293                                         }
1294                                 }
1295
1296                         //      tidyPrint('"');
1297                                 buf.append('"');
1298                                 tidyPrint( buf.toString() );
1299                         }
1300
1301                         tidyPrintln(
1302                                 MessageFormat.format(
1303                                         res.getString("report_version"),
1304                                         new Object[] {
1305                                                 filename,
1306                                                 (vers != null ? vers : "HTML proprietary")}));
1307                 } catch (MissingResourceException e) {
1308                         tidyPrintln(e.toString());
1309                 }
1310         }
1311
1312         public static void reportNumWarnings(PrintWriter errout, Lexer lexer) {
1313                 if (lexer.warnings > 0) {
1314                         try {
1315                                 tidyPrintln(
1316                                         MessageFormat.format(
1317                                                 res.getString("num_warnings"),
1318                                                 new Object[] { new Integer(lexer.warnings)}));
1319                         } catch (MissingResourceException e) {
1320                                 tidyPrintln(e.toString());
1321                         }
1322                 } else {
1323                         try {
1324                                 tidyPrintln(res.getString("no_warnings"));
1325                         } catch (MissingResourceException e) {
1326                                 tidyPrintln(e.toString());
1327                         }
1328                 }
1329         }
1330
1331         public static void helpText(PrintWriter out, String prog) {
1332                 try {
1333                         tidyPrintln(
1334                                 MessageFormat.format(
1335                                         res.getString("help_text"),
1336                                         new Object[] { prog, RELEASE_DATE }));
1337                 } catch (MissingResourceException e) {
1338                         tidyPrintln(e.toString());
1339                 }
1340         }
1341
1342         public static void badTree(PrintWriter errout) {
1343                 try {
1344                         tidyPrintln(res.getString("bad_tree"));
1345                 } catch (MissingResourceException e) {
1346                         tidyPrintln(e.toString());
1347                 }
1348         }
1349
1350 }