| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
package org.mozilla.javascript.ast; |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
public class ParseProblem { |
| 13 |
|
| 14 |
public static enum Type {Error, Warning} |
| 15 |
|
| 16 |
private Type type; |
| 17 |
private String message; |
| 18 |
private String sourceName; |
| 19 |
private int offset; |
| 20 |
private int length; |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
public ParseProblem(ParseProblem.Type type, String message, |
| 26 |
String sourceName, int offset, int length) { |
| 27 |
setType(type); |
| 28 |
setMessage(message); |
| 29 |
setSourceName(sourceName); |
| 30 |
setFileOffset(offset); |
| 31 |
setLength(length); |
| 32 |
} |
| 33 |
|
| 34 |
public ParseProblem.Type getType() { |
| 35 |
return type; |
| 36 |
} |
| 37 |
|
| 38 |
public void setType(ParseProblem.Type type) { |
| 39 |
this.type = type; |
| 40 |
} |
| 41 |
|
| 42 |
public String getMessage() { |
| 43 |
return message; |
| 44 |
} |
| 45 |
|
| 46 |
public void setMessage(String msg) { |
| 47 |
this.message = msg; |
| 48 |
} |
| 49 |
|
| 50 |
public String getSourceName() { |
| 51 |
return sourceName; |
| 52 |
} |
| 53 |
|
| 54 |
public void setSourceName(String name) { |
| 55 |
this.sourceName = name; |
| 56 |
} |
| 57 |
|
| 58 |
public int getFileOffset() { |
| 59 |
return offset; |
| 60 |
} |
| 61 |
|
| 62 |
public void setFileOffset(int offset) { |
| 63 |
this.offset = offset; |
| 64 |
} |
| 65 |
|
| 66 |
public int getLength() { |
| 67 |
return length; |
| 68 |
} |
| 69 |
|
| 70 |
public void setLength(int length) { |
| 71 |
this.length = length; |
| 72 |
} |
| 73 |
|
| 74 |
@Override |
| 75 |
public String toString() { |
| 76 |
StringBuilder sb = new StringBuilder(200); |
| 77 |
sb.append(sourceName).append(":"); |
| 78 |
sb.append("offset=").append(offset).append(","); |
| 79 |
sb.append("length=").append(length).append(","); |
| 80 |
sb.append(type == Type.Error ? "error: " : "warning: "); |
| 81 |
sb.append(message); |
| 82 |
return sb.toString(); |
| 83 |
} |
| 84 |
} |