| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
package org.mozilla.javascript.ast; |
| 8 |
|
| 9 |
import org.mozilla.javascript.EvaluatorException; |
| 10 |
|
| 11 |
import java.util.ArrayList; |
| 12 |
import java.util.List; |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
public class ErrorCollector implements IdeErrorReporter { |
| 23 |
|
| 24 |
private List<ParseProblem> errors = new ArrayList<ParseProblem>(); |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
public void warning(String message, String sourceName, int line, |
| 32 |
String lineSource, int lineOffset) { |
| 33 |
throw new UnsupportedOperationException(); |
| 34 |
} |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
public void warning(String message, String sourceName, int offset, int length) |
| 40 |
{ |
| 41 |
errors.add(new ParseProblem(ParseProblem.Type.Warning, |
| 42 |
message, sourceName, |
| 43 |
offset, length)); |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
public void error(String message, String sourceName, int line, |
| 52 |
String lineSource, int lineOffset) |
| 53 |
{ |
| 54 |
throw new UnsupportedOperationException(); |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
public void error(String message, String sourceName, |
| 61 |
int fileOffset, int length) |
| 62 |
{ |
| 63 |
errors.add(new ParseProblem(ParseProblem.Type.Error, |
| 64 |
message, sourceName, |
| 65 |
fileOffset, length)); |
| 66 |
} |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
public EvaluatorException runtimeError(String message, String sourceName, |
| 72 |
int line, String lineSource, |
| 73 |
int lineOffset) |
| 74 |
{ |
| 75 |
throw new UnsupportedOperationException(); |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
public List<ParseProblem> getErrors() { |
| 82 |
return errors; |
| 83 |
} |
| 84 |
|
| 85 |
@Override |
| 86 |
public String toString() { |
| 87 |
StringBuilder sb = new StringBuilder(errors.size() * 100); |
| 88 |
for (ParseProblem pp : errors) { |
| 89 |
sb.append(pp.toString()).append("\n"); |
| 90 |
} |
| 91 |
return sb.toString(); |
| 92 |
} |
| 93 |
} |