1 19 20 package org.netbeans.modules.tasklist.html; 21 22 import javax.swing.text.*; 23 import javax.swing.event.*; 24 import java.awt.*; 25 import java.awt.event.*; 26 import javax.swing.*; 27 import java.io.*; 28 import java.util.List ; 29 import java.util.ArrayList ; 30 import org.openide.ErrorManager; 31 import org.openide.explorer.view.*; 32 33 34 import org.openide.loaders.DataObject; 35 import org.openide.text.Line; 36 37 import org.netbeans.modules.html.*; 38 39 import org.w3c.tidy.*; 40 41 import org.netbeans.modules.tasklist.core.TLUtils; 42 43 44 49 class ReportWriter extends PrintWriter { 50 private ErrorReporter reporter = null; 52 private int line = -1; 53 private int column = -1; 54 private boolean warning = false; 55 private StringBuffer sb = new StringBuffer (200); 56 57 ReportWriter(ErrorReporter reporter) { 58 super(new StringWriter()); this.reporter = reporter; 60 } 61 62 public void print(String msg) { 63 if (msg.startsWith("Error: ")) { warning = false; 65 71 } else if (msg.startsWith("Warning: ")) { warning = true; 73 if (msg.length() == 8) { 74 return; 75 } 76 msg = msg.substring(8); } 78 if ((sb.length() == 0) && 82 (msg.startsWith("line "))) { int i = 5; 86 int digit; 87 line = 0; 88 while (true) { 89 char c = msg.charAt(i++); 90 digit = Character.digit(c, 10); 91 if (digit == -1) { 92 break; 93 } 94 line *= 10; 95 line += digit; 96 } 97 } else { 100 sb.append(msg); 101 } 102 } 103 104 public void println(String msg) { 105 if (msg.startsWith("Error: ")) { warning = false; 107 113 } else if (msg.startsWith("Warning: ")) { warning = true; 115 if (msg.length() == 8) { 116 return; 117 } 118 msg = msg.substring(8); } 120 String content; 121 if (sb.length() > 0) { 122 sb.append(msg); 123 content = sb.toString(); 124 } else { 125 content = msg; 126 } 127 report(content); 128 } 129 130 public void println() { 131 if (sb.length() > 0) { 132 report(sb.toString()); 133 } 134 } 135 136 private void report(String msg) { 137 reporter.reportError(line, column, !warning, msg); 138 line = -1; 139 column = -1; 140 sb.setLength(0); 141 warning = false; 142 } 143 } 144 | Popular Tags |